Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…to isMore
  • Loading branch information
CraigMacomber committed May 10, 2024
2 parents 413b8ac + 5a15835 commit ffabda2
Show file tree
Hide file tree
Showing 60 changed files with 250 additions and 571 deletions.
5 changes: 3 additions & 2 deletions packages/common/container-definitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
"lint": "fluid-build . --task lint",
"lint:fix": "fluid-build . --task eslint:fix --task format",
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
"tsc:watch": "copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist && fluid-tsc commonjs --watch",
"place:cjs:package-stub": "copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && npm run place:cjs:package-stub",
"tsc:watch": "npm run place:cjs:package-stub && fluid-tsc commonjs --project ./tsconfig.cjs.json --watch",
"typetests:gen": "flub generate typetests --dir . -v --publicFallback",
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/common/core-interfaces/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
"lint": "fluid-build . --task lint",
"lint:fix": "fluid-build . --task eslint:fix --task format",
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
"tsc:watch": "tsc --watch",
"place:cjs:package-stub": "copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && npm run place:cjs:package-stub",
"tsc:watch": "npm run place:cjs:package-stub && fluid-tsc commonjs --project ./tsconfig.cjs.json --watch",
"typetests:gen": "flub generate typetests --dir . -v --publicFallback",
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/common/driver-definitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
"lint": "fluid-build . --task lint",
"lint:fix": "fluid-build . --task eslint:fix --task format",
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
"tsc:watch": "tsc --watch",
"place:cjs:package-stub": "copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && npm run place:cjs:package-stub",
"tsc:watch": "npm run place:cjs:package-stub && fluid-tsc commonjs --project ./tsconfig.cjs.json --watch",
"typetests:gen": "flub generate typetests --dir . -v --publicFallback",
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/dds/map/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

