@fluid-internal/presence-runtime 2.101.1 → 2.103.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.
Files changed (85) hide show
  1. package/dist/packageVersion.d.ts +1 -1
  2. package/dist/packageVersion.js +1 -1
  3. package/dist/packageVersion.js.map +1 -1
  4. package/dist/runtime/extension/containerPresence.d.ts +1 -1
  5. package/dist/runtime/presenceDatastoreManager.d.ts +2 -2
  6. package/dist/runtime/presenceDatastoreManager.d.ts.map +1 -1
  7. package/dist/runtime/presenceDatastoreManager.js.map +1 -1
  8. package/dist/runtime/presenceManager.js.map +1 -1
  9. package/lib/packageVersion.d.ts +1 -1
  10. package/lib/packageVersion.js +1 -1
  11. package/lib/packageVersion.js.map +1 -1
  12. package/lib/runtime/extension/containerPresence.d.ts +1 -1
  13. package/lib/runtime/presenceDatastoreManager.d.ts +2 -2
  14. package/lib/runtime/presenceDatastoreManager.d.ts.map +1 -1
  15. package/lib/runtime/presenceDatastoreManager.js.map +1 -1
  16. package/lib/runtime/presenceManager.js.map +1 -1
  17. package/package.json +14 -14
  18. package/dist/runtime/test/presenceDatastoreManager.spec.js +0 -618
  19. package/dist/runtime/test/presenceDatastoreManager.spec.js.map +0 -1
  20. package/dist/runtime/test/presenceManager.spec.js +0 -651
  21. package/dist/runtime/test/presenceManager.spec.js.map +0 -1
  22. package/dist/states/test/batching.spec.js +0 -843
  23. package/dist/states/test/batching.spec.js.map +0 -1
  24. package/dist/states/test/broadcastControlsTests.js +0 -60
  25. package/dist/states/test/broadcastControlsTests.js.map +0 -1
  26. package/dist/states/test/eventing.spec.js +0 -576
  27. package/dist/states/test/eventing.spec.js.map +0 -1
  28. package/dist/states/test/latestMapValueManager.spec.js +0 -210
  29. package/dist/states/test/latestMapValueManager.spec.js.map +0 -1
  30. package/dist/states/test/latestValueManager.spec.js +0 -193
  31. package/dist/states/test/latestValueManager.spec.js.map +0 -1
  32. package/dist/states/test/mockEphemeralRuntime.js +0 -11
  33. package/dist/states/test/mockEphemeralRuntime.js.map +0 -1
  34. package/dist/states/test/notificationsManager.spec.js +0 -460
  35. package/dist/states/test/notificationsManager.spec.js.map +0 -1
  36. package/dist/states/test/presenceStates.spec.js +0 -73
  37. package/dist/states/test/presenceStates.spec.js.map +0 -1
  38. package/dist/states/test/schemaValidation/protocol.spec.js +0 -246
  39. package/dist/states/test/schemaValidation/protocol.spec.js.map +0 -1
  40. package/dist/states/test/schemaValidation/valueManagers.spec.js +0 -784
  41. package/dist/states/test/schemaValidation/valueManagers.spec.js.map +0 -1
  42. package/dist/states/test/testUtils.js +0 -21
  43. package/dist/states/test/testUtils.js.map +0 -1
  44. package/dist/test/mockEphemeralRuntime.js +0 -175
  45. package/dist/test/mockEphemeralRuntime.js.map +0 -1
  46. package/dist/test/testUtils.js +0 -262
  47. package/dist/test/testUtils.js.map +0 -1
  48. package/dist/test/utils/index.js +0 -27
  49. package/dist/test/utils/index.js.map +0 -1
  50. package/dist/utils/test/timerManager.spec.js +0 -93
  51. package/dist/utils/test/timerManager.spec.js.map +0 -1
  52. package/lib/runtime/test/presenceDatastoreManager.spec.js +0 -616
  53. package/lib/runtime/test/presenceDatastoreManager.spec.js.map +0 -1
  54. package/lib/runtime/test/presenceManager.spec.js +0 -649
  55. package/lib/runtime/test/presenceManager.spec.js.map +0 -1
  56. package/lib/states/test/batching.spec.js +0 -841
  57. package/lib/states/test/batching.spec.js.map +0 -1
  58. package/lib/states/test/broadcastControlsTests.js +0 -56
  59. package/lib/states/test/broadcastControlsTests.js.map +0 -1
  60. package/lib/states/test/eventing.spec.js +0 -574
  61. package/lib/states/test/eventing.spec.js.map +0 -1
  62. package/lib/states/test/latestMapValueManager.spec.js +0 -206
  63. package/lib/states/test/latestMapValueManager.spec.js.map +0 -1
  64. package/lib/states/test/latestValueManager.spec.js +0 -189
  65. package/lib/states/test/latestValueManager.spec.js.map +0 -1
  66. package/lib/states/test/mockEphemeralRuntime.js +0 -6
  67. package/lib/states/test/mockEphemeralRuntime.js.map +0 -1
  68. package/lib/states/test/notificationsManager.spec.js +0 -456
  69. package/lib/states/test/notificationsManager.spec.js.map +0 -1
  70. package/lib/states/test/presenceStates.spec.js +0 -69
  71. package/lib/states/test/presenceStates.spec.js.map +0 -1
  72. package/lib/states/test/schemaValidation/protocol.spec.js +0 -244
  73. package/lib/states/test/schemaValidation/protocol.spec.js.map +0 -1
  74. package/lib/states/test/schemaValidation/valueManagers.spec.js +0 -782
  75. package/lib/states/test/schemaValidation/valueManagers.spec.js.map +0 -1
  76. package/lib/states/test/testUtils.js +0 -6
  77. package/lib/states/test/testUtils.js.map +0 -1
  78. package/lib/test/mockEphemeralRuntime.js +0 -171
  79. package/lib/test/mockEphemeralRuntime.js.map +0 -1
  80. package/lib/test/testUtils.js +0 -251
  81. package/lib/test/testUtils.js.map +0 -1
  82. package/lib/test/utils/index.js +0 -8
  83. package/lib/test/utils/index.js.map +0 -1
  84. package/lib/utils/test/timerManager.spec.js +0 -91
  85. package/lib/utils/test/timerManager.spec.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventing.spec.js","sourceRoot":"","sources":["../../../src/states/test/eventing.spec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,6CAA+C;AAU/C,kEAAkF;AAElF,iCAA2C;AAM3C,oEAAsF;AACtF,kEAAsE;AAEtE,uEAAiE;AAEjE,iDAMwB;AAExB,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAGnD;;GAEG;AACH,MAAM,cAAc,GAAG;IACtB,mBAAmB,EAAE;QACpB,SAAS,EAAE;YACV,KAAK,EAAE,CAAC;YACR,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,0BAAW;SACpB;KACD;CACQ,CAAC;AACX,MAAM,YAAY,GAAG;IACpB,QAAQ,EAAE;QACT,CAAC,0BAAW,CAAC,EAAE;YACd,KAAK,EAAE,CAAC;YACR,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,IAAA,oBAAY,EAAC,EA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EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;6BAC7D;yBACD,CAAC,CAAC;oBACJ,CAAC;gBACF,CAAC,CAAC,CAAC;gBAEH,MAAM;gBACN,cAAc,CAAC,sBAAsB,CAAC,CAAC;gBACvC,cAAc,CAAC,qBAAqB,CAAC,CAAC;gBAEtC,SAAS;gBACT,WAAW,CAAC,eAAe,EAAE,EAAE;oBAC9B,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;oBAC1D;wBACC,OAAO,EAAE,WAAW;wBACpB,aAAa,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;qBACxD;iBACD,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport type {\n\tAttendee,\n\tLatestMapRaw,\n\tLatestRaw,\n\tNotificationsManager,\n\tPresenceWithNotifications,\n\tWorkspaceAddress,\n} from \"@fluid-internal/presence-definitions\";\nimport { EventAndErrorTrackingLogger } from \"@fluidframework/test-utils/internal\";\nimport type { SinonFakeTimers, SinonSpy } from \"sinon\";\nimport { useFakeTimers, spy } from \"sinon\";\n\nimport type {\n\tGeneralDatastoreMessageContent,\n\tInternalWorkspaceAddress,\n} from \"@fluid-internal/presence-runtime/internal/test\";\nimport { Notifications, StateFactory } from \"@fluid-internal/presence-runtime/states\";\nimport { toOpaqueJson } from \"@fluid-internal/presence-runtime/utils\";\n\nimport { MockEphemeralRuntime } from \"./mockEphemeralRuntime.js\";\nimport type { ProcessSignalFunction } from \"./testUtils.js\";\nimport {\n\tassertFinalExpectations,\n\tprepareConnectedPresence,\n\tattendeeId1,\n\tlocalAttendeeId,\n\tinitialLocalClientConnectionId,\n} from \"./testUtils.js\";\n\nconst datastoreUpdateType = \"Pres:DatastoreUpdate\";\n\ntype StatesObjectUpdateContent = GeneralDatastoreMessageContent[InternalWorkspaceAddress];\n/**\n * Workspace updates\n */\nconst attendeeUpdate = {\n\t\"clientToSessionId\": {\n\t\t\"client1\": {\n\t\t\t\"rev\": 0,\n\t\t\t\"timestamp\": 0,\n\t\t\t\"value\": attendeeId1,\n\t\t},\n\t},\n} as const;\nconst latestUpdate = {\n\t\"latest\": {\n\t\t[attendeeId1]: {\n\t\t\t\"rev\": 1,\n\t\t\t\"timestamp\": 0,\n\t\t\t\"value\": toOpaqueJson({ x: 1, y: 1, z: 1 }),\n\t\t},\n\t},\n} as const satisfies StatesObjectUpdateContent;\nconst latestMapUpdate = {\n\t\"latestMap\": {\n\t\t[attendeeId1]: {\n\t\t\t\"rev\": 1,\n\t\t\t\"items\": {\n\t\t\t\t\"key1\": {\n\t\t\t\t\t\"rev\": 1,\n\t\t\t\t\t\"timestamp\": 0,\n\t\t\t\t\t\"value\": toOpaqueJson({ a: 1, b: 1 }),\n\t\t\t\t},\n\t\t\t\t\"key2\": {\n\t\t\t\t\t\"rev\": 1,\n\t\t\t\t\t\"timestamp\": 0,\n\t\t\t\t\t\"value\": toOpaqueJson({ c: 1, d: 1 }),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} as const satisfies StatesObjectUpdateContent;\nconst latestUpdateRev2 = {\n\t\"latest\": {\n\t\t[attendeeId1]: {\n\t\t\t\"rev\": 2,\n\t\t\t\"timestamp\": 50,\n\t\t\t\"value\": toOpaqueJson({ x: 2, y: 2, z: 2 }),\n\t\t},\n\t},\n} as const satisfies StatesObjectUpdateContent;\nconst itemRemovedMapUpdate = {\n\t\"latestMap\": {\n\t\t[attendeeId1]: {\n\t\t\t\"rev\": 2,\n\t\t\t\"items\": {\n\t\t\t\t\"key2\": {\n\t\t\t\t\t\"rev\": 2,\n\t\t\t\t\t\"timestamp\": 50,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} as const satisfies StatesObjectUpdateContent;\nconst itemRemovedAndItemUpdatedMapUpdate = {\n\t\"latestMap\": {\n\t\t[attendeeId1]: {\n\t\t\t\"rev\": 2,\n\t\t\t\"items\": {\n\t\t\t\t\"key2\": {\n\t\t\t\t\t\"rev\": 2,\n\t\t\t\t\t\"timestamp\": 50,\n\t\t\t\t},\n\t\t\t\t\"key1\": {\n\t\t\t\t\t\"rev\": 2,\n\t\t\t\t\t\"timestamp\": 50,\n\t\t\t\t\t\"value\": toOpaqueJson({ a: 2, b: 2 }),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} as const satisfies StatesObjectUpdateContent;\nconst itemUpdatedAndItemRemovedMapUpdate = {\n\t\"latestMap\": {\n\t\t[attendeeId1]: {\n\t\t\t\"rev\": 2,\n\t\t\t\"items\": {\n\t\t\t\t\"key1\": {\n\t\t\t\t\t\"rev\": 2,\n\t\t\t\t\t\"timestamp\": 50,\n\t\t\t\t\t\"value\": toOpaqueJson({ a: 2, b: 2 }),\n\t\t\t\t},\n\t\t\t\t\"key2\": {\n\t\t\t\t\t\"rev\": 2,\n\t\t\t\t\t\"timestamp\": 50,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} as const satisfies StatesObjectUpdateContent;\nconst notificationsUpdate = {\n\t\"testEvents\": {\n\t\t[attendeeId1]: {\n\t\t\t\"rev\": 0,\n\t\t\t\"timestamp\": 0,\n\t\t\t\"value\": toOpaqueJson({ \"name\": \"newId\", \"args\": [42] }),\n\t\t\t\"ignoreUnmonitored\": true,\n\t\t},\n\t},\n} as const satisfies StatesObjectUpdateContent;\n\ndescribe(\"Presence/States\", () => {\n\tdescribe(\"events are fired with consistent and final state when\", () => {\n\t\tlet runtime: MockEphemeralRuntime;\n\t\tlet logger: EventAndErrorTrackingLogger;\n\t\tlet clock: SinonFakeTimers;\n\t\tlet presence: PresenceWithNotifications;\n\t\tlet processSignal: ProcessSignalFunction;\n\t\tlet latest: LatestRaw<{ x: number; y: number; z: number }>;\n\t\tlet latestMap: LatestMapRaw<{ a: number; b: number } | { c: number; d: number }>;\n\t\tlet notificationManager: NotificationsManager<{ newId: (id: number) => void }>;\n\n\t\tinterface LatestMapValueExpected {\n\t\t\tkey1: { a: number; b: number } | undefined;\n\t\t\tkey2: { c: number; d: number } | undefined;\n\t\t}\n\t\tinterface LatestValueExpected {\n\t\t\tx: number;\n\t\t\ty: number;\n\t\t\tz: number;\n\t\t}\n\t\ttype StateVerification =\n\t\t\t| {\n\t\t\t\t\tmanager: \"latest\";\n\t\t\t\t\texpectedValue: LatestValueExpected;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tmanager: \"latestMap\";\n\t\t\t\t\texpectedValue: LatestMapValueExpected;\n\t\t\t };\n\n\t\tfunction verifyState(attendee: Attendee, verifications: StateVerification[]): void {\n\t\t\tassert(attendee !== undefined, \"Eventing does not reflect new attendee\");\n\t\t\tassert.strictEqual(\n\t\t\t\tattendee.attendeeId,\n\t\t\t\t\"attendeeId-1\",\n\t\t\t\t\"Eventing does not reflect new attendee's attendeeId\",\n\t\t\t);\n\t\t\tassert.strictEqual(\n\t\t\t\tattendee.getConnectionId(),\n\t\t\t\t\"client1\",\n\t\t\t\t\"Eventing does not reflect new attendee's connection id\",\n\t\t\t);\n\n\t\t\tfor (const { manager, expectedValue } of verifications) {\n\t\t\t\tswitch (manager) {\n\t\t\t\t\tcase \"latest\": {\n\t\t\t\t\t\tassert.deepEqual(\n\t\t\t\t\t\t\tlatest.getRemote(attendee).value,\n\t\t\t\t\t\t\texpectedValue,\n\t\t\t\t\t\t\t\"Eventing does not reflect latest value\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"latestMap\": {\n\t\t\t\t\t\tassert.deepEqual(\n\t\t\t\t\t\t\tlatestMap.getRemote(attendee).get(\"key1\")?.value,\n\t\t\t\t\t\t\texpectedValue.key1,\n\t\t\t\t\t\t\t\"Eventing does not reflect latest map value\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert.deepEqual(\n\t\t\t\t\t\t\tlatestMap.getRemote(attendee).get(\"key2\")?.value,\n\t\t\t\t\t\t\texpectedValue.key2,\n\t\t\t\t\t\t\t\"Eventing does not reflect latest map value\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tbefore(() => {\n\t\t\tclock = useFakeTimers();\n\t\t});\n\n\t\tbeforeEach(() => {\n\t\t\tlogger = new EventAndErrorTrackingLogger();\n\t\t\truntime = new MockEphemeralRuntime(logger);\n\t\t\t({ presence, processSignal } = prepareConnectedPresence(\n\t\t\t\truntime,\n\t\t\t\tlocalAttendeeId,\n\t\t\t\tinitialLocalClientConnectionId,\n\t\t\t\tclock,\n\t\t\t\tlogger,\n\t\t\t));\n\t\t});\n\n\t\tafterEach(function (done: Mocha.Done) {\n\t\t\tclock.reset();\n\t\t\tif (this.currentTest?.state === \"passed\") {\n\t\t\t\tassertFinalExpectations(runtime, logger);\n\t\t\t}\n\t\t\tdone();\n\t\t});\n\n\t\tafter(() => {\n\t\t\tclock.restore();\n\t\t});\n\n\t\tfunction setupSharedStatesWorkspace({\n\t\t\tnotifications,\n\t\t}: {\n\t\t\tnotifications?: true;\n\t\t} = {}): void {\n\t\t\tconst statesWorkspace = presence.states.getWorkspace(\"name:testWorkspace\", {\n\t\t\t\tlatest: StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),\n\t\t\t\tlatestMap: StateFactory.latestMap({\n\t\t\t\t\tlocal: { key1: { a: 0, b: 0 }, key2: { c: 0, d: 0 } },\n\t\t\t\t}),\n\t\t\t});\n\t\t\tlatest = statesWorkspace.states.latest;\n\t\t\tlatestMap = statesWorkspace.states.latestMap;\n\t\t\tif (notifications) {\n\t\t\t\tconst workspace: typeof statesWorkspace = statesWorkspace;\n\t\t\t\tworkspace.add(\n\t\t\t\t\t\"testEvents\",\n\t\t\t\t\tNotifications<{ newId: (id: number) => void }>({\n\t\t\t\t\t\tnewId: (_attendee: Attendee, _id: number) => {},\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tnotificationManager = workspace.states.testEvents;\n\t\t\t}\n\t\t}\n\n\t\tfunction setupMultipleStatesWorkspaces(): void {\n\t\t\tconst latestsStates = presence.states.getWorkspace(\"name:testWorkspace1\", {\n\t\t\t\tlatest: StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),\n\t\t\t});\n\t\t\tconst latesetMapStates = presence.states.getWorkspace(\"name:testWorkspace2\", {\n\t\t\t\tlatestMap: StateFactory.latestMap({\n\t\t\t\t\tlocal: { key1: { a: 0, b: 0 }, key2: { c: 0, d: 0 } },\n\t\t\t\t}),\n\t\t\t});\n\t\t\tlatest = latestsStates.states.latest;\n\t\t\tlatestMap = latesetMapStates.states.latestMap;\n\t\t}\n\n\t\tfunction setupNotificationsWorkspace(): void {\n\t\t\tconst notificationsWorkspace = presence.notifications.getWorkspace(\n\t\t\t\t\"name:testWorkspace\",\n\t\t\t\t{\n\t\t\t\t\ttestEvents: Notifications<{ newId: (id: number) => void }>({\n\t\t\t\t\t\tnewId: (_attendee: Attendee, _id: number) => {},\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\t\t\tnotificationManager = notificationsWorkspace.notifications.testEvents;\n\t\t}\n\n\t\tfunction processUpdates(valueManagerUpdates: GeneralDatastoreMessageContent): void {\n\t\t\tconst updates = { \"system:presence\": attendeeUpdate, ...valueManagerUpdates };\n\n\t\t\tprocessSignal(\n\t\t\t\t[],\n\t\t\t\t{\n\t\t\t\t\ttype: datastoreUpdateType,\n\t\t\t\t\tcontent: {\n\t\t\t\t\t\tsendTimestamp: clock.now - 10,\n\t\t\t\t\t\tavgLatency: 20,\n\t\t\t\t\t\tdata: updates,\n\t\t\t\t\t},\n\t\t\t\t\tclientId: \"client1\",\n\t\t\t\t},\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\n\t\tfunction getTestAttendee(): Attendee {\n\t\t\treturn presence.attendees.getAttendee(\"attendeeId-1\");\n\t\t}\n\n\t\tdescribe(\"states workspace\", () => {\n\t\t\tlet latestUpdatedEventSpy: SinonSpy;\n\t\t\tlet latestMapUpdatedEventSpy: SinonSpy;\n\t\t\tlet itemUpdatedEventSpy: SinonSpy;\n\n\t\t\tdescribe(\"value is updated where\", () => {\n\t\t\t\tlet atteendeeEventSpy: SinonSpy;\n\n\t\t\t\tfunction verify(): void {\n\t\t\t\t\tverifyState(getTestAttendee(), [\n\t\t\t\t\t\t{ manager: \"latest\", expectedValue: { x: 1, y: 1, z: 1 } },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmanager: \"latestMap\",\n\t\t\t\t\t\t\texpectedValue: { key1: { a: 1, b: 1 }, key2: { c: 1, d: 1 } },\n\t\t\t\t\t\t},\n\t\t\t\t\t]);\n\t\t\t\t}\n\n\t\t\t\tfunction assertSpies(): void {\n\t\t\t\t\tassert.ok(atteendeeEventSpy.calledOnce, \"attendee event not fired exactly once\");\n\t\t\t\t\tassert.ok(\n\t\t\t\t\t\tlatestUpdatedEventSpy.calledOnce,\n\t\t\t\t\t\t\"latest update event not fired exactly once\",\n\t\t\t\t\t);\n\t\t\t\t\tassert.ok(\n\t\t\t\t\t\tlatestMapUpdatedEventSpy.calledOnce,\n\t\t\t\t\t\t\"latestMap update event not fired exactly once\",\n\t\t\t\t\t);\n\t\t\t\t\tassert.ok(\n\t\t\t\t\t\titemUpdatedEventSpy.calledTwice,\n\t\t\t\t\t\t\"latestMap item update event not fired exactly twice\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tfunction setupSpiesAndListeners(): void {\n\t\t\t\t\tlatestUpdatedEventSpy = spy(verify);\n\t\t\t\t\tlatestMapUpdatedEventSpy = spy(verify);\n\t\t\t\t\titemUpdatedEventSpy = spy(verify);\n\t\t\t\t\tatteendeeEventSpy = spy(verify);\n\n\t\t\t\t\tlatest.events.on(\"remoteUpdated\", latestUpdatedEventSpy);\n\t\t\t\t\tlatestMap.events.on(\"remoteUpdated\", latestMapUpdatedEventSpy);\n\t\t\t\t\tlatestMap.events.on(\"remoteItemUpdated\", itemUpdatedEventSpy);\n\t\t\t\t\tpresence.attendees.events.on(\"attendeeConnected\", atteendeeEventSpy);\n\t\t\t\t}\n\n\t\t\t\tit(\"'latest' update comes before 'latestMap' update in single workspace\", async () => {\n\t\t\t\t\t// Setup\n\t\t\t\t\tsetupSharedStatesWorkspace();\n\t\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\t\tconst workspace = {\n\t\t\t\t\t\t\"s:name:testWorkspace\": { ...latestUpdate, ...latestMapUpdate },\n\t\t\t\t\t};\n\t\t\t\t\t// Act\n\t\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t\t// Verify\n\t\t\t\t\tassertSpies();\n\t\t\t\t});\n\n\t\t\t\tit(\"'latestMap' update comes before 'latest' update in single workspace\", async () => {\n\t\t\t\t\t// Setup\n\t\t\t\t\tsetupSharedStatesWorkspace();\n\t\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\t\tconst workspace = {\n\t\t\t\t\t\t\"s:name:testWorkspace\": { ...latestMapUpdate, ...latestUpdate },\n\t\t\t\t\t};\n\t\t\t\t\t// Act\n\t\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t\t// Verify\n\t\t\t\t\tassertSpies();\n\t\t\t\t});\n\n\t\t\t\tit(\"workspace 1 update comes before workspace 2 update in multiple workspaces\", async () => {\n\t\t\t\t\t// Setup\n\t\t\t\t\tsetupMultipleStatesWorkspaces();\n\t\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\t\tconst workspace = {\n\t\t\t\t\t\t\"s:name:testWorkspace1\": latestUpdate,\n\t\t\t\t\t\t\"s:name:testWorkspace2\": latestMapUpdate,\n\t\t\t\t\t};\n\t\t\t\t\t// Act\n\t\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t\t// Verify\n\t\t\t\t\tassertSpies();\n\t\t\t\t});\n\n\t\t\t\tit(\"workspace 2 update comes before workspace 1 update in multiple workspaces\", async () => {\n\t\t\t\t\t// Setup\n\t\t\t\t\tsetupMultipleStatesWorkspaces();\n\t\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\t\tconst workspace = {\n\t\t\t\t\t\t\"s:name:testWorkspace2\": latestMapUpdate,\n\t\t\t\t\t\t\"s:name:testWorkspace1\": latestUpdate,\n\t\t\t\t\t};\n\t\t\t\t\t// Act\n\t\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t\t// Verify\n\t\t\t\t\tassertSpies();\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tdescribe(\"map item is removed\", () => {\n\t\t\t\tlet itemRemovedEventSpy: SinonSpy;\n\n\t\t\t\tdescribe(\"and 'latest' value updated\", () => {\n\t\t\t\t\tfunction verify(): void {\n\t\t\t\t\t\tverifyState(getTestAttendee(), [\n\t\t\t\t\t\t\t{ manager: \"latest\", expectedValue: { x: 2, y: 2, z: 2 } },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmanager: \"latestMap\",\n\t\t\t\t\t\t\t\texpectedValue: { key1: { a: 1, b: 1 }, key2: undefined },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction setupSpiesAndListeners(): void {\n\t\t\t\t\t\titemRemovedEventSpy = spy(verify);\n\t\t\t\t\t\tlatestUpdatedEventSpy = spy(verify);\n\t\t\t\t\t\tlatestMapUpdatedEventSpy = spy(verify);\n\t\t\t\t\t\tlatest.events.on(\"remoteUpdated\", latestUpdatedEventSpy);\n\t\t\t\t\t\tlatestMap.events.on(\"remoteUpdated\", latestMapUpdatedEventSpy);\n\t\t\t\t\t\tlatestMap.events.on(\"remoteItemRemoved\", itemRemovedEventSpy);\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction assertSpies(): void {\n\t\t\t\t\t\tassert.ok(\n\t\t\t\t\t\t\tlatestUpdatedEventSpy.calledOnce,\n\t\t\t\t\t\t\t`latest update event not fired exactly once`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert.ok(\n\t\t\t\t\t\t\tlatestMapUpdatedEventSpy.calledOnce,\n\t\t\t\t\t\t\t\"latestMap update event not fired exactly once\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert.ok(\n\t\t\t\t\t\t\titemRemovedEventSpy.calledOnce,\n\t\t\t\t\t\t\t\"latestMap item remove event not fired exactly once\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tit(\"in a single workspace\", async () => {\n\t\t\t\t\t\t// Setup\n\t\t\t\t\t\tsetupSharedStatesWorkspace();\n\t\t\t\t\t\tconst workspace = {\n\t\t\t\t\t\t\t\"s:name:testWorkspace\": { ...latestMapUpdate, ...latestUpdate },\n\t\t\t\t\t\t};\n\t\t\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\t\t\tconst itemRemovedUpdate = {\n\t\t\t\t\t\t\t\"s:name:testWorkspace\": { ...latestUpdateRev2, ...itemRemovedMapUpdate },\n\t\t\t\t\t\t};\n\t\t\t\t\t\t// Act\n\t\t\t\t\t\tprocessUpdates(itemRemovedUpdate);\n\t\t\t\t\t\t// Verify\n\t\t\t\t\t\tassertSpies();\n\t\t\t\t\t});\n\n\t\t\t\t\tit(\"in multiple workspaces\", async () => {\n\t\t\t\t\t\t// Setup\n\t\t\t\t\t\tsetupMultipleStatesWorkspaces();\n\t\t\t\t\t\tconst workspace = {\n\t\t\t\t\t\t\t\"s:name:testWorkspace2\": latestMapUpdate,\n\t\t\t\t\t\t\t\"s:name:testWorkspace1\": latestUpdate,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\t\t\tconst itemRemovedUpdate = {\n\t\t\t\t\t\t\t\"s:name:testWorkspace1\": latestUpdateRev2,\n\t\t\t\t\t\t\t\"s:name:testWorkspace2\": itemRemovedMapUpdate,\n\t\t\t\t\t\t};\n\t\t\t\t\t\t// Act\n\t\t\t\t\t\tprocessUpdates(itemRemovedUpdate);\n\t\t\t\t\t\t// Verify\n\t\t\t\t\t\tassertSpies();\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tdescribe(\"and map item is updated\", () => {\n\t\t\t\t\tfunction verify(): void {\n\t\t\t\t\t\tverifyState(getTestAttendee(), [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmanager: \"latestMap\",\n\t\t\t\t\t\t\t\texpectedValue: { key1: { a: 2, b: 2 }, key2: undefined },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction setupSpiesAndListeners(): void {\n\t\t\t\t\t\titemRemovedEventSpy = spy(verify);\n\t\t\t\t\t\tlatestMapUpdatedEventSpy = spy(verify);\n\t\t\t\t\t\titemUpdatedEventSpy = spy(verify);\n\n\t\t\t\t\t\tlatestMap.events.on(\"remoteUpdated\", latestMapUpdatedEventSpy);\n\t\t\t\t\t\tlatestMap.events.on(\"remoteItemUpdated\", itemUpdatedEventSpy);\n\t\t\t\t\t\tlatestMap.events.on(\"remoteItemRemoved\", itemRemovedEventSpy);\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction assertSpies(): void {\n\t\t\t\t\t\tassert.ok(\n\t\t\t\t\t\t\titemUpdatedEventSpy.calledOnce,\n\t\t\t\t\t\t\t`latest update event not fired exactly once`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert.ok(\n\t\t\t\t\t\t\tlatestMapUpdatedEventSpy.calledOnce,\n\t\t\t\t\t\t\t\"latestMap update event not fired exactly once\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert.ok(\n\t\t\t\t\t\t\titemRemovedEventSpy.calledOnce,\n\t\t\t\t\t\t\t\"latestMap item remove event not fired exactly once\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tit(\"with removal first\", () => {\n\t\t\t\t\t\t// Setup\n\t\t\t\t\t\tsetupSharedStatesWorkspace();\n\t\t\t\t\t\tconst workspace = {\n\t\t\t\t\t\t\t\"s:name:testWorkspace\": latestMapUpdate,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\t\t\tconst itemRemovedAndItemUpdatedUpdate = {\n\t\t\t\t\t\t\t\"s:name:testWorkspace\": itemRemovedAndItemUpdatedMapUpdate,\n\t\t\t\t\t\t} as const satisfies GeneralDatastoreMessageContent;\n\t\t\t\t\t\t// Act\n\t\t\t\t\t\tprocessUpdates(itemRemovedAndItemUpdatedUpdate);\n\t\t\t\t\t\t// Verify\n\t\t\t\t\t\tassertSpies();\n\t\t\t\t\t});\n\n\t\t\t\t\tit(\"with update first\", () => {\n\t\t\t\t\t\t// Setup\n\t\t\t\t\t\tsetupSharedStatesWorkspace();\n\t\t\t\t\t\tconst workspace = {\n\t\t\t\t\t\t\t\"s:name:testWorkspace\": latestMapUpdate,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\t\t\tconst itemUpdatedAndItemRemovedUpdate = {\n\t\t\t\t\t\t\t\"s:name:testWorkspace\": itemUpdatedAndItemRemovedMapUpdate,\n\t\t\t\t\t\t};\n\t\t\t\t\t\t// Act\n\t\t\t\t\t\tprocessUpdates(itemUpdatedAndItemRemovedUpdate);\n\t\t\t\t\t\t// Verify\n\t\t\t\t\t\tassertSpies();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\"Notifications update\", () => {\n\t\t\tlet notificationSpy: SinonSpy;\n\t\t\tlet latestSpy: SinonSpy;\n\t\t\tlet attendeeSpy: SinonSpy;\n\t\t\tlet latestMapSpy: SinonSpy;\n\n\t\t\tfunction verify(): void {\n\t\t\t\tverifyState(getTestAttendee(), [\n\t\t\t\t\t{ manager: \"latest\", expectedValue: { x: 1, y: 1, z: 1 } },\n\t\t\t\t\t{\n\t\t\t\t\t\tmanager: \"latestMap\",\n\t\t\t\t\t\texpectedValue: { key1: { a: 1, b: 1 }, key2: { c: 1, d: 1 } },\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t}\n\n\t\t\tfunction setupSpiesAndListeners(): void {\n\t\t\t\tnotificationSpy = spy(verify);\n\t\t\t\tlatestSpy = spy(verify);\n\t\t\t\tattendeeSpy = spy(verify);\n\t\t\t\tlatestMapSpy = spy(verify);\n\n\t\t\t\tnotificationManager.notifications.on(\"newId\", notificationSpy);\n\t\t\t\tlatest.events.on(\"remoteUpdated\", latestSpy);\n\t\t\t\tlatestMap.events.on(\"remoteUpdated\", latestMapSpy);\n\t\t\t\tpresence.attendees.events.on(\"attendeeConnected\", attendeeSpy);\n\t\t\t}\n\n\t\t\tfunction assertSpies(): void {\n\t\t\t\tassert.ok(notificationSpy.calledOnce, \"notification event not fired exactly once\");\n\t\t\t\tassert.ok(latestMapSpy.calledOnce, \"latestMap update event not fired exactly once\");\n\t\t\t\tassert.ok(latestSpy.calledOnce, \"latest update event not fired exactly once\");\n\t\t\t\tassert.ok(attendeeSpy.calledOnce, \"attendee event not fired exactly once\");\n\t\t\t}\n\n\t\t\tit(\"comes before states workspace update\", async () => {\n\t\t\t\t// Setup\n\t\t\t\tsetupSharedStatesWorkspace();\n\t\t\t\tsetupNotificationsWorkspace();\n\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\tconst workspace = {\n\t\t\t\t\t\"n:name:testWorkspace\": notificationsUpdate,\n\t\t\t\t\t\"s:name:testWorkspace\": { ...latestUpdate, ...latestMapUpdate },\n\t\t\t\t};\n\t\t\t\t// Act\n\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t// Verify\n\t\t\t\tassertSpies();\n\t\t\t});\n\n\t\t\tit(\"comes after states workspace update\", async () => {\n\t\t\t\t// Setup\n\t\t\t\tsetupSharedStatesWorkspace();\n\t\t\t\tsetupNotificationsWorkspace();\n\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\tconst workspace = {\n\t\t\t\t\t\"s:name:testWorkspace\": { ...latestUpdate, ...latestMapUpdate },\n\t\t\t\t\t\"n:name:testWorkspace\": notificationsUpdate,\n\t\t\t\t};\n\t\t\t\t// Act\n\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t// Verify\n\t\t\t\tassertSpies();\n\t\t\t});\n\n\t\t\tit(\"comes in between states workspaces\", async () => {\n\t\t\t\t// Setup\n\t\t\t\tsetupMultipleStatesWorkspaces();\n\t\t\t\tsetupNotificationsWorkspace();\n\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\tconst workspace = {\n\t\t\t\t\t\"s:name:testWorkspace1\": latestUpdate,\n\t\t\t\t\t\"n:name:testWorkspace\": notificationsUpdate,\n\t\t\t\t\t\"s:name:testWorkspace2\": latestMapUpdate,\n\t\t\t\t};\n\t\t\t\t// Act\n\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t// Verify\n\t\t\t\tassertSpies();\n\t\t\t});\n\n\t\t\tit(\"within a states workspace\", async () => {\n\t\t\t\t// Setup\n\t\t\t\tsetupSharedStatesWorkspace({ notifications: true });\n\t\t\t\tsetupSpiesAndListeners();\n\t\t\t\tconst workspace = {\n\t\t\t\t\t\"s:name:testWorkspace\": {\n\t\t\t\t\t\t...latestUpdate,\n\t\t\t\t\t\t...notificationsUpdate,\n\t\t\t\t\t\t...latestMapUpdate,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\t// Act\n\t\t\t\tprocessUpdates(workspace);\n\t\t\t\t// Verify\n\t\t\t\tassertSpies();\n\t\t\t});\n\n\t\t\tit(\"from unregistered workspace triggers 'workspaceActivated' event\", async () => {\n\t\t\t\t// Setup\n\t\t\t\tnotificationSpy = spy();\n\t\t\t\tconst workspaceActivatedEventSpy = spy((workspaceAddress: WorkspaceAddress) => {\n\t\t\t\t\t// Once activated, register the notifications workspace and listener for it's event\n\t\t\t\t\tconst notificationsWorkspace = presence.notifications.getWorkspace(\n\t\t\t\t\t\tworkspaceAddress,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttestEvents: Notifications<{ newId: (id: number) => void }>({\n\t\t\t\t\t\t\t\tnewId: (_attendee: Attendee, _id: number) => {},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tnotificationsWorkspace.notifications.testEvents.notifications.on(\n\t\t\t\t\t\t\"newId\",\n\t\t\t\t\t\tnotificationSpy,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tpresence.events.on(\"workspaceActivated\", (workspaceAddress, type) => {\n\t\t\t\t\tif (workspaceAddress === \"name:testWorkspace\" && type === \"Notifications\") {\n\t\t\t\t\t\tworkspaceActivatedEventSpy(workspaceAddress);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tconst workspace = {\n\t\t\t\t\t\"n:name:testWorkspace\": notificationsUpdate,\n\t\t\t\t};\n\t\t\t\t// Act\n\t\t\t\tprocessUpdates(workspace);\n\n\t\t\t\t// Verify\n\t\t\t\tassert.ok(\n\t\t\t\t\tworkspaceActivatedEventSpy.calledOnce,\n\t\t\t\t\t\"workspace activated event not fired\",\n\t\t\t\t);\n\t\t\t\tassert.ok(\n\t\t\t\t\tnotificationSpy.calledOnce,\n\t\t\t\t\t`notification event not fired exactly once ${notificationSpy.callCount}`,\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tit(\"from an unregistered workspace arrives with state updates\", async () => {\n\t\t\t\tsetupMultipleStatesWorkspaces();\n\n\t\t\t\tconst initialWorkspaceUpdate = {\n\t\t\t\t\t\"s:name:testWorkspace1\": latestUpdate,\n\t\t\t\t\t\"s:name:testWorkspace2\": latestMapUpdate,\n\t\t\t\t};\n\t\t\t\tconst secondWorkspaceUpdate = {\n\t\t\t\t\t\"s:name:testWorkspace1\": latestUpdateRev2,\n\t\t\t\t\t\"n:name:testWorkspace\": notificationsUpdate,\n\t\t\t\t\t\"s:name:testWorkspace2\": itemUpdatedAndItemRemovedMapUpdate,\n\t\t\t\t};\n\n\t\t\t\tpresence.events.on(\"workspaceActivated\", (_, type) => {\n\t\t\t\t\tif (type === \"Notifications\") {\n\t\t\t\t\t\t// Verify initial state maintains consistency\n\t\t\t\t\t\tverifyState(getTestAttendee(), [\n\t\t\t\t\t\t\t{ manager: \"latest\", expectedValue: { x: 1, y: 1, z: 1 } },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmanager: \"latestMap\",\n\t\t\t\t\t\t\t\texpectedValue: { key1: { a: 1, b: 1 }, key2: { c: 1, d: 1 } },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t// Act\n\t\t\t\tprocessUpdates(initialWorkspaceUpdate);\n\t\t\t\tprocessUpdates(secondWorkspaceUpdate);\n\n\t\t\t\t// Verify\n\t\t\t\tverifyState(getTestAttendee(), [\n\t\t\t\t\t{ manager: \"latest\", expectedValue: { x: 2, y: 2, z: 2 } },\n\t\t\t\t\t{\n\t\t\t\t\t\tmanager: \"latestMap\",\n\t\t\t\t\t\texpectedValue: { key1: { a: 2, b: 2 }, key2: undefined },\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t});\n\t\t});\n\t});\n});\n"]}
