-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move events library to core-interfaces and core-utils #23037
Move events library to core-interfaces and core-utils #23037
Conversation
packages/common/core-interfaces/api-report/core-interfaces.beta.api.md
Outdated
Show resolved
Hide resolved
packages/common/core-interfaces/api-report/core-interfaces.beta.api.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e750cb1
to
6bdacc5
Compare
6bdacc5
to
b4ea361
Compare
21b1057
to
fa229a3
Compare
@@ -168,7 +171,7 @@ export class EventEmitter<TListeners extends Listeners<TListeners>> | |||
const eventDescription = | |||
typeof eventName === "symbol" ? eventName.description : String(eventName.toString()); | |||
|
|||
throw new UsageError( | |||
throw new Error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UsageError
has been replaced with the standard Error
type because telemetry-utils cannot be added as a dependency in core-utils, due to a layer-check failure.
fyi: @noencke
@@ -5,7 +5,7 @@ | |||
|
|||
import { strict as assert } from "node:assert"; | |||
|
|||
import { validateAssertionError } from "@fluidframework/test-runtime-utils/internal"; | |||
// import { validateAssertionError } from "@fluidframework/test-runtime-utils/internal"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateAssertionError
has been replaced with the standard Error
type because test-runtime-utils cannot be added as a dependency in core-utils, due to a layer-check failure.
fyi, @noencke
f0d55d8
to
b84034c
Compare
⯅ @fluid-example/bundle-size-tests: +391 Bytes
Baseline commit: 3fe3fa5 |
e27d63e
to
3ec50b1
Compare
* @system | ||
* @public | ||
*/ | ||
export type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. this file doesn't really need to be edited. if you keep your local main branch up to date you can run git checkout main -- packages/dds/tree/src/util/typeUtils.ts
to clobber it with the version from main, kind of like a revert. you can even do it on whole sub-paths if you want to undo changes in an area.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked at the whole PR, but wondering if client-utils a better fit to move eventing to (core-utils
says it's for fluid-agnostic utilities). If the whole set of features we're moving don't have dependencies on Fluid-specific things, then core-utils might be fine, but the fact that core-utils now requires a new dependency on core-interfaces (which contains Fluid-specific types) makes me think that's not the case and that client-utils might indeed be a better target.
Also, we'll want a changeset for this PR.
@@ -4,7 +4,7 @@ | |||
*/ | |||
|
|||
/** | |||
* `true` iff the given type is an acceptable shape for a {@link Listeners | event} listener | |||
* `true` if the given type is an acceptable shape for a {@link Listeners | event} listener |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iff
might have been a deliberate abbreviation of "if and only if" but I think in this context it doesn't make a difference.
@@ -3,7 +3,8 @@ | |||
* Licensed under the MIT License. | |||
*/ | |||
|
|||
import { type NestedMap, getOrDefaultInNestedMap, setInNestedMap } from "./nestedMap.js"; | |||
import type { NestedMap } from "@fluidframework/core-interfaces/internal"; | |||
import { getOrDefaultInNestedMap, setInNestedMap } from "./nestedMap.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With NestedMap
moving to a common place, I find it a bit weird that some of the functions to use it are in tree and not in core-utils. Should we move the functions there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this same concern but IMO this is too much scope growth. I'm inclined to duplicate what's needed for emitter.ts into client-utils and change none of the utility functions' homes in this PR.
At a glance I'm not a fan of this nested map concept and I think it needs to defend itself in its own PR.
@@ -17,7 +19,6 @@ import type { | |||
JsonSerializable, | |||
} from "@fluid-experimental/presence/internal/core-interfaces"; | |||
import type { ISubscribable } from "@fluid-experimental/presence/internal/events"; | |||
import { createEmitter } from "@fluid-experimental/presence/internal/events"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tangent: I'm a bit confused here. Presence does all its imports with the full package name instead of relative paths? (cc @jason-ha).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core-utils also does: https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-utils/src/test/timer.spec.ts#L12. I think that's to avoid adding eslint suppression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't lint suppression.
The best use for "self-references" is in testing. We should test against the public API more. For that we should use package reference where possible. Then we can also see where we are violating API to do certain testing.
Here it is used to manage the temp duplication of the tree events package and workaround api-extractor
fussiness. Everything in presence that is using one these complex presence/internal/foo paths has a plan to get rid of them.
That's a good point. I thought about adding events to client-utils but the README suggests it's a "dumping ground," so it’s best to avoid adding new functionality in there? Probably it's okay to have core-interfaces as a dependency on core-utils and core-utils not be fluid agnostic utility package? |
client-utils is better, but it is fluid-internal :( , so we shouldn't put non-internal things there |
I don't feel too strongly against this, but it seems to me like a good office hours topic. I'm also not sure what I think about client-utils own README stating "In most cases, the code would be better placed in a |
Yeah, that's probably one of the strongest arguments against it. I think technically nothing prevents us from exposing APIs there as |
-- Tangent from the client-utils discussion thread --
Eventing is fluid agnostic, and I hope remains fluid agnostic. So, I agree we should not mix with fluid dependencies. We also already have eventing support in core-utils. This is part of the transition to replace that. So, this is perhaps an argument against the suggestion to put the interfaces in |
i don't think we want or should be in the business of creating reusable libraries which are external to fluid, as it's not a support burden we should take on. For the existing eventing it is split between core-interfaces and client-utils, so maybe we just ignore the odd scoping, and go with client-utils anyway. |
Seems very funny that eventing has types in core-interfaces but core-utils that provides implementation doesn't reference core-interfaces. .... well that is because core-utils doesn't provide implementation (I made bad assumption above). client-utils is providing it. I don't see reason why the implementation shouldn't be in client-utils. |
6b9eb93
to
9f560f9
Compare
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output
|
I’ve opened a new PR that addresses most of the feedback from this one: #23141 |
This change relocates event library from SharedTree to client-utils and core-interfaces. Old PR: #23037 [ADO#6595](https://dev.azure.com/fluidframework/internal/_workitems/edit/6595)
This change relocates event library from SharedTree to core-utils and core-interfaces. It updates imports in both the tree and presence packages to reference the event library.
ADO