module.exports = {
extends: [require.resolve("@fluidframework/eslint-config-fluid"), "prettier"],
extends: [require.resolve("@fluidframework/eslint-config-fluid/strict"), "prettier"],
parserOptions: {
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
},
Expand Down
12 changes: 6 additions & 6 deletions packages/dds/map/api-report/map.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import type { IChannelAttributes } from '@fluidframework/datastore-definitions';
import type { IChannelFactory } from '@fluidframework/datastore-definitions';
import type { IChannelServices } from '@fluidframework/datastore-definitions';
import { IDisposable } from '@fluidframework/core-interfaces';
import { IEvent } from '@fluidframework/core-interfaces';
import { IEventProvider } from '@fluidframework/core-interfaces';
import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
import type { IDisposable } from '@fluidframework/core-interfaces';
import type { IEvent } from '@fluidframework/core-interfaces';
import type { IEventProvider } from '@fluidframework/core-interfaces';
import type { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
import type { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
import { ISharedObject } from '@fluidframework/shared-object-base';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
import type { ISharedObject } from '@fluidframework/shared-object-base';
import type { ISharedObjectEvents } from '@fluidframework/shared-object-base';
import type { ISharedObjectKind } from '@fluidframework/shared-object-base';

// @alpha @sealed
Expand Down
52 changes: 29 additions & 23 deletions packages/dds/map/src/directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,36 @@

import { TypedEventEmitter } from "@fluid-internal/client-utils";
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
import {
import type {
IChannelAttributes,
IChannelStorageService,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions";
import { readAndParse } from "@fluidframework/driver-utils/internal";
import { RedBlackTree } from "@fluidframework/merge-tree/internal";
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
import { MessageType, type ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
import type { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import type { IFluidSerializer } from "@fluidframework/shared-object-base";
import { SharedObject, ValueType, parseHandles } from "@fluidframework/shared-object-base/internal";
import { ITelemetryLoggerExt, UsageError } from "@fluidframework/telemetry-utils/internal";
import { type ITelemetryLoggerExt, UsageError } from "@fluidframework/telemetry-utils/internal";
import path from "path-browserify";

import {
import type {
IDirectory,
IDirectoryEvents,
IDirectoryValueChanged,
ISharedDirectory,
ISharedDirectoryEvents,
IValueChanged,
} from "./interfaces.js";
import {
import type {
// eslint-disable-next-line import/no-deprecated
ISerializableValue,
ISerializedValue,
} from "./internalInterfaces.js";
import { ILocalValue, LocalValueMaker, makeSerializable } from "./localValues.js";
import type { ILocalValue } from "./localValues.js";
import { LocalValueMaker, makeSerializable } from "./localValues.js";

// We use path-browserify since this code can run safely on the server or the browser.
// We standardize on using posix slashes everywhere.
Expand Down Expand Up @@ -230,12 +231,12 @@ export interface IDirectoryDataObject {
* Key/value date set by the user.
*/
// eslint-disable-next-line import/no-deprecated
storage?: { [key: string]: ISerializableValue };
storage?: Record<string, ISerializableValue>;

/**
* Recursive sub-directories {@link IDirectoryDataObject | objects}.
*/
subdirectories?: { [subdirName: string]: IDirectoryDataObject };
subdirectories?: Record<string, IDirectoryDataObject>;

/**
* Create info for the sub directory. Since directories with same name can get deleted/created by multiple clients
Expand Down Expand Up @@ -322,27 +323,27 @@ interface SequenceData {
* TODO: It can be combined with the creation tracker utilized in SharedMap
*/
class DirectoryCreationTracker {
readonly indexToKey: RedBlackTree<SequenceData, string>;
public readonly indexToKey: RedBlackTree<SequenceData, string>;

readonly keyToIndex: Map<string, SequenceData>;
public readonly keyToIndex: Map<string, SequenceData>;

constructor() {
public constructor() {
this.indexToKey = new RedBlackTree<SequenceData, string>(seqDataComparator);
this.keyToIndex = new Map<string, SequenceData>();
}

set(key: string, seqData: SequenceData): void {
public set(key: string, seqData: SequenceData): void {
this.indexToKey.put(seqData, key);
this.keyToIndex.set(key, seqData);
}

has(keyOrSeqData: string | SequenceData): boolean {
public has(keyOrSeqData: string | SequenceData): boolean {
return typeof keyOrSeqData === "string"
? this.keyToIndex.has(keyOrSeqData)
: this.indexToKey.get(keyOrSeqData) !== undefined;
}

delete(keyOrSeqData: string | SequenceData): void {
public delete(keyOrSeqData: string | SequenceData): void {
if (this.has(keyOrSeqData)) {
if (typeof keyOrSeqData === "string") {
const seqData = this.keyToIndex.get(keyOrSeqData) as SequenceData;
Expand All @@ -361,7 +362,7 @@ class DirectoryCreationTracker {
* @param constraint - An optional constraint function that filters keys.
* @returns An array of keys that satisfy the constraint (or all keys if no constraint is provided).
*/
keys(constraint?: (key: string) => boolean): string[] {
public keys(constraint?: (key: string) => boolean): string[] {
const keys: string[] = [];
this.indexToKey.mapRange((node) => {
if (!constraint || constraint(node.data)) {
Expand Down Expand Up @@ -426,7 +427,7 @@ export class SharedDirectory
/**
* Mapping of op types to message handlers.
*/
private readonly messageHandlers: Map<string, IDirectoryMessageHandler> = new Map();
private readonly messageHandlers = new Map<string, IDirectoryMessageHandler>();

/**
* Constructs a new shared directory. If the object is non-local an id and service interfaces will
Expand Down Expand Up @@ -767,6 +768,7 @@ export class SharedDirectory
local: boolean,
localOpMetadata: unknown,
): void {
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (message.type === MessageType.Operation) {
const op: IDirectoryOperation = message.contents as IDirectoryOperation;
const handler = this.messageHandlers.get(op.type);
Expand Down Expand Up @@ -1091,6 +1093,10 @@ interface IDeleteSubDirLocalOpMetadata {
}

type SubDirLocalOpMetadata = ICreateSubDirLocalOpMetadata | IDeleteSubDirLocalOpMetadata;

/**
* Types of local op metadata.
*/
export type DirectoryLocalOpMetadata =
| IClearLocalOpMetadata
| IKeyEditLocalOpMetadata
Expand Down Expand Up @@ -1157,34 +1163,34 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
/**
* The in-memory data the directory is storing.
*/
private readonly _storage: Map<string, ILocalValue> = new Map();
private readonly _storage = new Map<string, ILocalValue>();

/**
* The subdirectories the directory is holding.
*/
private readonly _subdirectories: Map<string, SubDirectory> = new Map();
private readonly _subdirectories = new Map<string, SubDirectory>();

/**
* Keys that have been modified locally but not yet ack'd from the server. This is for operations on keys like
* set/delete operations on keys. The value of this map is list of pendingMessageIds at which that key
* was modified. We don't store the type of ops, and behaviour of key ops are different from behaviour of sub
* directory ops, so we have separate map from subDirectories tracker.
*/
private readonly pendingKeys: Map<string, number[]> = new Map();
private readonly pendingKeys = new Map<string, number[]>();

/**
* Subdirectories that have been deleted locally but not yet ack'd from the server. This maintains the record
* of delete op that are pending or yet to be acked from server. This is maintained just to track the locally
* deleted sub directory.
*/
private readonly pendingDeleteSubDirectoriesTracker: Map<string, number> = new Map();
private readonly pendingDeleteSubDirectoriesTracker = new Map<string, number>();

/**
* Subdirectories that have been created locally but not yet ack'd from the server. This maintains the record
* of create op that are pending or yet to be acked from server. This is maintained just to track the locally
* created sub directory.
*/
private readonly pendingCreateSubDirectoriesTracker: Map<string, number> = new Map();
private readonly pendingCreateSubDirectoriesTracker = new Map<string, number>();

/**
* This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.
Expand Down
2 changes: 1 addition & 1 deletion packages/dds/map/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @packageDocumentation
*/

export {
export type {
IDirectory,
IDirectoryEvents,
IDirectoryValueChanged,
Expand Down
4 changes: 2 additions & 2 deletions packages/dds/map/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* Licensed under the MIT License.
*/

import {
import type {
IDisposable,
IEvent,
IEventProvider,
IEventThisPlaceHolder,
} from "@fluidframework/core-interfaces";
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
import type { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";

/**
* Type of "valueChanged" event parameter.
Expand Down
3 changes: 1 addition & 2 deletions packages/dds/map/src/internalInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { ILocalValue } from "./localValues.js";
import type { ILocalValue } from "./localValues.js";

/**
* Operation indicating a value should be set for a key.
Expand All @@ -22,7 +22,6 @@ export interface IMapSetOperation {
/**
* Value to be set on the key.
*/
// eslint-disable-next-line import/no-deprecated
value: ISerializableValue;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/dds/map/src/localValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
* Licensed under the MIT License.
*/

import { IFluidHandle } from "@fluidframework/core-interfaces";
import { ISerializedHandle } from "@fluidframework/runtime-utils/internal";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import type { IFluidHandle } from "@fluidframework/core-interfaces";
import type { ISerializedHandle } from "@fluidframework/runtime-utils/internal";
import type { IFluidSerializer } from "@fluidframework/shared-object-base";
import {
ValueType,
parseHandles,
serializeHandles,
} from "@fluidframework/shared-object-base/internal";

// eslint-disable-next-line import/no-deprecated
import { ISerializableValue, ISerializedValue } from "./internalInterfaces.js";
import type { ISerializableValue, ISerializedValue } from "./internalInterfaces.js";

/**
* A local value to be stored in a container type Distributed Data Store (DDS).
Expand Down
13 changes: 7 additions & 6 deletions packages/dds/map/src/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
* Licensed under the MIT License.
*/

import {
import type {
IChannelAttributes,
IChannelStorageService,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions";
import { readAndParse } from "@fluidframework/driver-utils/internal";
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
import { MessageType, type ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
import type { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import type { IFluidSerializer } from "@fluidframework/shared-object-base";
import { SharedObject } from "@fluidframework/shared-object-base/internal";

import { ISharedMap, ISharedMapEvents } from "./interfaces.js";
import { IMapDataObjectSerializable, IMapOperation, MapKernel } from "./mapKernel.js";
import type { ISharedMap, ISharedMapEvents } from "./interfaces.js";
import { type IMapDataObjectSerializable, type IMapOperation, MapKernel } from "./mapKernel.js";

interface IMapSerializationFormat {
blobs?: string[];
Expand Down Expand Up @@ -284,6 +284,7 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
local: boolean,
localOpMetadata: unknown,
): void {
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (message.type === MessageType.Operation) {
this.kernel.tryProcessMessage(
message.contents as IMapOperation,
Expand Down
24 changes: 10 additions & 14 deletions packages/dds/map/src/mapKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Licensed under the MIT License.
*/

import { TypedEventEmitter } from "@fluid-internal/client-utils";
import { IFluidHandle } from "@fluidframework/core-interfaces";
import type { TypedEventEmitter } from "@fluid-internal/client-utils";
import type { IFluidHandle } from "@fluidframework/core-interfaces";
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import type { IFluidSerializer } from "@fluidframework/shared-object-base";
import { ValueType, bindHandles } from "@fluidframework/shared-object-base/internal";

import { ISharedMapEvents } from "./interfaces.js";
import {
import type { ISharedMapEvents } from "./interfaces.js";
import type {
IMapClearLocalOpMetadata,
IMapClearOperation,
IMapDeleteOperation,
Expand All @@ -21,7 +21,7 @@ import {
ISerializableValue,
ISerializedValue,
} from "./internalInterfaces.js";
import { ILocalValue, LocalValueMaker, makeSerializable } from "./localValues.js";
import { type ILocalValue, LocalValueMaker, makeSerializable } from "./localValues.js";

/**
* Defines the means to process and submit a given op on a map.
Expand Down Expand Up @@ -62,17 +62,13 @@ export type IMapOperation = IMapKeyOperation | IMapClearOperation;
* | JSON.stringify}, direct result from
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.
*/
export interface IMapDataObjectSerializable {
// eslint-disable-next-line import/no-deprecated
[key: string]: ISerializableValue;
}
// eslint-disable-next-line import/no-deprecated
export type IMapDataObjectSerializable = Record<string, ISerializableValue>;

/**
* Serialized key/value data.
*/
export interface IMapDataObjectSerialized {
[key: string]: ISerializedValue;
}
export type IMapDataObjectSerialized = Record<string, ISerializedValue>;

type MapKeyLocalOpMetadata = IMapKeyEditLocalOpMetadata | IMapKeyAddLocalOpMetadata;
type MapLocalOpMetadata = IMapClearLocalOpMetadata | MapKeyLocalOpMetadata;
Expand Down Expand Up @@ -153,7 +149,7 @@ export class MapKernel {
/**
* Keys that have been modified locally but not yet ack'd from the server.
*/
private readonly pendingKeys: Map<string, number[]> = new Map();
private readonly pendingKeys = new Map<string, number[]>();

/**
* This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.
Expand Down
Loading

0 comments on commit ffabda2

Please sign in to comment.