@fluidframework/react 2.90.0-378676 → 2.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/propNode.js.map +1 -1
- package/lib/test/mochaHooks.js +13 -0
- package/lib/test/mochaHooks.js.map +1 -0
- package/lib/test/text/plainUtils.test.js +75 -0
- package/lib/test/text/plainUtils.test.js.map +1 -0
- package/lib/test/text/textEditor.test.js +704 -0
- package/lib/test/text/textEditor.test.js.map +1 -0
- package/lib/test/undoRedo.test.js +62 -0
- package/lib/test/undoRedo.test.js.map +1 -0
- package/lib/test/useObservation.spec.js +0 -1
- package/lib/test/useObservation.spec.js.map +1 -1
- package/lib/test/useTree.spec.js +0 -1
- package/lib/test/useTree.spec.js.map +1 -1
- package/lib/text/formatted/index.d.ts +6 -0
- package/lib/text/formatted/index.d.ts.map +1 -0
- package/lib/text/formatted/index.js +6 -0
- package/lib/text/formatted/index.js.map +1 -0
- package/lib/text/formatted/quillFormattedView.d.ts +54 -0
- package/lib/text/formatted/quillFormattedView.d.ts.map +1 -0
- package/lib/text/formatted/quillFormattedView.js +426 -0
- package/lib/text/formatted/quillFormattedView.js.map +1 -0
- package/lib/text/index.d.ts +7 -0
- package/lib/text/index.d.ts.map +1 -0
- package/lib/text/index.js +7 -0
- package/lib/text/index.js.map +1 -0
- package/lib/text/plain/index.d.ts +7 -0
- package/lib/text/plain/index.d.ts.map +1 -0
- package/lib/text/plain/index.js +7 -0
- package/lib/text/plain/index.js.map +1 -0
- package/lib/text/plain/plainTextView.d.ts +14 -0
- package/lib/text/plain/plainTextView.d.ts.map +1 -0
- package/lib/text/plain/plainTextView.js +75 -0
- package/lib/text/plain/plainTextView.js.map +1 -0
- package/lib/text/plain/plainUtils.d.ts +23 -0
- package/lib/text/plain/plainUtils.d.ts.map +1 -0
- package/lib/text/plain/plainUtils.js +51 -0
- package/lib/text/plain/plainUtils.js.map +1 -0
- package/lib/text/plain/quillView.d.ts +22 -0
- package/lib/text/plain/quillView.d.ts.map +1 -0
- package/lib/text/plain/quillView.js +112 -0
- package/lib/text/plain/quillView.js.map +1 -0
- package/lib/undoRedo.d.ts +51 -0
- package/lib/undoRedo.d.ts.map +1 -0
- package/lib/undoRedo.js +76 -0
- package/lib/undoRedo.js.map +1 -0
- package/package.json +26 -45
- package/react.test-files.tar +0 -0
- package/src/index.ts +10 -0
- package/src/propNode.ts +1 -1
- package/src/text/formatted/index.ts +11 -0
- package/src/text/formatted/quillFormattedView.tsx +509 -0
- package/src/text/index.ts +15 -0
- package/src/text/plain/index.ts +7 -0
- package/src/text/plain/plainTextView.tsx +110 -0
- package/src/text/plain/plainUtils.ts +68 -0
- package/src/text/plain/quillView.tsx +149 -0
- package/src/undoRedo.ts +117 -0
- package/tsconfig.json +6 -0
- package/api-extractor/api-extractor-lint-alpha.cjs.json +0 -5
- package/api-extractor/api-extractor-lint-beta.cjs.json +0 -5
- package/api-extractor/api-extractor-lint-public.cjs.json +0 -5
- package/dist/alpha.d.ts +0 -45
- package/dist/beta.d.ts +0 -15
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -26
- package/dist/index.js.map +0 -1
- package/dist/package.json +0 -4
- package/dist/propNode.d.ts +0 -114
- package/dist/propNode.d.ts.map +0 -1
- package/dist/propNode.js +0 -43
- package/dist/propNode.js.map +0 -1
- package/dist/public.d.ts +0 -15
- package/dist/reactSharedTreeView.d.ts +0 -119
- package/dist/reactSharedTreeView.d.ts.map +0 -1
- package/dist/reactSharedTreeView.js +0 -206
- package/dist/reactSharedTreeView.js.map +0 -1
- package/dist/simpleIdentifier.d.ts +0 -19
- package/dist/simpleIdentifier.d.ts.map +0 -1
- package/dist/simpleIdentifier.js +0 -33
- package/dist/simpleIdentifier.js.map +0 -1
- package/dist/useObservation.d.ts +0 -83
- package/dist/useObservation.d.ts.map +0 -1
- package/dist/useObservation.js +0 -295
- package/dist/useObservation.js.map +0 -1
- package/dist/useTree.d.ts +0 -80
- package/dist/useTree.d.ts.map +0 -1
- package/dist/useTree.js +0 -137
- package/dist/useTree.js.map +0 -1
- package/tsconfig.cjs.json +0 -7
package/dist/propNode.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"propNode.js","sourceRoot":"","sources":["../src/propNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6EH;;;;;;GAMG;AACH,SAAgB,kBAAkB,CACjC,QAA8B;IAE9B,OAAO,QAAa,CAAC;AACtB,CAAC;AAJD,gDAIC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CACnC,KAAQ;IAER,OAAO,KAAoC,CAAC;AAC7C,CAAC;AAJD,oDAIC;AAgDD;;;GAGG;AACH,SAAgB,cAAc,CAAqC,IAAO;IACzE,OAAO,IAAmC,CAAC;AAC5C,CAAC;AAFD,wCAEC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAuB,IAAO;IAC7D,OAAO,IAA4C,CAAC;AACrD,CAAC;AAFD,4CAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\nimport type { TreeNode, TreeLeafValue } from \"@fluidframework/tree\";\n\n/**\n * A type erased TreeNode for use in react props.\n * @remarks\n * Read content from the node using {@link usePropTreeNode} or {@link usePropTreeRecord}.\n *\n * In events where tracking dependencies is not required, the node can be unwrapped using {@link unwrapPropTreeNode}.\n *\n * To convert a TreeNode to this type use {@link toPropTreeNode} or {@link toPropTreeRecord}.\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type\nexport interface PropTreeNode<T extends TreeNode> extends ErasedType<[T, \"PropTreeNode\"]> {}\n\n/**\n * Type TreeNodes in T as {@link PropTreeNode}s.\n * @remarks\n * This only handles a few cases (TreeNode, structurally typed objects fields and arrays) and leaves other types as is.\n * Users which provide other types (e.g. maps) which contain TreeNodes will need to handle wrapping those themselves if the wrapping is desired.\n *\n * Users of this should not rely on a given use of TreeNode not being wrapped:\n * future changes to this API may add more cases which are wrapped, and this will be considered a non-breaking change.\n * @privateRemarks\n * Covering all cases is impossible, and trying to cover more with recursive mapped types can break some of the types by losing methods, private members, etc.\n * To mitigate this IsMappableObjectType is used for objects, and only mappable types, where the mapping actually impacted the type are modified.\n *\n * This is intended to cover the common cases, and users can handle other cases manually.\n * See the tests for this for more details.\n * @alpha\n */\nexport type WrapNodes<T> = T extends TreeNode\n\t? PropTreeNode<T>\n\t: T extends readonly (infer U)[]\n\t\t? readonly WrapNodes<U>[]\n\t\t: // `T extends (infer U)` distributes over unions, allowing WrapNodes<A|B> to be WrapNodes<A> | WrapNodes<B>.\n\t\t\tT extends infer U\n\t\t\t? IsMappableObjectType<\n\t\t\t\t\tU,\n\t\t\t\t\t{\n\t\t\t\t\t\t[P in keyof U]: WrapNodes<U[P]>;\n\t\t\t\t\t} extends U\n\t\t\t\t\t\t? // Returning U in this case (when assignable to the mapped type) avoids flatting named interfaces when they are unchanged.\n\t\t\t\t\t\t\tU\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t[P in keyof U]: WrapNodes<U[P]>;\n\t\t\t\t\t\t\t},\n\t\t\t\t\tT\n\t\t\t\t>\n\t\t\t: T;\n\n/**\n * Detect if a type is a simple structural object.\n * @remarks\n * This returns the true case if the type is entirely defined by its set of public properties.\n * More concretely, this indicates if creating a mapped type based on `T`\n * will be lossy due to details mapped types cannot access.\n *\n * This is shallow, and distributes over unions.\n *\n * This also returns the true case for primitive types since mapping over them leaves them unchanged if doing so in a generic context:\n * Mapping over a primitive does not leave them unchanged if done directly (not to a generic type parameter), but this can not detect that behavior.\n * This is fine as the use for this is to detect when making a mapped type from a generic type parameter would be lossy.\n * @system @alpha\n */\nexport type IsMappableObjectType<\n\tT,\n\tTrue = true,\n\tFalse = false,\n\tMapped = {\n\t\t[P in keyof T]: T[P];\n\t},\n> = [Mapped] extends [T] ? ([T] extends [Mapped] ? True : False) : False;\n\n/**\n * Casts a node from a {@link PropTreeNode} back to a TreeNode.\n * @remarks\n * This should only be done in scenarios where tracking observations is not required (such as event handlers),\n * or when taking care to handle invalidation manually.\n * @alpha\n */\nexport function unwrapPropTreeNode<T extends TreeNode | TreeLeafValue>(\n\tpropNode: PropTreeValue<T> | T,\n): T {\n\treturn propNode as T;\n}\n\n/**\n * {@link unwrapPropTreeNode} but for a {@link PropTreeNodeRecord}.\n * @alpha\n */\nexport function unwrapPropTreeRecord<T extends PropTreeNodeRecord>(\n\tprops: T,\n): UnwrapPropTreeNodeRecord<T> {\n\treturn props as UnwrapPropTreeNodeRecord<T>;\n}\n\n/**\n * {@inheritdoc unwrapPropTreeNode}\n * @alpha\n */\nexport type UnwrapPropTreeNode<T extends TreeLeafValue | PropTreeNode<TreeNode> | undefined> =\n\tT extends PropTreeNode<infer Node> ? Node : T;\n\n/**\n * Record that can contain TreeNodes.\n * @alpha\n */\nexport type NodeRecord = Record<string, TreeNode | TreeLeafValue>;\n\n/**\n * Type erase `TreeNode`s from a {@link NodeRecord} as a {@link PropTreeNode}.\n * @alpha\n */\nexport type WrapPropTreeNodeRecord<T extends NodeRecord> = {\n\treadonly [P in keyof T]: PropTreeValue<T[P]>;\n};\n\n/**\n * Type erase `TreeNode`s from a {@link NodeRecord} as a {@link PropTreeNode}.\n * @alpha\n */\nexport type UnwrapPropTreeNodeRecord<T extends PropTreeNodeRecord> = {\n\treadonly [P in keyof T]: UnwrapPropTreeNode<T[P]>;\n};\n\n/**\n * Type erase `TreeNode`s from a {@link NodeRecord} as a {@link PropTreeNode}.\n * @alpha\n */\nexport type PropTreeNodeRecord = Record<\n\tstring,\n\tTreeLeafValue | PropTreeNode<TreeNode> | undefined\n>;\n\n/**\n * Type erase a `TreeNode` from a `TreeNode | TreeLeafValue` as a {@link PropTreeNode}.\n * @alpha\n */\nexport type PropTreeValue<T extends TreeNode | TreeLeafValue | undefined> = T extends TreeNode\n\t? PropTreeNode<T>\n\t: T;\n\n/**\n * Type erase a TreeNode as a {@link PropTreeNode}.\n * @alpha\n */\nexport function toPropTreeNode<T extends TreeNode | TreeLeafValue>(node: T): PropTreeValue<T> {\n\treturn node as unknown as PropTreeValue<T>;\n}\n\n/**\n * Type erase a {@link NodeRecord} as a {@link PropTreeNodeRecord}.\n * @alpha\n */\nexport function toPropTreeRecord<T extends NodeRecord>(node: T): WrapPropTreeNodeRecord<T> {\n\treturn node as unknown as WrapPropTreeNodeRecord<T>;\n}\n"]}
|
package/dist/public.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Utilities for using SharedTree with React.
|
|
13
|
-
* @packageDocumentation
|
|
14
|
-
*/export {}
|
|
15
|
-
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { TreeDataObject } from "@fluidframework/aqueduct/internal";
|
|
6
|
-
import type { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
|
-
import type { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions/internal";
|
|
8
|
-
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
9
|
-
import type { SchemaCompatibilityStatus, TreeViewConfiguration, TreeFieldFromImplicitField, TreeView, ImplicitFieldSchema, InsertableTreeFieldFromImplicitField } from "@fluidframework/tree";
|
|
10
|
-
import * as React from "react";
|
|
11
|
-
import { type PropTreeValue } from "./propNode.js";
|
|
12
|
-
/**
|
|
13
|
-
* Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
14
|
-
* @param treeConfiguration - See {@link IReactTreeDataObject.config}.
|
|
15
|
-
* @param createInitialTree - Function which populates the tree with initial data on document create.
|
|
16
|
-
* @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.
|
|
17
|
-
* @alpha
|
|
18
|
-
*/
|
|
19
|
-
export declare function treeDataObject<TSchema extends ImplicitFieldSchema>(treeConfiguration: TreeViewConfiguration<TSchema>, createInitialTree: () => InsertableTreeFieldFromImplicitField<TSchema>): SharedObjectKind<IReactTreeDataObject<TSchema> & IFluidLoadable>;
|
|
20
|
-
/**
|
|
21
|
-
* Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
22
|
-
* @param treeConfiguration - See {@link IReactTreeDataObject.config}.
|
|
23
|
-
* @param createInitialTree - Function which populates the tree with initial data on document create.
|
|
24
|
-
* @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
export declare function treeDataObjectInternal<TSchema extends ImplicitFieldSchema>(treeConfiguration: TreeViewConfiguration<TSchema>, createInitialTree: () => InsertableTreeFieldFromImplicitField<TSchema>): SharedObjectKind<IReactTreeDataObject<TSchema> & IFluidLoadable & TreeDataObject> & {
|
|
28
|
-
readonly factory: IFluidDataStoreFactory;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* A schema-aware tree-backed DataObject, extended with a React Component to view the tree.
|
|
32
|
-
* @remarks Allows for the Tree's schema to be baked into the container schema.
|
|
33
|
-
* @sealed @alpha
|
|
34
|
-
*/
|
|
35
|
-
export interface IReactTreeDataObject<TSchema extends ImplicitFieldSchema> {
|
|
36
|
-
/**
|
|
37
|
-
* The configuration used to initialize new documents, as well as to interpret (schematize) existing ones.
|
|
38
|
-
*
|
|
39
|
-
* @remarks
|
|
40
|
-
* The fact that a single view schema is provided here (on the data object) makes it impossible to try and apply multiple different schema.
|
|
41
|
-
* Since the view schema currently does not provide any adapters for handling differences between view and stored schema,
|
|
42
|
-
* it's also impossible for this single view schema to handle multiple different stored schema.
|
|
43
|
-
* Therefore, with this current API, two different applications (or different versions of the same application)
|
|
44
|
-
* with differing stored schema requirements (as implied by their view schema) can not collaborate on the same tree.
|
|
45
|
-
* The only schema evolution that's currently possible is upgrading the schema to one that supports a superset of what the old schema allowed,
|
|
46
|
-
* and collaborating between clients which have view schema that exactly correspond to that stored schema.
|
|
47
|
-
* Future work on tree as well as these utilities should address this limitation.
|
|
48
|
-
*/
|
|
49
|
-
readonly config: TreeViewConfiguration<TSchema>;
|
|
50
|
-
/**
|
|
51
|
-
* The schema-aware view of the tree.
|
|
52
|
-
*/
|
|
53
|
-
readonly treeView: TreeView<TSchema>;
|
|
54
|
-
/**
|
|
55
|
-
* React component which handles schematizing trees.
|
|
56
|
-
* This includes displaying errors when the document can not be viewed using the view schema.
|
|
57
|
-
*
|
|
58
|
-
* @privateRemarks
|
|
59
|
-
* This is exposed as a member rather than a free function since type inference for the schema doesn't work when used as a free function,
|
|
60
|
-
* and thus making it a member avoids the user of this from having to explicitly provide the type parameter.
|
|
61
|
-
* This is an arrow function not a method so it gets the correct this when not called as a member.
|
|
62
|
-
*/
|
|
63
|
-
readonly TreeViewComponent: (props: TreeViewProps<TSchema>) => React.JSX.Element;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* React props for viewing a tree.
|
|
67
|
-
* @input @alpha
|
|
68
|
-
*/
|
|
69
|
-
export interface TreeViewProps<TSchema extends ImplicitFieldSchema> {
|
|
70
|
-
/**
|
|
71
|
-
* Component to display the tree content.
|
|
72
|
-
*/
|
|
73
|
-
readonly viewComponent: React.FC<{
|
|
74
|
-
root: PropTreeValue<TreeFieldFromImplicitField<TSchema>>;
|
|
75
|
-
}>;
|
|
76
|
-
/**
|
|
77
|
-
* Component to display instead of the {@link TreeViewProps.viewComponent}
|
|
78
|
-
* when tree content is not compatible with the {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
79
|
-
*
|
|
80
|
-
* @defaultValue Component which describes the situation (in English) and allows the user to upgrade the schema to match the {@link @fluidframework/tree#TreeViewConfiguration} if possible.
|
|
81
|
-
*/
|
|
82
|
-
readonly errorComponent?: React.FC<SchemaIncompatibleProps>;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Generic DataObject for shared trees.
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
88
|
-
export declare abstract class ReactTreeDataObject<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> extends TreeDataObject implements IReactTreeDataObject<TSchema> {
|
|
89
|
-
#private;
|
|
90
|
-
abstract readonly config: TreeViewConfiguration<TSchema>;
|
|
91
|
-
/**
|
|
92
|
-
* The schema-aware view of the tree.
|
|
93
|
-
*/
|
|
94
|
-
get treeView(): TreeView<TSchema>;
|
|
95
|
-
readonly TreeViewComponent: ({ viewComponent, errorComponent, }: TreeViewProps<TSchema>) => React.JSX.Element;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* React component which handles schematizing trees.
|
|
99
|
-
* This includes displaying errors when the document can not be schematized.
|
|
100
|
-
* @alpha
|
|
101
|
-
*/
|
|
102
|
-
export declare function TreeViewComponent<TSchema extends ImplicitFieldSchema>({ tree, viewComponent: ViewComponent, errorComponent, }: TreeViewProps<TSchema> & {
|
|
103
|
-
tree: Pick<IReactTreeDataObject<TSchema>, "treeView">;
|
|
104
|
-
}): React.JSX.Element;
|
|
105
|
-
/**
|
|
106
|
-
* React Props for displaying when the opened document is incompatible with the required view schema.
|
|
107
|
-
* @alpha
|
|
108
|
-
*/
|
|
109
|
-
export interface SchemaIncompatibleProps {
|
|
110
|
-
/**
|
|
111
|
-
* Information about the view schema's compatibility with the stored schema.
|
|
112
|
-
*/
|
|
113
|
-
readonly compatibility: SchemaCompatibilityStatus;
|
|
114
|
-
/**
|
|
115
|
-
* Callback to request that the stored schema in the document be upgraded.
|
|
116
|
-
*/
|
|
117
|
-
readonly upgradeSchema: () => void;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=reactSharedTreeView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactSharedTreeView.d.ts","sourceRoot":"","sources":["../src/reactSharedTreeView.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
-
if (mod && mod.__esModule) return mod;
|
|
24
|
-
var result = {};
|
|
25
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
-
__setModuleDefault(result, mod);
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
30
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
31
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
32
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
33
|
-
};
|
|
34
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
35
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
36
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
37
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
38
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
39
|
-
};
|
|
40
|
-
var _ReactTreeDataObject_treeView;
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.TreeViewComponent = exports.ReactTreeDataObject = exports.treeDataObjectInternal = exports.treeDataObject = void 0;
|
|
43
|
-
const internal_1 = require("@fluidframework/aqueduct/internal");
|
|
44
|
-
const internal_2 = require("@fluidframework/tree/internal");
|
|
45
|
-
const React = __importStar(require("react"));
|
|
46
|
-
const propNode_js_1 = require("./propNode.js");
|
|
47
|
-
/**
|
|
48
|
-
* Opt into extra validation to detect encoding bugs and data corruption.
|
|
49
|
-
* As long as this is an experimental package, opting into extra validation (at a small perf and bundle size cost) seems reasonable.
|
|
50
|
-
*/
|
|
51
|
-
const SharedTree = (0, internal_2.configuredSharedTree)({
|
|
52
|
-
jsonValidator: internal_2.FormatValidatorBasic,
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
56
|
-
* @param treeConfiguration - See {@link IReactTreeDataObject.config}.
|
|
57
|
-
* @param createInitialTree - Function which populates the tree with initial data on document create.
|
|
58
|
-
* @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.
|
|
59
|
-
* @alpha
|
|
60
|
-
*/
|
|
61
|
-
function treeDataObject(treeConfiguration, createInitialTree) {
|
|
62
|
-
return treeDataObjectInternal(treeConfiguration, createInitialTree);
|
|
63
|
-
}
|
|
64
|
-
exports.treeDataObject = treeDataObject;
|
|
65
|
-
/**
|
|
66
|
-
* Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
67
|
-
* @param treeConfiguration - See {@link IReactTreeDataObject.config}.
|
|
68
|
-
* @param createInitialTree - Function which populates the tree with initial data on document create.
|
|
69
|
-
* @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.
|
|
70
|
-
* @internal
|
|
71
|
-
*/
|
|
72
|
-
function treeDataObjectInternal(treeConfiguration, createInitialTree) {
|
|
73
|
-
var _SchemaAwareTreeDataObject_treeView;
|
|
74
|
-
class SchemaAwareTreeDataObject extends ReactTreeDataObject {
|
|
75
|
-
constructor() {
|
|
76
|
-
super(...arguments);
|
|
77
|
-
this.config = treeConfiguration;
|
|
78
|
-
_SchemaAwareTreeDataObject_treeView.set(this, void 0);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* The schema-aware view of the tree.
|
|
82
|
-
*/
|
|
83
|
-
get treeView() {
|
|
84
|
-
if (__classPrivateFieldGet(this, _SchemaAwareTreeDataObject_treeView, "f") === undefined) {
|
|
85
|
-
throw new Error("treeView has not been initialized.");
|
|
86
|
-
}
|
|
87
|
-
return __classPrivateFieldGet(this, _SchemaAwareTreeDataObject_treeView, "f");
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Converts the underlying ITree into a typed TreeView using the provided schema configuration.
|
|
91
|
-
*
|
|
92
|
-
* @param tree - The ITree instance to view.
|
|
93
|
-
* @returns A typed TreeView using the TodoList schema.
|
|
94
|
-
*/
|
|
95
|
-
initializeView() {
|
|
96
|
-
__classPrivateFieldSet(this, _SchemaAwareTreeDataObject_treeView, this.tree.viewWith(this.config), "f");
|
|
97
|
-
}
|
|
98
|
-
async initializingFirstTime() {
|
|
99
|
-
this.initializeView();
|
|
100
|
-
this.treeView.initialize(createInitialTree());
|
|
101
|
-
}
|
|
102
|
-
async initializingFromExisting() {
|
|
103
|
-
this.initializeView();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
_SchemaAwareTreeDataObject_treeView = new WeakMap();
|
|
107
|
-
SchemaAwareTreeDataObject.factory = new internal_1.PureDataObjectFactory(`TreeDataObject`, SchemaAwareTreeDataObject, [SharedTree.getFactory()], {});
|
|
108
|
-
return (0, internal_1.createDataObjectKind)(SchemaAwareTreeDataObject);
|
|
109
|
-
}
|
|
110
|
-
exports.treeDataObjectInternal = treeDataObjectInternal;
|
|
111
|
-
/**
|
|
112
|
-
* Generic DataObject for shared trees.
|
|
113
|
-
* @internal
|
|
114
|
-
*/
|
|
115
|
-
class ReactTreeDataObject extends internal_1.TreeDataObject {
|
|
116
|
-
constructor() {
|
|
117
|
-
super(...arguments);
|
|
118
|
-
_ReactTreeDataObject_treeView.set(this, void 0);
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
|
|
120
|
-
this.TreeViewComponent = ({ viewComponent, errorComponent, }) => TreeViewComponent({
|
|
121
|
-
tree: this,
|
|
122
|
-
viewComponent,
|
|
123
|
-
errorComponent,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* The schema-aware view of the tree.
|
|
128
|
-
*/
|
|
129
|
-
get treeView() {
|
|
130
|
-
if (__classPrivateFieldGet(this, _ReactTreeDataObject_treeView, "f") === undefined) {
|
|
131
|
-
throw new Error("treeView has not been initialized.");
|
|
132
|
-
}
|
|
133
|
-
return __classPrivateFieldGet(this, _ReactTreeDataObject_treeView, "f");
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.ReactTreeDataObject = ReactTreeDataObject;
|
|
137
|
-
_ReactTreeDataObject_treeView = new WeakMap();
|
|
138
|
-
function useViewCompatibility(view) {
|
|
139
|
-
const [compatibility, setCompatibility] = React.useState(view.compatibility);
|
|
140
|
-
React.useEffect(() => {
|
|
141
|
-
const updateCompatibility = () => {
|
|
142
|
-
setCompatibility(view.compatibility);
|
|
143
|
-
};
|
|
144
|
-
updateCompatibility();
|
|
145
|
-
return view.events.on("schemaChanged", updateCompatibility);
|
|
146
|
-
}, [view]);
|
|
147
|
-
return compatibility;
|
|
148
|
-
}
|
|
149
|
-
function useViewRoot(view) {
|
|
150
|
-
const [root, setRoot] = React.useState(undefined);
|
|
151
|
-
React.useEffect(() => {
|
|
152
|
-
const updateRoot = () => {
|
|
153
|
-
if (view.compatibility.canView) {
|
|
154
|
-
setRoot(view.root);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
setRoot(undefined);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
updateRoot();
|
|
161
|
-
return view.events.on("rootChanged", updateRoot);
|
|
162
|
-
}, [view]);
|
|
163
|
-
return root;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* React component which handles schematizing trees.
|
|
167
|
-
* This includes displaying errors when the document can not be schematized.
|
|
168
|
-
* @alpha
|
|
169
|
-
*/
|
|
170
|
-
function TreeViewComponent({ tree, viewComponent: ViewComponent, errorComponent, }) {
|
|
171
|
-
const view = tree.treeView;
|
|
172
|
-
const compatibility = useViewCompatibility(view);
|
|
173
|
-
const root = useViewRoot(view);
|
|
174
|
-
const upgradeSchema = React.useCallback(() => view.upgradeSchema(), [view]);
|
|
175
|
-
// Note: this policy is on the stricter side and ensures that clients will only be able to submit edits when their view schema
|
|
176
|
-
// supports exactly the same documents as the stored schema.
|
|
177
|
-
// A realistic production application using this strategy would need to take steps to attempt to open the document using
|
|
178
|
-
// several different view schemas in order to ensure that their users don't temporarily lose access to documents while
|
|
179
|
-
// code rollout is in progress.
|
|
180
|
-
// Alternative policies can be implemented, see "Schema Evolvability" in SharedTree's README for more information.
|
|
181
|
-
if (!compatibility.isEquivalent) {
|
|
182
|
-
const Error = errorComponent ?? TreeErrorComponent;
|
|
183
|
-
return React.createElement(Error, { compatibility: compatibility, upgradeSchema: upgradeSchema });
|
|
184
|
-
}
|
|
185
|
-
if (root === undefined) {
|
|
186
|
-
return React.createElement("div", null, "View not set");
|
|
187
|
-
}
|
|
188
|
-
return React.createElement(ViewComponent, { root: (0, propNode_js_1.toPropTreeNode)(root) });
|
|
189
|
-
}
|
|
190
|
-
exports.TreeViewComponent = TreeViewComponent;
|
|
191
|
-
/**
|
|
192
|
-
* React component which displays schema errors and allows upgrading schema when possible.
|
|
193
|
-
*/
|
|
194
|
-
function TreeErrorComponent({ compatibility, upgradeSchema, }) {
|
|
195
|
-
// eslint-disable-next-line unicorn/prefer-ternary
|
|
196
|
-
if (compatibility.canUpgrade) {
|
|
197
|
-
return (React.createElement("div", null,
|
|
198
|
-
React.createElement("div", null, "Document is incompatible with current version of the application, but the document format can be updated. This may prevent other versions of the application from opening this document."),
|
|
199
|
-
React.createElement("button", { onClick: upgradeSchema }, "Upgrade"),
|
|
200
|
-
";"));
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
return (React.createElement("div", null, "Document is incompatible with current version of the application, and the document format cannot be updated. The document is likely from a newer or otherwise incompatible version of the application, or a different application."));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
//# sourceMappingURL=reactSharedTreeView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactSharedTreeView.js","sourceRoot":"","sources":["../src/reactSharedTreeView.tsx"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tPureDataObjectFactory,\n\tTreeDataObject,\n\tcreateDataObjectKind,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport type {\n\tSchemaCompatibilityStatus,\n\tTreeViewConfiguration,\n\tTreeFieldFromImplicitField,\n\tTreeView,\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n} from \"@fluidframework/tree\";\nimport { configuredSharedTree, FormatValidatorBasic } from \"@fluidframework/tree/internal\";\nimport * as React from \"react\";\n\nimport { toPropTreeNode, type PropTreeValue } from \"./propNode.js\";\n\n/**\n * Opt into extra validation to detect encoding bugs and data corruption.\n * As long as this is an experimental package, opting into extra validation (at a small perf and bundle size cost) seems reasonable.\n */\nconst SharedTree = configuredSharedTree({\n\tjsonValidator: FormatValidatorBasic,\n});\n\n/**\n * Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.\n * @param treeConfiguration - See {@link IReactTreeDataObject.config}.\n * @param createInitialTree - Function which populates the tree with initial data on document create.\n * @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.\n * @alpha\n */\nexport function treeDataObject<TSchema extends ImplicitFieldSchema>(\n\ttreeConfiguration: TreeViewConfiguration<TSchema>,\n\tcreateInitialTree: () => InsertableTreeFieldFromImplicitField<TSchema>,\n): SharedObjectKind<IReactTreeDataObject<TSchema> & IFluidLoadable> {\n\treturn treeDataObjectInternal(treeConfiguration, createInitialTree);\n}\n\n/**\n * Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.\n * @param treeConfiguration - See {@link IReactTreeDataObject.config}.\n * @param createInitialTree - Function which populates the tree with initial data on document create.\n * @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.\n * @internal\n */\nexport function treeDataObjectInternal<TSchema extends ImplicitFieldSchema>(\n\ttreeConfiguration: TreeViewConfiguration<TSchema>,\n\tcreateInitialTree: () => InsertableTreeFieldFromImplicitField<TSchema>,\n): SharedObjectKind<IReactTreeDataObject<TSchema> & IFluidLoadable & TreeDataObject> & {\n\treadonly factory: IFluidDataStoreFactory;\n} {\n\tclass SchemaAwareTreeDataObject extends ReactTreeDataObject<TSchema> {\n\t\tpublic override readonly config = treeConfiguration;\n\n\t\tpublic static readonly factory = new PureDataObjectFactory<ReactTreeDataObject<TSchema>>(\n\t\t\t`TreeDataObject`,\n\t\t\tSchemaAwareTreeDataObject,\n\t\t\t[SharedTree.getFactory()],\n\t\t\t{},\n\t\t);\n\n\t\t#treeView: TreeView<TSchema> | undefined;\n\n\t\t/**\n\t\t * The schema-aware view of the tree.\n\t\t */\n\t\tpublic get treeView(): TreeView<TSchema> {\n\t\t\tif (this.#treeView === undefined) {\n\t\t\t\tthrow new Error(\"treeView has not been initialized.\");\n\t\t\t}\n\t\t\treturn this.#treeView;\n\t\t}\n\n\t\t/**\n\t\t * Converts the underlying ITree into a typed TreeView using the provided schema configuration.\n\t\t *\n\t\t * @param tree - The ITree instance to view.\n\t\t * @returns A typed TreeView using the TodoList schema.\n\t\t */\n\t\tprivate initializeView(): void {\n\t\t\tthis.#treeView = this.tree.viewWith(this.config);\n\t\t}\n\n\t\tprotected override async initializingFirstTime(): Promise<void> {\n\t\t\tthis.initializeView();\n\t\t\tthis.treeView.initialize(createInitialTree());\n\t\t}\n\n\t\tprotected override async initializingFromExisting(): Promise<void> {\n\t\t\tthis.initializeView();\n\t\t}\n\t}\n\treturn createDataObjectKind(SchemaAwareTreeDataObject);\n}\n\n/**\n * A schema-aware tree-backed DataObject, extended with a React Component to view the tree.\n * @remarks Allows for the Tree's schema to be baked into the container schema.\n * @sealed @alpha\n */\nexport interface IReactTreeDataObject<TSchema extends ImplicitFieldSchema> {\n\t/**\n\t * The configuration used to initialize new documents, as well as to interpret (schematize) existing ones.\n\t *\n\t * @remarks\n\t * The fact that a single view schema is provided here (on the data object) makes it impossible to try and apply multiple different schema.\n\t * Since the view schema currently does not provide any adapters for handling differences between view and stored schema,\n\t * it's also impossible for this single view schema to handle multiple different stored schema.\n\t * Therefore, with this current API, two different applications (or different versions of the same application)\n\t * with differing stored schema requirements (as implied by their view schema) can not collaborate on the same tree.\n\t * The only schema evolution that's currently possible is upgrading the schema to one that supports a superset of what the old schema allowed,\n\t * and collaborating between clients which have view schema that exactly correspond to that stored schema.\n\t * Future work on tree as well as these utilities should address this limitation.\n\t */\n\treadonly config: TreeViewConfiguration<TSchema>;\n\n\t/**\n\t * The schema-aware view of the tree.\n\t */\n\treadonly treeView: TreeView<TSchema>;\n\n\t/**\n\t * React component which handles schematizing trees.\n\t * This includes displaying errors when the document can not be viewed using the view schema.\n\t *\n\t * @privateRemarks\n\t * This is exposed as a member rather than a free function since type inference for the schema doesn't work when used as a free function,\n\t * and thus making it a member avoids the user of this from having to explicitly provide the type parameter.\n\t * This is an arrow function not a method so it gets the correct this when not called as a member.\n\t */\n\treadonly TreeViewComponent: (props: TreeViewProps<TSchema>) => React.JSX.Element;\n}\n\n/**\n * React props for viewing a tree.\n * @input @alpha\n */\nexport interface TreeViewProps<TSchema extends ImplicitFieldSchema> {\n\t/**\n\t * Component to display the tree content.\n\t */\n\treadonly viewComponent: React.FC<{\n\t\troot: PropTreeValue<TreeFieldFromImplicitField<TSchema>>;\n\t}>;\n\n\t/**\n\t * Component to display instead of the {@link TreeViewProps.viewComponent}\n\t * when tree content is not compatible with the {@link @fluidframework/tree#TreeViewConfiguration}.\n\t *\n\t * @defaultValue Component which describes the situation (in English) and allows the user to upgrade the schema to match the {@link @fluidframework/tree#TreeViewConfiguration} if possible.\n\t */\n\treadonly errorComponent?: React.FC<SchemaIncompatibleProps>;\n\n\t// TODO: Once its possible to query the status of individual schema upgrades, provide more options here for handling such cases.\n}\n\n/**\n * Generic DataObject for shared trees.\n * @internal\n */\nexport abstract class ReactTreeDataObject<\n\t\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n\t>\n\textends TreeDataObject\n\timplements IReactTreeDataObject<TSchema>\n{\n\tpublic abstract readonly config: TreeViewConfiguration<TSchema>;\n\n\treadonly #treeView: TreeView<TSchema> | undefined;\n\n\t/**\n\t * The schema-aware view of the tree.\n\t */\n\tpublic get treeView(): TreeView<TSchema> {\n\t\tif (this.#treeView === undefined) {\n\t\t\tthrow new Error(\"treeView has not been initialized.\");\n\t\t}\n\t\treturn this.#treeView;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type\n\tpublic readonly TreeViewComponent = ({\n\t\tviewComponent,\n\t\terrorComponent,\n\t}: TreeViewProps<TSchema>) =>\n\t\tTreeViewComponent<TSchema>({\n\t\t\ttree: this,\n\t\t\tviewComponent,\n\t\t\terrorComponent,\n\t\t});\n}\n\nfunction useViewCompatibility<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): SchemaCompatibilityStatus {\n\tconst [compatibility, setCompatibility] = React.useState<SchemaCompatibilityStatus>(\n\t\tview.compatibility,\n\t);\n\n\tReact.useEffect(() => {\n\t\tconst updateCompatibility = (): void => {\n\t\t\tsetCompatibility(view.compatibility);\n\t\t};\n\n\t\tupdateCompatibility();\n\t\treturn view.events.on(\"schemaChanged\", updateCompatibility);\n\t}, [view]);\n\n\treturn compatibility;\n}\n\nfunction useViewRoot<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): TreeFieldFromImplicitField<TSchema> | undefined {\n\tconst [root, setRoot] = React.useState<TreeFieldFromImplicitField<TSchema> | undefined>(\n\t\tundefined,\n\t);\n\n\tReact.useEffect(() => {\n\t\tconst updateRoot = (): void => {\n\t\t\tif (view.compatibility.canView) {\n\t\t\t\tsetRoot(view.root);\n\t\t\t} else {\n\t\t\t\tsetRoot(undefined);\n\t\t\t}\n\t\t};\n\n\t\tupdateRoot();\n\t\treturn view.events.on(\"rootChanged\", updateRoot);\n\t}, [view]);\n\n\treturn root;\n}\n\n/**\n * React component which handles schematizing trees.\n * This includes displaying errors when the document can not be schematized.\n * @alpha\n */\nexport function TreeViewComponent<TSchema extends ImplicitFieldSchema>({\n\ttree,\n\tviewComponent: ViewComponent,\n\terrorComponent,\n}: TreeViewProps<TSchema> & {\n\ttree: Pick<IReactTreeDataObject<TSchema>, \"treeView\">;\n}): React.JSX.Element {\n\tconst view = tree.treeView;\n\n\tconst compatibility = useViewCompatibility(view);\n\tconst root = useViewRoot(view);\n\tconst upgradeSchema = React.useCallback((): void => view.upgradeSchema(), [view]);\n\n\t// Note: this policy is on the stricter side and ensures that clients will only be able to submit edits when their view schema\n\t// supports exactly the same documents as the stored schema.\n\t// A realistic production application using this strategy would need to take steps to attempt to open the document using\n\t// several different view schemas in order to ensure that their users don't temporarily lose access to documents while\n\t// code rollout is in progress.\n\t// Alternative policies can be implemented, see \"Schema Evolvability\" in SharedTree's README for more information.\n\tif (!compatibility.isEquivalent) {\n\t\tconst Error = errorComponent ?? TreeErrorComponent;\n\t\treturn <Error compatibility={compatibility} upgradeSchema={upgradeSchema} />;\n\t}\n\n\tif (root === undefined) {\n\t\treturn <div>View not set</div>;\n\t}\n\n\treturn <ViewComponent root={toPropTreeNode(root)} />;\n}\n\n/**\n * React Props for displaying when the opened document is incompatible with the required view schema.\n * @alpha\n */\nexport interface SchemaIncompatibleProps {\n\t/**\n\t * Information about the view schema's compatibility with the stored schema.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\t/**\n\t * Callback to request that the stored schema in the document be upgraded.\n\t */\n\treadonly upgradeSchema: () => void;\n}\n\n/**\n * React component which displays schema errors and allows upgrading schema when possible.\n */\nfunction TreeErrorComponent({\n\tcompatibility,\n\tupgradeSchema,\n}: {\n\tcompatibility: SchemaCompatibilityStatus;\n\tupgradeSchema: () => void;\n}): React.JSX.Element {\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (compatibility.canUpgrade) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t<div>\n\t\t\t\t\tDocument is incompatible with current version of the application, but the document\n\t\t\t\t\tformat can be updated. This may prevent other versions of the application from\n\t\t\t\t\topening this document.\n\t\t\t\t</div>\n\t\t\t\t<button onClick={upgradeSchema}>Upgrade</button>;\n\t\t\t</div>\n\t\t);\n\t} else {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\tDocument is incompatible with current version of the application, and the document\n\t\t\t\tformat cannot be updated. The document is likely from a newer or otherwise incompatible\n\t\t\t\tversion of the application, or a different application.\n\t\t\t</div>\n\t\t);\n\t}\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Associates a unique number with an object.
|
|
7
|
-
* @remarks
|
|
8
|
-
* The ID number is tied to the object identity, not the object's contents; modifying the object will not cause it to get a different ID.
|
|
9
|
-
*
|
|
10
|
-
* This can be handy for generating {@link https://react.dev/learn/rendering-lists#where-to-get-your-key | keys for React lists} from TreeNodes.
|
|
11
|
-
*
|
|
12
|
-
* Most cases which could use this function should just use the objects themselves instead of getting IDs from them, since the objects will have the same equality as the IDs.
|
|
13
|
-
* For example, if storing data associated with the objects in a map, using the object as the key is more efficient than getting an ID from it and using that.
|
|
14
|
-
* This functions exists to deal with the edge case where you would like to use object identity, but you can't.
|
|
15
|
-
* React keys are an examples of such a case, since React does not allow objects as keys.
|
|
16
|
-
* @alpha
|
|
17
|
-
*/
|
|
18
|
-
export declare function objectIdNumber(object: object): number;
|
|
19
|
-
//# sourceMappingURL=simpleIdentifier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simpleIdentifier.d.ts","sourceRoot":"","sources":["../src/simpleIdentifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQrD"}
|
package/dist/simpleIdentifier.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.objectIdNumber = void 0;
|
|
8
|
-
let counter = 0;
|
|
9
|
-
const idMap = new WeakMap();
|
|
10
|
-
/**
|
|
11
|
-
* Associates a unique number with an object.
|
|
12
|
-
* @remarks
|
|
13
|
-
* The ID number is tied to the object identity, not the object's contents; modifying the object will not cause it to get a different ID.
|
|
14
|
-
*
|
|
15
|
-
* This can be handy for generating {@link https://react.dev/learn/rendering-lists#where-to-get-your-key | keys for React lists} from TreeNodes.
|
|
16
|
-
*
|
|
17
|
-
* Most cases which could use this function should just use the objects themselves instead of getting IDs from them, since the objects will have the same equality as the IDs.
|
|
18
|
-
* For example, if storing data associated with the objects in a map, using the object as the key is more efficient than getting an ID from it and using that.
|
|
19
|
-
* This functions exists to deal with the edge case where you would like to use object identity, but you can't.
|
|
20
|
-
* React keys are an examples of such a case, since React does not allow objects as keys.
|
|
21
|
-
* @alpha
|
|
22
|
-
*/
|
|
23
|
-
function objectIdNumber(object) {
|
|
24
|
-
const id = idMap.get(object);
|
|
25
|
-
if (id !== undefined) {
|
|
26
|
-
return id;
|
|
27
|
-
}
|
|
28
|
-
counter++;
|
|
29
|
-
idMap.set(object, counter);
|
|
30
|
-
return counter;
|
|
31
|
-
}
|
|
32
|
-
exports.objectIdNumber = objectIdNumber;
|
|
33
|
-
//# sourceMappingURL=simpleIdentifier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simpleIdentifier.js","sourceRoot":"","sources":["../src/simpleIdentifier.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,IAAI,OAAO,GAAG,CAAC,CAAC;AAEhB,MAAM,KAAK,GAAG,IAAI,OAAO,EAAkB,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,SAAgB,cAAc,CAAC,MAAc;IAC5C,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,EAAE,CAAC;IACV,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3B,OAAO,OAAO,CAAC;AAChB,CAAC;AARD,wCAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nlet counter = 0;\n\nconst idMap = new WeakMap<object, number>();\n\n/**\n * Associates a unique number with an object.\n * @remarks\n * The ID number is tied to the object identity, not the object's contents; modifying the object will not cause it to get a different ID.\n *\n * This can be handy for generating {@link https://react.dev/learn/rendering-lists#where-to-get-your-key | keys for React lists} from TreeNodes.\n *\n * Most cases which could use this function should just use the objects themselves instead of getting IDs from them, since the objects will have the same equality as the IDs.\n * For example, if storing data associated with the objects in a map, using the object as the key is more efficient than getting an ID from it and using that.\n * This functions exists to deal with the edge case where you would like to use object identity, but you can't.\n * React keys are an examples of such a case, since React does not allow objects as keys.\n * @alpha\n */\nexport function objectIdNumber(object: object): number {\n\tconst id = idMap.get(object);\n\tif (id !== undefined) {\n\t\treturn id;\n\t}\n\tcounter++;\n\tidMap.set(object, counter);\n\treturn counter;\n}\n"]}
|
package/dist/useObservation.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Options for {@link useTreeObservations}.
|
|
7
|
-
* @input
|
|
8
|
-
* @alpha
|
|
9
|
-
*/
|
|
10
|
-
export interface ObservationOptions {
|
|
11
|
-
/**
|
|
12
|
-
* Called when the tracked observations are invalidated.
|
|
13
|
-
* @remarks
|
|
14
|
-
* This is not expected to have production use cases, but is useful for testing and debugging.
|
|
15
|
-
*/
|
|
16
|
-
onInvalidation?: () => void;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Custom hook which invalidates a React Component based on changes to what was observed during `trackDuring`.
|
|
20
|
-
*
|
|
21
|
-
* @param trackDuring - Called synchronously: can make event subscriptions which call the provided `invalidate` function.
|
|
22
|
-
* Any such subscriptions should be cleaned up via the returned `unsubscribe` function which will only be invoked if `invalidate` is not called.
|
|
23
|
-
* If `invalidate` is called, the code calling it should remove any subscriptions before calling it.
|
|
24
|
-
* @remarks
|
|
25
|
-
* React strongly discourages "render" from having side-effects other than idempotent lazy initialization.
|
|
26
|
-
*
|
|
27
|
-
* Tracking observations made during render to subscribe to events for automatic invalidation is a side-effect.
|
|
28
|
-
* This makes the behavior of this hook somewhat unusual from a React perspective, and also rather poorly supported by React.
|
|
29
|
-
*
|
|
30
|
-
* That said, the alternatives more aligned with how React expects things to work have much less friendly APIs, or have gaps where they risk invalidation bugs.
|
|
31
|
-
*
|
|
32
|
-
* For example, this hook could record which observations were made during render, then pass them into a `useEffect` hook to do the subscription.
|
|
33
|
-
* This would be more aligned with React's expectations, but would have a number of issues:
|
|
34
|
-
* - The effect would run after render, so if the observed content changed between render and the effect running, there could be an invalidation bug.
|
|
35
|
-
* - It would require changes to `TreeAlpha.trackObservationsOnce` to support a two phase approach (first track, then subscribe) which would have the same risk of missed invalidation.
|
|
36
|
-
* - It would have slightly higher cost due to the extra effect.
|
|
37
|
-
* Such an approach is implemented in {@link useObservationPure}.
|
|
38
|
-
*/
|
|
39
|
-
export declare function useObservation<TResult>(trackDuring: (invalidate: () => void) => {
|
|
40
|
-
result: TResult;
|
|
41
|
-
unsubscribe: () => void;
|
|
42
|
-
}, options?: ObservationOptions): TResult;
|
|
43
|
-
/**
|
|
44
|
-
* Options for {@link useTreeObservations}.
|
|
45
|
-
* @input
|
|
46
|
-
*/
|
|
47
|
-
export interface ObservationPureOptions {
|
|
48
|
-
onSubscribe?: () => void;
|
|
49
|
-
onUnsubscribe?: () => void;
|
|
50
|
-
onPureInvalidation?: () => void;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* {@link useObservation} but more aligned with React expectations.
|
|
54
|
-
* @remarks
|
|
55
|
-
* This is more expensive than {@link useObservation}, and also leaks subscriptions longer.
|
|
56
|
-
* When rendering a component, relies on a finalizer to clean up subscriptions from the previous render.
|
|
57
|
-
*
|
|
58
|
-
* Unlike {@link useObservation}, this behave correctly even if React does something unexpected, like Rendering a component twice, and throwing away the second render instead of the first.
|
|
59
|
-
* {@link useObservation} relies on React not doing such things, assuming that when re-rendering a component, it will be the older render which is discarded.
|
|
60
|
-
*
|
|
61
|
-
* This should also avoid calling `setState` after unmount, which can avoid a React warning.
|
|
62
|
-
*
|
|
63
|
-
* This does not however avoid the finalizer based cleanup: it actually relies on it much more (for rerender and unmount, not just unmount).
|
|
64
|
-
* This simply adds a layer of indirection to the invalidation through useEffect.
|
|
65
|
-
*/
|
|
66
|
-
export declare function useObservationWithEffects<TResult>(trackDuring: (invalidate: () => void) => {
|
|
67
|
-
result: TResult;
|
|
68
|
-
unsubscribe: () => void;
|
|
69
|
-
}, options?: ObservationOptions & ObservationPureOptions): TResult;
|
|
70
|
-
/**
|
|
71
|
-
* {@link useObservation} but more strict with its behavior.
|
|
72
|
-
* @remarks
|
|
73
|
-
* This has the eager cleanup on re-render of {@link useObservation}, but has the effect based subscriptions and cleanup on unmount of {@link useObservationWithEffects}.
|
|
74
|
-
*
|
|
75
|
-
* If React behaves in a way which breaks the assumptions of {@link useObservation} (and thus would require the leakier {@link useObservationWithEffects}), this will throw an error.
|
|
76
|
-
* @privateRemarks
|
|
77
|
-
* This is just a {@link useObservationPure}, except with the eager cleanup on re-render from {@link useObservation}.
|
|
78
|
-
*/
|
|
79
|
-
export declare function useObservationStrict<TResult>(trackDuring: (invalidate: () => void) => {
|
|
80
|
-
result: TResult;
|
|
81
|
-
unsubscribe: () => void;
|
|
82
|
-
}, options?: ObservationOptions & ObservationPureOptions): TResult;
|
|
83
|
-
//# sourceMappingURL=useObservation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useObservation.d.ts","sourceRoot":"","sources":["../src/useObservation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2BH;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,OAAO,EACrC,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,IAAI,KAAK;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,IAAI,CAAA;CAAE,EACrF,OAAO,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAkET;AAoBD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CAChC;AAuID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAChD,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,IAAI,KAAK;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,IAAI,CAAA;CAAE,EACrF,OAAO,CAAC,EAAE,kBAAkB,GAAG,sBAAsB,GACnD,OAAO,CAGT;AAiCD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAC3C,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,IAAI,KAAK;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,IAAI,CAAA;CAAE,EACrF,OAAO,CAAC,EAAE,kBAAkB,GAAG,sBAAsB,GACnD,OAAO,CAaT"}
|