@@ -1,210 +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.checkCompiles = void 0;
8
- const node_assert_1 = require("node:assert");
9
- const test_1 = require("@fluid-internal/presence-runtime/internal/test");
10
- const states_1 = require("@fluid-internal/presence-runtime/states");
11
- const broadcastControlsTests_js_1 = require("./broadcastControlsTests.js");
12
- const mockEphemeralRuntime_js_1 = require("./mockEphemeralRuntime.js");
13
- const testUtils_js_1 = require("./testUtils.js");
14
- const testWorkspaceName = "name:testWorkspaceA";
15
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
16
- function createLatestMapManager(presence, valueControlSettings) {
17
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
18
- fixedMap: states_1.StateFactory.latestMap({
19
- local: { key1: { x: 0, y: 0 }, key2: { ref: "default", someId: 0 } },
20
- settings: valueControlSettings,
21
- }),
22
- });
23
- return workspace.states.fixedMap;
24
- }
25
- describe("Presence/States", () => {
26
- describe("LatestMap", () => {
27
- /**
28
- * See {@link checkCompiles} below
29
- */
30
- it("API use compiles", () => { });
31
- (0, broadcastControlsTests_js_1.addControlsTests)(createLatestMapManager);
32
- function setupMapValueManager() {
33
- const presence = (0, test_1.createPresenceManager)(new mockEphemeralRuntime_js_1.MockEphemeralRuntime());
34
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
35
- fixedMap: states_1.StateFactory.latestMap({ local: { key1: { x: 0, y: 0 } } }),
36
- });
37
- return workspace.states.fixedMap;
38
- }
39
- it("localItemUpdated event is fired with new value when local value is updated", () => {
40
- // Setup
41
- const mapVM = setupMapValueManager();
42
- let localUpdateCount = 0;
43
- mapVM.events.on("localItemUpdated", (update) => {
44
- localUpdateCount++;
45
- node_assert_1.strict.strictEqual(update.key, "key1");
46
- node_assert_1.strict.deepStrictEqual(update.value, { x: 1, y: 2 });
47
- });
48
- // Act & Verify
49
- mapVM.local.set("key1", { x: 1, y: 2 });
50
- node_assert_1.strict.strictEqual(localUpdateCount, 1);
51
- });
52
- it("localItemRemoved event is fired with new value when local value is deleted", () => {
53
- // Setup
54
- const mapVM = setupMapValueManager();
55
- let localRemovalCount = 0;
56
- mapVM.events.on("localItemRemoved", (update) => {
57
- localRemovalCount++;
58
- node_assert_1.strict.strictEqual(update.key, "key1");
59
- });
60
- // Act & Verify
61
- mapVM.local.delete("key1");
62
- node_assert_1.strict.strictEqual(localRemovalCount, 1);
63
- });
64
- it(".presence provides Presence it was created under", () => {
65
- const presence = (0, test_1.createPresenceManager)(new mockEphemeralRuntime_js_1.MockEphemeralRuntime());
66
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
67
- fixedMap: states_1.StateFactory.latestMap({ local: { key1: { x: 0, y: 0 } } }),
68
- });
69
- node_assert_1.strict.strictEqual(workspace.states.fixedMap.presence, presence);
70
- });
71
- });
72
- });
73
- /**
74
- * Check that the code compiles.
75
- */
76
- function checkCompiles() {
77
- const fixedMapAnyKeyConfiguration = states_1.StateFactory.latestMap();
78
- const validatedMapSpecificKeyConfiguration = states_1.StateFactory.latestMap({
79
- local: {
80
- key1: { x: 0, y: 0 },
81
- key2: { ref: "default", someId: 0 },
82
- },
83
- validator: (data) => data,
84
- });
85
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
86
- const presence = {};
87
- const statesWorkspace = presence.states.getWorkspace("name:testStatesWorkspaceWithLatestMap", {
88
- fixedMap: states_1.StateFactory.latestMap({
89
- local: {
90
- key1: { x: 0, y: 0 },
91
- key2: { ref: "default", someId: 0 },
92
- },
93
- }),
94
- validatedMap: states_1.StateFactory.latestMap({
95
- local: {
96
- key1: { x: 0, y: 0 },
97
- key2: { ref: "default", someId: 0 },
98
- },
99
- validator: (data) => data,
100
- }),
101
- otherMap: fixedMapAnyKeyConfiguration,
102
- anotherMap: fixedMapAnyKeyConfiguration,
103
- specificValidatedMap: validatedMapSpecificKeyConfiguration,
104
- });
105
- // Workaround ts(2775): Assertions require every name in the call target to be declared with an explicit type annotation.
106
- const workspace = statesWorkspace;
107
- const props = workspace.states;
108
- props.fixedMap.local.get("key1");
109
- // @ts-expect-error with inferred keys only those named it init are accessible
110
- props.fixedMap.local.get("key3");
111
- props.fixedMap.local.set("key2", { x: 0, y: 2 });
112
- props.fixedMap.local.set("key2", { ref: "string", someId: -1 });
113
- // @ts-expect-error with inferred type `undefined` optional values are errors
114
- props.fixedMap.local.set("key2", { x: undefined, y: undefined, ref: "string", someId: -1 });
115
- // @ts-expect-error with inferred type partial values are errors
116
- props.fixedMap.local.set("key2", { x: 0 });
117
- // @ts-expect-error with inferred heterogenous type mixed type values are errors
118
- props.fixedMap.local.set("key2", { x: 0, y: 2, ref: "a", someId: 3 });
119
- for (const key of props.fixedMap.local.keys()) {
120
- const value = props.fixedMap.local.get(key);
121
- console.log(key, value);
122
- }
123
- (0, testUtils_js_1.assertIdenticalTypes)(props.validatedMap, (0, testUtils_js_1.createInstanceOf)());
124
- (0, testUtils_js_1.assertIdenticalTypes)(props.fixedMap, (0, testUtils_js_1.createInstanceOf)());
125
- // Get a reference to one of the remote attendees
126
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
127
- const attendee2 = [...props.validatedMap.getStateAttendees()].find((attendee) => attendee !== presence.attendees.getMyself());
128
- // Get a remote validated value
129
- const latestMapData = props.validatedMap.getRemote(attendee2);
130
- // Get a value from the validated map
131
- const keyValue = latestMapData.get("key2");
132
- if (keyValue === undefined) {
133
- throw new Error("'key2' not found in LatestMap");
134
- }
135
- const validatedKeyValue = keyValue.value;
136
- // @ts-expect-error because validatedKeyValue is an accessor, not a value
137
- // Type '() =>
138
- // { readonly x: number; readonly y: number; readonly ref?: never; readonly someId?: never; } | { readonly ref:
139
- // string; readonly someId: number; readonly x?: never; readonly y?: never; } | undefined'
140
- // is not assignable to type 'TestMapData | undefined'.
141
- (0, testUtils_js_1.assertIdenticalTypes)(validatedKeyValue, (0, testUtils_js_1.createInstanceOf)());
142
- // The key value should be a function that returns a value.
143
- const validatedValue = validatedKeyValue?.();
144
- if (validatedValue === undefined) {
145
- throw new Error("Value is not valid according to the validator function.");
146
- }
147
- logClientValue({ attendee: attendee2, key: "key2", value: validatedValue });
148
- workspace.add("pointers", states_1.StateFactory.latestMap({ local: {} }));
149
- const pointers = workspace.states.pointers;
150
- const localPointers = pointers.local;
151
- function logClientValue({ attendee, key, value, }) {
152
- console.log(attendee.attendeeId, key, value);
153
- }
154
- localPointers.set("pen", { x: 1, y: 2 });
155
- const pointerItemUpdatedOff = pointers.events.on("remoteItemUpdated", logClientValue);
156
- pointerItemUpdatedOff();
157
- for (const attendee of pointers.getStateAttendees()) {
158
- const items = pointers.getRemote(attendee);
159
- for (const [key, { value }] of items.entries()) {
160
- logClientValue({ attendee, key, value });
161
- }
162
- }
163
- for (const { attendee, items } of pointers.getRemotes()) {
164
- for (const [key, { value }] of items.entries()) {
165
- logClientValue({ attendee, key, value });
166
- }
167
- }
168
- pointers.events.on("remoteItemRemoved", ({ attendee, key }) => logClientValue({ attendee, key, value: "<removed>" }));
169
- pointers.events.on("remoteUpdated", ({ attendee, items }) => {
170
- for (const [key, { value }] of items.entries()) {
171
- logClientValue({ attendee, key, value });
172
- }
173
- });
174
- // ----------------------------------
175
- // primitive and null value support
176
- workspace.add("primitiveMap", states_1.StateFactory.latestMap({
177
- local: {
178
- // eslint-disable-next-line unicorn/no-null
179
- null: null,
180
- string: "string",
181
- number: 0,
182
- boolean: true,
183
- },
184
- }));
185
- const localPrimitiveMap = workspace.states.primitiveMap.local;
186
- // map value types are not matched to specific key
187
- localPrimitiveMap.set("string", 1);
188
- // latestMap should infer that `true` or `false` is a valid value
189
- // without use of `true as const` or explicit specification.
190
- // That happened under PR #24752 unexpectedly. Presumably from some
191
- // additional inference complication where `& JsonDeserialized<T>`
192
- // was used in `LatestMapArguments` that was relaxed in PR #247??. !!! <- to fill in
193
- // Caller can always use explicit generic specification to be
194
- // completely clear about the types.
195
- localPrimitiveMap.set("number", false);
196
- // eslint-disable-next-line unicorn/no-null
197
- localPrimitiveMap.set("boolean", null);
198
- localPrimitiveMap.set("null", "null");
199
- // @ts-expect-error with inferred keys only those named in init are accessible
200
- localPrimitiveMap.set("key3", "value");
201
- // @ts-expect-error value of type value is not assignable
202
- localPrimitiveMap.set("null", { value: "value" });
203
- // Adding captured LatestMapConfigurations's to workspace
204
- workspace.add("otherMap", fixedMapAnyKeyConfiguration);
205
- workspace.add("specificValidatedMap", validatedMapSpecificKeyConfiguration);
206
- // @ts-expect-error Argument of type '"yetAnotherMap"' is not assignable to parameter of type '"specificValidatedMap"'
207
- workspace.add("yetAnotherMap", validatedMapSpecificKeyConfiguration);
208
- }
209
- exports.checkCompiles = checkCompiles;
210
- //# sourceMappingURL=latestMapValueManager.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"latestMapValueManager.spec.js","sourceRoot":"","sources":["../../../src/states/test/latestMapValueManager.spec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAA+C;AAY/C,yEAAuF;AACvF,oEAAuE;AAEvE,2EAA+D;AAC/D,uEAAiE;AACjE,iDAAwE;AAExE,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEhD,4EAA4E;AAC5E,SAAS,sBAAsB,CAC9B,QAAkB,EAClB,oBAA+C;IAE/C,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE;QACjE,QAAQ,EAAE,qBAAY,CAAC,SAAS,CAAC;YAChC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE;YACpE,QAAQ,EAAE,oBAAoB;SAC9B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC;AAClC,CAAC;AAED,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAChC,QAAQ,CAAC,WAAW,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2B,CAAC,CAAC;IACvD,SAAS,CAAC,GAAG,CAAC,sBAAsB,EAAE,oCAAoC,CAAC,CAAC;IAC5E,sHAAsH;IACtH,SAAS,CAAC,GAAG,CAAC,eAAe,EAAE,oCAAoC,CAAC,CAAC;AACtE,CAAC;AAtMD,sCAsMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport type {\n\tBroadcastControlSettings,\n\tLatestMapRaw,\n\tLatestMapItemUpdatedClientData,\n\tPresence,\n\tRawValueAccessor,\n\tLatestMap,\n\tLatestMapConfiguration,\n} from \"@fluid-internal/presence-definitions\";\n\nimport { createPresenceManager } from \"@fluid-internal/presence-runtime/internal/test\";\nimport { StateFactory } from \"@fluid-internal/presence-runtime/states\";\n\nimport { addControlsTests } from \"./broadcastControlsTests.js\";\nimport { MockEphemeralRuntime } from \"./mockEphemeralRuntime.js\";\nimport { assertIdenticalTypes, createInstanceOf } from \"./testUtils.js\";\n\nconst testWorkspaceName = \"name:testWorkspaceA\";\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction createLatestMapManager(\n\tpresence: Presence,\n\tvalueControlSettings?: BroadcastControlSettings,\n) {\n\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\tfixedMap: StateFactory.latestMap({\n\t\t\tlocal: { key1: { x: 0, y: 0 }, key2: { ref: \"default\", someId: 0 } },\n\t\t\tsettings: valueControlSettings,\n\t\t}),\n\t});\n\treturn workspace.states.fixedMap;\n}\n\ndescribe(\"Presence/States\", () => {\n\tdescribe(\"LatestMap\", () => {\n\t\t/**\n\t\t * See {@link checkCompiles} below\n\t\t */\n\t\tit(\"API use compiles\", () => {});\n\n\t\taddControlsTests(createLatestMapManager);\n\n\t\tfunction setupMapValueManager(): LatestMapRaw<\n\t\t\t{\n\t\t\t\tx: number;\n\t\t\t\ty: number;\n\t\t\t},\n\t\t\t`key${number}`\n\t\t> {\n\t\t\tconst presence = createPresenceManager(new MockEphemeralRuntime());\n\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\tfixedMap: StateFactory.latestMap({ local: { key1: { x: 0, y: 0 } } }),\n\t\t\t});\n\t\t\treturn workspace.states.fixedMap;\n\t\t}\n\n\t\tit(\"localItemUpdated event is fired with new value when local value is updated\", () => {\n\t\t\t// Setup\n\t\t\tconst mapVM = setupMapValueManager();\n\n\t\t\tlet localUpdateCount = 0;\n\t\t\tmapVM.events.on(\"localItemUpdated\", (update) => {\n\t\t\t\tlocalUpdateCount++;\n\t\t\t\tassert.strictEqual(update.key, \"key1\");\n\t\t\t\tassert.deepStrictEqual(update.value, { x: 1, y: 2 });\n\t\t\t});\n\n\t\t\t// Act & Verify\n\t\t\tmapVM.local.set(\"key1\", { x: 1, y: 2 });\n\t\t\tassert.strictEqual(localUpdateCount, 1);\n\t\t});\n\n\t\tit(\"localItemRemoved event is fired with new value when local value is deleted\", () => {\n\t\t\t// Setup\n\t\t\tconst mapVM = setupMapValueManager();\n\n\t\t\tlet localRemovalCount = 0;\n\t\t\tmapVM.events.on(\"localItemRemoved\", (update) => {\n\t\t\t\tlocalRemovalCount++;\n\t\t\t\tassert.strictEqual(update.key, \"key1\");\n\t\t\t});\n\n\t\t\t// Act & Verify\n\t\t\tmapVM.local.delete(\"key1\");\n\t\t\tassert.strictEqual(localRemovalCount, 1);\n\t\t});\n\n\t\tit(\".presence provides Presence it was created under\", () => {\n\t\t\tconst presence = createPresenceManager(new MockEphemeralRuntime());\n\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\tfixedMap: StateFactory.latestMap({ local: { key1: { x: 0, y: 0 } } }),\n\t\t\t});\n\n\t\t\tassert.strictEqual(workspace.states.fixedMap.presence, presence);\n\t\t});\n\t});\n});\n\n// ---- test (example) code ----\n\ntype TestMapData =\n\t| { x: number; y: number; ref?: never; someId?: never }\n\t| { ref: string; someId: number; x?: never; y?: never };\n\n/**\n * Check that the code compiles.\n */\nexport function checkCompiles(): void {\n\tconst fixedMapAnyKeyConfiguration = StateFactory.latestMap<TestMapData>();\n\tconst validatedMapSpecificKeyConfiguration: LatestMapConfiguration<\n\t\tTestMapData,\n\t\t\"key1\" | \"key2\",\n\t\t// May only be set to specific workspace key \"specificValidatedMap\"\n\t\t\"specificValidatedMap\"\n\t> = StateFactory.latestMap({\n\t\tlocal: {\n\t\t\tkey1: { x: 0, y: 0 },\n\t\t\tkey2: { ref: \"default\", someId: 0 },\n\t\t},\n\t\tvalidator: (data) => data as TestMapData,\n\t});\n\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tconst presence = {} as Presence;\n\tconst statesWorkspace = presence.states.getWorkspace(\n\t\t\"name:testStatesWorkspaceWithLatestMap\",\n\t\t{\n\t\t\tfixedMap: StateFactory.latestMap({\n\t\t\t\tlocal: {\n\t\t\t\t\tkey1: { x: 0, y: 0 },\n\t\t\t\t\tkey2: { ref: \"default\", someId: 0 },\n\t\t\t\t},\n\t\t\t}),\n\t\t\tvalidatedMap: StateFactory.latestMap({\n\t\t\t\tlocal: {\n\t\t\t\t\tkey1: { x: 0, y: 0 },\n\t\t\t\t\tkey2: { ref: \"default\", someId: 0 },\n\t\t\t\t},\n\t\t\t\tvalidator: (data) => data as TestMapData,\n\t\t\t}),\n\t\t\totherMap: fixedMapAnyKeyConfiguration,\n\t\t\tanotherMap: fixedMapAnyKeyConfiguration,\n\t\t\tspecificValidatedMap: validatedMapSpecificKeyConfiguration,\n\t\t},\n\t);\n\t// Workaround ts(2775): Assertions require every name in the call target to be declared with an explicit type annotation.\n\tconst workspace: typeof statesWorkspace = statesWorkspace;\n\tconst props = workspace.states;\n\n\tprops.fixedMap.local.get(\"key1\");\n\t// @ts-expect-error with inferred keys only those named it init are accessible\n\tprops.fixedMap.local.get(\"key3\");\n\n\tprops.fixedMap.local.set(\"key2\", { x: 0, y: 2 });\n\tprops.fixedMap.local.set(\"key2\", { ref: \"string\", someId: -1 });\n\t// @ts-expect-error with inferred type `undefined` optional values are errors\n\tprops.fixedMap.local.set(\"key2\", { x: undefined, y: undefined, ref: \"string\", someId: -1 });\n\t// @ts-expect-error with inferred type partial values are errors\n\tprops.fixedMap.local.set(\"key2\", { x: 0 });\n\t// @ts-expect-error with inferred heterogenous type mixed type values are errors\n\tprops.fixedMap.local.set(\"key2\", { x: 0, y: 2, ref: \"a\", someId: 3 });\n\n\tfor (const key of props.fixedMap.local.keys()) {\n\t\tconst value = props.fixedMap.local.get(key);\n\t\tconsole.log(key, value);\n\t}\n\n\tassertIdenticalTypes(\n\t\tprops.validatedMap,\n\t\tcreateInstanceOf<LatestMap<TestMapData, \"key1\" | \"key2\">>(),\n\t);\n\n\tassertIdenticalTypes(\n\t\tprops.fixedMap,\n\t\tcreateInstanceOf<LatestMapRaw<TestMapData, \"key1\" | \"key2\">>(),\n\t);\n\n\t// Get a reference to one of the remote attendees\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst attendee2 = [...props.validatedMap.getStateAttendees()].find(\n\t\t(attendee) => attendee !== presence.attendees.getMyself(),\n\t)!;\n\n\t// Get a remote validated value\n\tconst latestMapData = props.validatedMap.getRemote(attendee2);\n\n\t// Get a value from the validated map\n\tconst keyValue = latestMapData.get(\"key2\");\n\tif (keyValue === undefined) {\n\t\tthrow new Error(\"'key2' not found in LatestMap\");\n\t}\n\n\tconst validatedKeyValue = keyValue.value;\n\n\t// @ts-expect-error because validatedKeyValue is an accessor, not a value\n\t// Type '() =>\n\t// { readonly x: number; readonly y: number; readonly ref?: never; readonly someId?: never; } | { readonly ref:\n\t// string; readonly someId: number; readonly x?: never; readonly y?: never; } | undefined'\n\t// is not assignable to type 'TestMapData | undefined'.\n\tassertIdenticalTypes(validatedKeyValue, createInstanceOf<TestMapData | undefined>());\n\n\t// The key value should be a function that returns a value.\n\tconst validatedValue: TestMapData | undefined = validatedKeyValue?.();\n\n\tif (validatedValue === undefined) {\n\t\tthrow new Error(\"Value is not valid according to the validator function.\");\n\t}\n\tlogClientValue({ attendee: attendee2, key: \"key2\", value: validatedValue });\n\n\t// ----------------------------------\n\t// pointers data\n\n\tinterface PointerData {\n\t\tx: number;\n\t\ty: number;\n\t\tpressure?: number;\n\t\ttilt?: number;\n\t}\n\n\tworkspace.add(\"pointers\", StateFactory.latestMap<PointerData>({ local: {} }));\n\n\tconst pointers = workspace.states.pointers;\n\tconst localPointers = pointers.local;\n\n\tfunction logClientValue<T>({\n\t\tattendee,\n\t\tkey,\n\t\tvalue,\n\t}: Pick<\n\t\tLatestMapItemUpdatedClientData<T, string, RawValueAccessor<T>>,\n\t\t\"attendee\" | \"key\" | \"value\"\n\t>): void {\n\t\tconsole.log(attendee.attendeeId, key, value);\n\t}\n\n\tlocalPointers.set(\"pen\", { x: 1, y: 2 });\n\n\tconst pointerItemUpdatedOff = pointers.events.on(\"remoteItemUpdated\", logClientValue);\n\tpointerItemUpdatedOff();\n\n\tfor (const attendee of pointers.getStateAttendees()) {\n\t\tconst items = pointers.getRemote(attendee);\n\t\tfor (const [key, { value }] of items.entries()) {\n\t\t\tlogClientValue({ attendee, key, value });\n\t\t}\n\t}\n\n\tfor (const { attendee, items } of pointers.getRemotes()) {\n\t\tfor (const [key, { value }] of items.entries()) {\n\t\t\tlogClientValue({ attendee, key, value });\n\t\t}\n\t}\n\n\tpointers.events.on(\"remoteItemRemoved\", ({ attendee, key }) =>\n\t\tlogClientValue<string>({ attendee, key, value: \"<removed>\" }),\n\t);\n\n\tpointers.events.on(\"remoteUpdated\", ({ attendee, items }) => {\n\t\tfor (const [key, { value }] of items.entries()) {\n\t\t\tlogClientValue({ attendee, key, value });\n\t\t}\n\t});\n\n\t// ----------------------------------\n\t// primitive and null value support\n\n\tworkspace.add(\n\t\t\"primitiveMap\",\n\t\tStateFactory.latestMap({\n\t\t\tlocal: {\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\tnull: null,\n\t\t\t\tstring: \"string\",\n\t\t\t\tnumber: 0,\n\t\t\t\tboolean: true,\n\t\t\t},\n\t\t}),\n\t);\n\n\tconst localPrimitiveMap = workspace.states.primitiveMap.local;\n\n\t// map value types are not matched to specific key\n\tlocalPrimitiveMap.set(\"string\", 1);\n\t// latestMap should infer that `true` or `false` is a valid value\n\t// without use of `true as const` or explicit specification.\n\t// That happened under PR #24752 unexpectedly. Presumably from some\n\t// additional inference complication where `& JsonDeserialized<T>`\n\t// was used in `LatestMapArguments` that was relaxed in PR #247??. !!! <- to fill in\n\t// Caller can always use explicit generic specification to be\n\t// completely clear about the types.\n\tlocalPrimitiveMap.set(\"number\", false);\n\t// eslint-disable-next-line unicorn/no-null\n\tlocalPrimitiveMap.set(\"boolean\", null);\n\tlocalPrimitiveMap.set(\"null\", \"null\");\n\n\t// @ts-expect-error with inferred keys only those named in init are accessible\n\tlocalPrimitiveMap.set(\"key3\", \"value\");\n\t// @ts-expect-error value of type value is not assignable\n\tlocalPrimitiveMap.set(\"null\", { value: \"value\" });\n\n\t// Adding captured LatestMapConfigurations's to workspace\n\tworkspace.add(\"otherMap\", fixedMapAnyKeyConfiguration);\n\tworkspace.add(\"specificValidatedMap\", validatedMapSpecificKeyConfiguration);\n\t// @ts-expect-error Argument of type '\"yetAnotherMap\"' is not assignable to parameter of type '\"specificValidatedMap\"'\n\tworkspace.add(\"yetAnotherMap\", validatedMapSpecificKeyConfiguration);\n}\n"]}
@@ -1,193 +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.checkCompiles = void 0;
8
- const node_assert_1 = require("node:assert");
9
- const test_1 = require("@fluid-internal/presence-runtime/internal/test");
10
- const states_1 = require("@fluid-internal/presence-runtime/states");
11
- const broadcastControlsTests_js_1 = require("./broadcastControlsTests.js");
12
- const mockEphemeralRuntime_js_1 = require("./mockEphemeralRuntime.js");
13
- const testUtils_js_1 = require("./testUtils.js");
14
- const testWorkspaceName = "name:testWorkspaceA";
15
- /* eslint-disable unicorn/no-null -- API null support must be tested */
16
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
17
- function createLatestManager(presence, valueControlSettings) {
18
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
19
- camera: states_1.StateFactory.latest({
20
- local: { x: 0, y: 0, z: 0 },
21
- settings: valueControlSettings,
22
- }),
23
- });
24
- return workspace.states.camera;
25
- }
26
- describe("Presence/States", () => {
27
- describe("Latest", () => {
28
- /**
29
- * See {@link checkCompiles} below
30
- */
31
- it("API use compiles", () => { });
32
- describe("when initialized", () => {
33
- let presence;
34
- beforeEach(() => {
35
- presence = (0, test_1.createPresenceManager)(new mockEphemeralRuntime_js_1.MockEphemeralRuntime());
36
- });
37
- it("can set and get empty object as initial value", () => {
38
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
39
- obj: states_1.StateFactory.latest({ local: {} }),
40
- });
41
- node_assert_1.strict.deepStrictEqual(workspace.states.obj.local, {});
42
- });
43
- it("can set and get object with properties as initial value", () => {
44
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
45
- obj: states_1.StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),
46
- });
47
- node_assert_1.strict.deepStrictEqual(workspace.states.obj.local, { x: 0, y: 0, z: 0 });
48
- });
49
- it("can set and get empty array as initial value", () => {
50
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
51
- arr: states_1.StateFactory.latest({ local: [] }),
52
- });
53
- node_assert_1.strict.deepStrictEqual(workspace.states.arr.local, []);
54
- });
55
- it("can set and get array with elements as initial value", () => {
56
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
57
- arr: states_1.StateFactory.latest({ local: [1, 2, 3] }),
58
- });
59
- node_assert_1.strict.deepStrictEqual(workspace.states.arr.local, [1, 2, 3]);
60
- });
61
- it("can set and get null as initial value", () => {
62
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
63
- nullable: states_1.StateFactory.latest({ local: null }),
64
- });
65
- node_assert_1.strict.deepStrictEqual(workspace.states.nullable.local, null);
66
- });
67
- it("can set and get inferred nullable type as initial value", () => {
68
- // Setup
69
- // Use a function to generate the initial value so that TypeScript
70
- // can't statically infer the type as exactly null.
71
- function generateInitialValue() {
72
- return { x: 0, y: 0 };
73
- }
74
- const initialValue = generateInitialValue();
75
- // Act
76
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
77
- nullable: states_1.StateFactory.latest({ local: initialValue }),
78
- });
79
- // Verify
80
- node_assert_1.strict.deepStrictEqual(workspace.states.nullable.local, initialValue);
81
- });
82
- it(".presence provides Presence it was created under", () => {
83
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
84
- camera: states_1.StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),
85
- });
86
- node_assert_1.strict.strictEqual(workspace.states.camera.presence, presence);
87
- });
88
- it("can set and get null as modified local value", () => {
89
- // Setup
90
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
91
- nullable: states_1.StateFactory.latest({
92
- local: { x: 0, y: 0 },
93
- }),
94
- });
95
- // Act and Verify
96
- workspace.states.nullable.local = null;
97
- node_assert_1.strict.deepStrictEqual(workspace.states.nullable.local, null);
98
- });
99
- });
100
- (0, broadcastControlsTests_js_1.addControlsTests)(createLatestManager);
101
- it("localUpdate event is fired with new value when local value is updated", () => {
102
- // Setup
103
- const presence = (0, test_1.createPresenceManager)(new mockEphemeralRuntime_js_1.MockEphemeralRuntime());
104
- const workspace = presence.states.getWorkspace(testWorkspaceName, {
105
- camera: states_1.StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),
106
- });
107
- const camera = workspace.states.camera;
108
- let localUpdateCount = 0;
109
- camera.events.on("localUpdated", (update) => {
110
- localUpdateCount++;
111
- node_assert_1.strict.deepStrictEqual(update.value, { x: 1, y: 2, z: 3 });
112
- });
113
- // Act & Verify
114
- camera.local = { x: 1, y: 2, z: 3 };
115
- node_assert_1.strict.strictEqual(localUpdateCount, 1);
116
- });
117
- });
118
- });
119
- // ---- test (example) code ----
120
- /**
121
- * Check that the code compiles.
122
- */
123
- function checkCompiles() {
124
- const latestCountAnyKeyConfiguration = states_1.StateFactory.latest({ local: { count: 0 } });
125
- const latestCountSpecificKeyConfiguration = states_1.StateFactory.latest({ local: { count: 0 } });
126
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
127
- const presence = {};
128
- const statesWorkspace = presence.states.getWorkspace("name:testStatesWorkspaceWithLatest", {
129
- cursor: states_1.StateFactory.latest({ local: { x: 0, y: 0 } }),
130
- camera: states_1.StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),
131
- nullablePoint: states_1.StateFactory.latest({ local: null }),
132
- validated: states_1.StateFactory.latest({
133
- local: { num: 22 },
134
- validator: (data) => data,
135
- }),
136
- count0: latestCountAnyKeyConfiguration,
137
- count1: latestCountAnyKeyConfiguration,
138
- myCount: latestCountSpecificKeyConfiguration,
139
- });
140
- // Workaround ts(2775): Assertions require every name in the call target to be declared with an explicit type annotation.
141
- const workspace = statesWorkspace;
142
- const props = workspace.states;
143
- workspace.add("caret", states_1.StateFactory.latest({ local: { id: "", pos: 0 } }));
144
- const fakeAdd = workspace.states.caret.local.pos + props.camera.local.z + props.cursor.local.x;
145
- console.log(fakeAdd);
146
- // @ts-expect-error local may be set wholly, but partially it is readonly
147
- workspace.states.caret.local.pos = 0;
148
- function logClientValue({ attendee, value, }) {
149
- console.log(attendee.attendeeId, value);
150
- }
151
- function logRemoteValue({ attendee, value, }) {
152
- console.log(attendee.attendeeId, value());
153
- }
154
- // Create new cursor state
155
- const cursor = props.cursor;
156
- // Update our cursor position
157
- cursor.local = { x: 1, y: 2 };
158
- // Set nullable point to non-null value
159
- props.nullablePoint.local = { x: 10, y: -2 };
160
- // Listen to others cursor updates
161
- const cursorUpdatedOff = cursor.events.on("remoteUpdated", ({ attendee, value }) => console.log(`attendee ${attendee.attendeeId}'s cursor is now at (${value.x},${value.y})`));
162
- cursorUpdatedOff();
163
- for (const attendee of cursor.getStateAttendees()) {
164
- logClientValue({ attendee, ...cursor.getRemote(attendee) });
165
- }
166
- // Enumerate all cursor values
167
- for (const { attendee, value } of cursor.getRemotes()) {
168
- logClientValue({ attendee, value });
169
- }
170
- // Get a reference to one of the remote attendees
171
- const attendee2 = [...cursor.getStateAttendees()].find((attendee) => attendee !== presence.attendees.getMyself());
172
- (0, node_assert_1.strict)(attendee2 !== undefined);
173
- // Get a remote raw value
174
- const remoteCursor = cursor.getRemote(attendee2);
175
- logClientValue({ attendee: attendee2, value: remoteCursor.value });
176
- (0, testUtils_js_1.assertIdenticalTypes)(props.cursor, (0, testUtils_js_1.createInstanceOf)());
177
- (0, testUtils_js_1.assertIdenticalTypes)(props.validated, (0, testUtils_js_1.createInstanceOf)());
178
- // Get a remote validated value
179
- const latestData = props.validated.getRemote(attendee2);
180
- // The next line correctly does not compile because the value argument must be a RawValueAccessor
181
- // @ts-expect-error Type '() => { readonly num: number; } | undefined' is not assignable to type 'never'.
182
- logClientValue({ attendee: attendee2, value: latestData.value });
183
- // This line correctly compiles because logRemoteValue expects a ProxiedValueAccessor
184
- logRemoteValue({ attendee: attendee2, value: latestData.value });
185
- // Adding captured LatestConfigurations's to workspace
186
- workspace.add("myCount", latestCountAnyKeyConfiguration);
187
- workspace.add("otherCount", latestCountAnyKeyConfiguration);
188
- // @ts-expect-error Argument of type '"otherCount"' is not assignable to parameter of type '"myCount"'
189
- workspace.add("otherCount", latestCountSpecificKeyConfiguration);
190
- }
191
- exports.checkCompiles = checkCompiles;
192
- /* eslint-enable unicorn/no-null */
193
- //# sourceMappingURL=latestValueManager.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"latestValueManager.spec.js","sourceRoot":"","sources":["../../../src/states/test/latestValueManager.spec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAA+C;AAY/C,yEAAuF;AACvF,oEAAuE;AAEvE,2EAA+D;AAC/D,uEAAiE;AACjE,iDAAwE;AAExE,MAAM,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;IAEnE,IAAA,mCAAoB,EAAC,KAAK,CAAC,MAAM,EAAE,IAAA,+BAAgB,GAAuC,CAAC,CAAC;IAC5F,IAAA,mCAAoB,EAAC,KAAK,CAAC,SAAS,EAAE,IAAA,+BAAgB,GAA2B,CAAC,CAAC;IAEnF,+BAA+B;IAC/B,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAExD,iGAAiG;IACjG,yGAAyG;IACzG,cAAc,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;IAEjE,qFAAqF;IACrF,cAAc,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;IAEjE,sDAAsD;IACtD,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,8BAA8B,CAAC,CAAC;IACzD,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,8BAA8B,CAAC,CAAC;IAC5D,sGAAsG;IACtG,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,mCAAmC,CAAC,CAAC;AAClE,CAAC;AAvGD,sCAuGC;AAED,mCAAmC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport type {\n\tBroadcastControlSettings,\n\tLatest,\n\tLatestClientData,\n\tLatestRaw,\n\tLatestRawConfiguration,\n\tPresence,\n\tRawValueAccessor,\n} from \"@fluid-internal/presence-definitions\";\n\nimport { createPresenceManager } from \"@fluid-internal/presence-runtime/internal/test\";\nimport { StateFactory } from \"@fluid-internal/presence-runtime/states\";\n\nimport { addControlsTests } from \"./broadcastControlsTests.js\";\nimport { MockEphemeralRuntime } from \"./mockEphemeralRuntime.js\";\nimport { assertIdenticalTypes, createInstanceOf } from \"./testUtils.js\";\n\nconst testWorkspaceName = \"name:testWorkspaceA\";\n\n/* eslint-disable unicorn/no-null -- API null support must be tested */\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction createLatestManager(\n\tpresence: Presence,\n\tvalueControlSettings?: BroadcastControlSettings,\n) {\n\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\tcamera: StateFactory.latest({\n\t\t\tlocal: { x: 0, y: 0, z: 0 },\n\t\t\tsettings: valueControlSettings,\n\t\t}),\n\t});\n\treturn workspace.states.camera;\n}\n\ndescribe(\"Presence/States\", () => {\n\tdescribe(\"Latest\", () => {\n\t\t/**\n\t\t * See {@link checkCompiles} below\n\t\t */\n\t\tit(\"API use compiles\", () => {});\n\n\t\tdescribe(\"when initialized\", () => {\n\t\t\tlet presence: Presence;\n\n\t\t\tbeforeEach(() => {\n\t\t\t\tpresence = createPresenceManager(new MockEphemeralRuntime());\n\t\t\t});\n\n\t\t\tit(\"can set and get empty object as initial value\", () => {\n\t\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\t\tobj: StateFactory.latest({ local: {} }),\n\t\t\t\t});\n\t\t\t\tassert.deepStrictEqual(workspace.states.obj.local, {});\n\t\t\t});\n\n\t\t\tit(\"can set and get object with properties as initial value\", () => {\n\t\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\t\tobj: StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),\n\t\t\t\t});\n\t\t\t\tassert.deepStrictEqual(workspace.states.obj.local, { x: 0, y: 0, z: 0 });\n\t\t\t});\n\n\t\t\tit(\"can set and get empty array as initial value\", () => {\n\t\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\t\tarr: StateFactory.latest({ local: [] }),\n\t\t\t\t});\n\t\t\t\tassert.deepStrictEqual(workspace.states.arr.local, []);\n\t\t\t});\n\n\t\t\tit(\"can set and get array with elements as initial value\", () => {\n\t\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\t\tarr: StateFactory.latest({ local: [1, 2, 3] }),\n\t\t\t\t});\n\t\t\t\tassert.deepStrictEqual(workspace.states.arr.local, [1, 2, 3]);\n\t\t\t});\n\n\t\t\tit(\"can set and get null as initial value\", () => {\n\t\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\t\tnullable: StateFactory.latest({ local: null }),\n\t\t\t\t});\n\t\t\t\tassert.deepStrictEqual(workspace.states.nullable.local, null);\n\t\t\t});\n\n\t\t\tit(\"can set and get inferred nullable type as initial value\", () => {\n\t\t\t\t// Setup\n\t\t\t\t// Use a function to generate the initial value so that TypeScript\n\t\t\t\t// can't statically infer the type as exactly null.\n\t\t\t\tfunction generateInitialValue(): { x: number; y: number } | null {\n\t\t\t\t\treturn { x: 0, y: 0 };\n\t\t\t\t}\n\t\t\t\tconst initialValue = generateInitialValue();\n\t\t\t\t// Act\n\t\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\t\tnullable: StateFactory.latest({ local: initialValue }),\n\t\t\t\t});\n\t\t\t\t// Verify\n\t\t\t\tassert.deepStrictEqual(workspace.states.nullable.local, initialValue);\n\t\t\t});\n\n\t\t\tit(\".presence provides Presence it was created under\", () => {\n\t\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\t\tcamera: StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),\n\t\t\t\t});\n\n\t\t\t\tassert.strictEqual(workspace.states.camera.presence, presence);\n\t\t\t});\n\n\t\t\tit(\"can set and get null as modified local value\", () => {\n\t\t\t\t// Setup\n\t\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\t\tnullable: StateFactory.latest<{ x: number; y: number } | null>({\n\t\t\t\t\t\tlocal: { x: 0, y: 0 },\n\t\t\t\t\t}),\n\t\t\t\t});\n\n\t\t\t\t// Act and Verify\n\t\t\t\tworkspace.states.nullable.local = null;\n\t\t\t\tassert.deepStrictEqual(workspace.states.nullable.local, null);\n\t\t\t});\n\t\t});\n\n\t\taddControlsTests(createLatestManager);\n\n\t\tit(\"localUpdate event is fired with new value when local value is updated\", () => {\n\t\t\t// Setup\n\t\t\tconst presence = createPresenceManager(new MockEphemeralRuntime());\n\t\t\tconst workspace = presence.states.getWorkspace(testWorkspaceName, {\n\t\t\t\tcamera: StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),\n\t\t\t});\n\t\t\tconst camera = workspace.states.camera;\n\n\t\t\tlet localUpdateCount = 0;\n\t\t\tcamera.events.on(\"localUpdated\", (update) => {\n\t\t\t\tlocalUpdateCount++;\n\t\t\t\tassert.deepStrictEqual(update.value, { x: 1, y: 2, z: 3 });\n\t\t\t});\n\n\t\t\t// Act & Verify\n\t\t\tcamera.local = { x: 1, y: 2, z: 3 };\n\t\t\tassert.strictEqual(localUpdateCount, 1);\n\t\t});\n\t});\n});\n\n// ---- test (example) code ----\n\n/**\n * Check that the code compiles.\n */\nexport function checkCompiles(): void {\n\tconst latestCountAnyKeyConfiguration = StateFactory.latest({ local: { count: 0 } });\n\tconst latestCountSpecificKeyConfiguration: LatestRawConfiguration<\n\t\t{\n\t\t\tcount: number;\n\t\t},\n\t\t// May only be set to specific workspace key \"myCount\"\n\t\t\"myCount\"\n\t> = StateFactory.latest({ local: { count: 0 } });\n\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tconst presence = {} as Presence;\n\tconst statesWorkspace = presence.states.getWorkspace(\"name:testStatesWorkspaceWithLatest\", {\n\t\tcursor: StateFactory.latest({ local: { x: 0, y: 0 } }),\n\t\tcamera: StateFactory.latest({ local: { x: 0, y: 0, z: 0 } }),\n\t\tnullablePoint: StateFactory.latest<null | { x: number; y: number }>({ local: null }),\n\t\tvalidated: StateFactory.latest({\n\t\t\tlocal: { num: 22 },\n\t\t\tvalidator: (data: unknown) => data as { num: number },\n\t\t}),\n\t\tcount0: latestCountAnyKeyConfiguration,\n\t\tcount1: latestCountAnyKeyConfiguration,\n\t\tmyCount: latestCountSpecificKeyConfiguration,\n\t});\n\t// Workaround ts(2775): Assertions require every name in the call target to be declared with an explicit type annotation.\n\tconst workspace: typeof statesWorkspace = statesWorkspace;\n\tconst props = workspace.states;\n\n\tworkspace.add(\"caret\", StateFactory.latest({ local: { id: \"\", pos: 0 } }));\n\n\tconst fakeAdd =\n\t\tworkspace.states.caret.local.pos + props.camera.local.z + props.cursor.local.x;\n\tconsole.log(fakeAdd);\n\n\t// @ts-expect-error local may be set wholly, but partially it is readonly\n\tworkspace.states.caret.local.pos = 0;\n\n\tfunction logClientValue<T>({\n\t\tattendee,\n\t\tvalue,\n\t}: Pick<LatestClientData<T, RawValueAccessor<T>>, \"attendee\" | \"value\">): void {\n\t\tconsole.log(attendee.attendeeId, value);\n\t}\n\n\tfunction logRemoteValue<T>({\n\t\tattendee,\n\t\tvalue,\n\t}: Pick<LatestClientData<T>, \"attendee\" | \"value\">): void {\n\t\tconsole.log(attendee.attendeeId, value());\n\t}\n\n\t// Create new cursor state\n\tconst cursor = props.cursor;\n\n\t// Update our cursor position\n\tcursor.local = { x: 1, y: 2 };\n\n\t// Set nullable point to non-null value\n\tprops.nullablePoint.local = { x: 10, y: -2 };\n\n\t// Listen to others cursor updates\n\tconst cursorUpdatedOff = cursor.events.on(\"remoteUpdated\", ({ attendee, value }) =>\n\t\tconsole.log(`attendee ${attendee.attendeeId}'s cursor is now at (${value.x},${value.y})`),\n\t);\n\tcursorUpdatedOff();\n\n\tfor (const attendee of cursor.getStateAttendees()) {\n\t\tlogClientValue({ attendee, ...cursor.getRemote(attendee) });\n\t}\n\n\t// Enumerate all cursor values\n\tfor (const { attendee, value } of cursor.getRemotes()) {\n\t\tlogClientValue({ attendee, value });\n\t}\n\n\t// Get a reference to one of the remote attendees\n\tconst attendee2 = [...cursor.getStateAttendees()].find(\n\t\t(attendee) => attendee !== presence.attendees.getMyself(),\n\t);\n\tassert(attendee2 !== undefined);\n\n\t// Get a remote raw value\n\tconst remoteCursor = cursor.getRemote(attendee2);\n\tlogClientValue({ attendee: attendee2, value: remoteCursor.value });\n\n\tassertIdenticalTypes(props.cursor, createInstanceOf<LatestRaw<{ x: number; y: number }>>());\n\tassertIdenticalTypes(props.validated, createInstanceOf<Latest<{ num: number }>>());\n\n\t// Get a remote validated value\n\tconst latestData = props.validated.getRemote(attendee2);\n\n\t// The next line correctly does not compile because the value argument must be a RawValueAccessor\n\t// @ts-expect-error Type '() => { readonly num: number; } | undefined' is not assignable to type 'never'.\n\tlogClientValue({ attendee: attendee2, value: latestData.value });\n\n\t// This line correctly compiles because logRemoteValue expects a ProxiedValueAccessor\n\tlogRemoteValue({ attendee: attendee2, value: latestData.value });\n\n\t// Adding captured LatestConfigurations's to workspace\n\tworkspace.add(\"myCount\", latestCountAnyKeyConfiguration);\n\tworkspace.add(\"otherCount\", latestCountAnyKeyConfiguration);\n\t// @ts-expect-error Argument of type '\"otherCount\"' is not assignable to parameter of type '\"myCount\"'\n\tworkspace.add(\"otherCount\", latestCountSpecificKeyConfiguration);\n}\n\n/* eslint-enable unicorn/no-null */\n"]}
@@ -1,11 +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.MockEphemeralRuntime = exports.initialLocalClientConnectionId = void 0;
8
- var test_utils_1 = require("@fluid-internal/presence-runtime/internal/test-utils");
9
- Object.defineProperty(exports, "initialLocalClientConnectionId", { enumerable: true, get: function () { return test_utils_1.initialLocalClientConnectionId; } });
10
- Object.defineProperty(exports, "MockEphemeralRuntime", { enumerable: true, get: function () { return test_utils_1.MockEphemeralRuntime; } });
11
- //# sourceMappingURL=mockEphemeralRuntime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mockEphemeralRuntime.js","sourceRoot":"","sources":["../../../src/states/test/mockEphemeralRuntime.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAG8D;AAF7D,4HAAA,8BAA8B,OAAA;AAC9B,kHAAA,oBAAoB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tinitialLocalClientConnectionId,\n\tMockEphemeralRuntime,\n} from \"@fluid-internal/presence-runtime/internal/test-utils\";\n"]}