@noya-app/noya-multiplayer-react 0.1.65 → 0.1.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1495,24 +1495,30 @@ var require_lib2 = __commonJS({
1495
1495
  // src/index.ts
1496
1496
  var src_exports = {};
1497
1497
  __export(src_exports, {
1498
- AnyEphemeralUserDataManagerContext: () => AnyEphemeralUserDataManagerContext,
1499
1498
  AnyNoyaStateContext: () => AnyNoyaStateContext,
1500
- ConnectedUsersContext: () => ConnectedUsersContext,
1501
1499
  FallbackUntilInitialized: () => FallbackUntilInitialized,
1502
1500
  StateInspector: () => StateInspector,
1503
1501
  UserPointersOverlay: () => UserPointersOverlay,
1504
1502
  WebSocketConnection: () => WebSocketConnection,
1503
+ buildCreateResourcePayload: () => buildCreateResourcePayload,
1505
1504
  createDefaultAppData: () => createDefaultAppData,
1506
1505
  createNoyaContext: () => createNoyaContext,
1506
+ createStateInspectorRoot: () => createStateInspectorRoot,
1507
1507
  decodeAll: () => decodeAll,
1508
+ deleteNoyaSingleton: () => deleteNoyaSingleton,
1508
1509
  encodeAll: () => encodeAll,
1509
1510
  enforceSchema: () => enforceSchema,
1510
1511
  exportAll: () => exportAll,
1511
1512
  fetchAssetMap: () => fetchAssetMap,
1512
1513
  getAppData: () => getAppData,
1514
+ getNoyaManagerSingleton: () => getNoyaManagerSingleton,
1515
+ getNoyaSingletonBindings: () => getNoyaSingletonBindings,
1516
+ getSyncAdapter: () => getSyncAdapter,
1513
1517
  importAll: () => importAll,
1518
+ initializeNoyaSingleton: () => initializeNoyaSingleton,
1514
1519
  parseAppDataParameter: () => parseAppDataParameter,
1515
1520
  replaceDeep: () => replaceDeep,
1521
+ resourceToCreateParameters: () => resourceToCreateParameters,
1516
1522
  resourceToMediaItem: () => resourceToMediaItem,
1517
1523
  useAIManager: () => useAIManager,
1518
1524
  useActivityEvents: () => useActivityEvents,
@@ -1523,12 +1529,15 @@ __export(src_exports, {
1523
1529
  useAsset: () => useAsset,
1524
1530
  useAssetManager: () => useAssetManager,
1525
1531
  useAssets: () => useAssets,
1532
+ useBindNoyaManager: () => useBindNoyaManager,
1526
1533
  useCallableAITools: () => useCallableAITools,
1527
1534
  useColorScheme: () => useColorScheme,
1528
1535
  useConnectedUser: () => useConnectedUser,
1529
1536
  useConnectedUsers: () => useConnectedUsers,
1530
1537
  useConnectedUsersManager: () => useConnectedUsersManager,
1531
1538
  useCurrentUserId: () => useCurrentUserId,
1539
+ useFileName: () => useFileName,
1540
+ useFilePropertyManager: () => useFilePropertyManager,
1532
1541
  useIOManager: () => useIOManager,
1533
1542
  useInputs: () => useInputs,
1534
1543
  useIsInitialized: () => useIsInitialized,
@@ -1536,7 +1545,7 @@ __export(src_exports, {
1536
1545
  useManagedHistory: () => useManagedHistory,
1537
1546
  useManagedState: () => useManagedState,
1538
1547
  useMultiplayerState: () => useMultiplayerState,
1539
- useNoyaState: () => useNoyaState,
1548
+ useNoyaStateInternal: () => useNoyaStateInternal,
1540
1549
  useObservable: () => useObservable,
1541
1550
  useOutputTransforms: () => useOutputTransforms,
1542
1551
  usePipelineManager: () => usePipelineManager,
@@ -1547,15 +1556,15 @@ __export(src_exports, {
1547
1556
  useSecret: () => useSecret,
1548
1557
  useSecretManager: () => useSecretManager,
1549
1558
  useSecrets: () => useSecrets,
1559
+ useSetFileNameState: () => useSetFileNameState,
1550
1560
  useStateInspector: () => useStateInspector,
1551
- useSyncStateManager: () => useSyncStateManager,
1552
1561
  useViewType: () => useViewType
1553
1562
  });
1554
1563
  module.exports = __toCommonJS(src_exports);
1555
1564
  __reExport(src_exports, require("@noya-app/state-manager"), module.exports);
1556
1565
 
1557
1566
  // src/ai.ts
1558
- var import_react19 = require("react");
1567
+ var import_react20 = require("react");
1559
1568
 
1560
1569
  // ../../node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
1561
1570
  var TransformKind = Symbol.for("TypeBox.Transform");
@@ -4044,6 +4053,7 @@ var activityEventSchema = Type.Object({
4044
4053
  // ../noya-schemas/src/asset.ts
4045
4054
  var assetSchema = Type.Object({
4046
4055
  id: Type.String(),
4056
+ stableId: Type.String(),
4047
4057
  url: Type.String(),
4048
4058
  createdAt: Type.String(),
4049
4059
  size: Type.Number(),
@@ -4549,6 +4559,26 @@ var flatResourceSchema = Type.Object({
4549
4559
  fileId: Nullable(Type.String()),
4550
4560
  resourceId: Nullable(Type.String())
4551
4561
  });
4562
+ function getChangedResourceProperties({
4563
+ oldResource,
4564
+ newResource,
4565
+ oldPath,
4566
+ newPath
4567
+ }) {
4568
+ const changed = {};
4569
+ if (newPath !== void 0 && (oldPath ?? oldResource.path) !== newPath) {
4570
+ changed.path = newPath;
4571
+ }
4572
+ const oldAssetId = oldResource.type === "asset" ? oldResource.assetId : void 0;
4573
+ const newAssetId = newResource.type === "asset" ? newResource.assetId : void 0;
4574
+ if (oldAssetId !== newAssetId) {
4575
+ changed.assetId = newAssetId;
4576
+ }
4577
+ if (newResource.type === "asset" && newResource.asset !== void 0) {
4578
+ changed.asset = newResource.asset;
4579
+ }
4580
+ return changed;
4581
+ }
4552
4582
  function diffResourceMaps(resourceMap, newResourceMap, idProperty) {
4553
4583
  const oldIdToPathMap = new Map(
4554
4584
  Object.entries(resourceMap).map(([path2, entity]) => [
@@ -4575,7 +4605,7 @@ function diffResourceMaps(resourceMap, newResourceMap, idProperty) {
4575
4605
  const removedResources = Object.values(resourceMap).filter(
4576
4606
  (entity) => !newIds.has(entity[idProperty])
4577
4607
  );
4578
- const modifiedResources = [...sameIds].flatMap((id) => {
4608
+ const sameIdModifiedResources = [...sameIds].flatMap((id) => {
4579
4609
  const oldResource = Object.values(resourceMap).find(
4580
4610
  (resource) => resource[idProperty] === id
4581
4611
  );
@@ -4585,17 +4615,54 @@ function diffResourceMaps(resourceMap, newResourceMap, idProperty) {
4585
4615
  if (!oldResource || !newResource) return [];
4586
4616
  const oldPath = oldIdToPathMap.get(id);
4587
4617
  const newPath = newIdToPathMap.get(id);
4588
- const oldAssetId = oldResource.type === "asset" ? oldResource.assetId : void 0;
4589
- const newAssetId = newResource.type === "asset" ? newResource.assetId : void 0;
4590
- const changedProperties = {
4591
- ...oldPath !== newPath ? { path: newPath } : {},
4592
- ...oldAssetId !== newAssetId ? { assetId: newAssetId } : {},
4593
- ...newResource.type === "asset" && newResource.asset !== void 0 ? { asset: newResource.asset } : {}
4594
- };
4618
+ const changedProperties = getChangedResourceProperties({
4619
+ oldResource,
4620
+ newResource,
4621
+ oldPath,
4622
+ newPath
4623
+ });
4595
4624
  if (Object.keys(changedProperties).length === 0) return [];
4596
4625
  return [{ id, stableId: newResource.stableId, ...changedProperties }];
4597
4626
  });
4598
- return { addedResources, removedResources, modifiedResources };
4627
+ const removedResourcesByPath = new Map(
4628
+ removedResources.map((resource) => [resource.path, resource])
4629
+ );
4630
+ const swappedPaths = /* @__PURE__ */ new Set();
4631
+ const swappedModifiedResources = [];
4632
+ for (const addedResource of addedResources) {
4633
+ const existingResource = removedResourcesByPath.get(addedResource.path);
4634
+ if (!existingResource) continue;
4635
+ if (existingResource.type !== addedResource.type) continue;
4636
+ if (existingResource[idProperty] === addedResource[idProperty]) continue;
4637
+ swappedPaths.add(addedResource.path);
4638
+ const changedProperties = getChangedResourceProperties({
4639
+ oldResource: existingResource,
4640
+ newResource: addedResource,
4641
+ oldPath: existingResource.path,
4642
+ newPath: addedResource.path
4643
+ });
4644
+ if (Object.keys(changedProperties).length === 0) continue;
4645
+ const id = existingResource[idProperty];
4646
+ swappedModifiedResources.push({
4647
+ id,
4648
+ stableId: existingResource.stableId,
4649
+ ...changedProperties
4650
+ });
4651
+ }
4652
+ const filteredAddedResources = addedResources.filter(
4653
+ (resource) => !swappedPaths.has(resource.path)
4654
+ );
4655
+ const filteredRemovedResources = removedResources.filter(
4656
+ (resource) => !swappedPaths.has(resource.path)
4657
+ );
4658
+ return {
4659
+ addedResources: filteredAddedResources,
4660
+ removedResources: filteredRemovedResources,
4661
+ modifiedResources: [
4662
+ ...sameIdModifiedResources,
4663
+ ...swappedModifiedResources
4664
+ ]
4665
+ };
4599
4666
  }
4600
4667
 
4601
4668
  // ../noya-schemas/src/resourceTree.ts
@@ -4614,7 +4681,7 @@ format_exports.Set("uuid", validateUUID);
4614
4681
  // src/NoyaStateContext.tsx
4615
4682
  var import_observable = require("@noya-app/observable");
4616
4683
  var import_react_utils3 = require("@noya-app/react-utils");
4617
- var import_react18 = __toESM(require("react"));
4684
+ var import_react19 = __toESM(require("react"));
4618
4685
 
4619
4686
  // src/noyaApp.ts
4620
4687
  var import_state_manager3 = require("@noya-app/state-manager");
@@ -4747,6 +4814,26 @@ var FILE_TYPE_TO_EXTENSION = {
4747
4814
  };
4748
4815
  var FILE_EXTENSION_TO_TYPE = invert(FILE_TYPE_TO_EXTENSION);
4749
4816
 
4817
+ // ../noya-utils/src/memoize.ts
4818
+ function memoize(f) {
4819
+ const intermediateCache = /* @__PURE__ */ new Map();
4820
+ const cache = /* @__PURE__ */ new Map();
4821
+ let intermediateCacheIndex = 0;
4822
+ return (...values) => {
4823
+ let key = "";
4824
+ for (const value of values) {
4825
+ if (!intermediateCache.has(value)) {
4826
+ intermediateCache.set(value, `${intermediateCacheIndex++}`);
4827
+ }
4828
+ key += intermediateCache.get(value) + ":";
4829
+ }
4830
+ if (!cache.has(key)) {
4831
+ cache.set(key, f(...values));
4832
+ }
4833
+ return cache.get(key);
4834
+ };
4835
+ }
4836
+
4750
4837
  // ../noya-utils/src/memoizeDeep.ts
4751
4838
  var TOKEN_OBJECT = Symbol("object");
4752
4839
  var TOKEN_ARRAY = Symbol("array");
@@ -5967,19 +6054,17 @@ async function importAll(buffer, noyaManager, {
5967
6054
  }
5968
6055
  if (assets.length) {
5969
6056
  await Promise.all(
5970
- noyaManager.assetManager.assets$.get().map((asset) => noyaManager.assetManager.delete(asset.id))
6057
+ noyaManager.assetManager.assets$.get().map((asset) => noyaManager.assetManager.delete(asset.stableId))
5971
6058
  );
5972
- const idPairs = await Promise.all(
6059
+ await Promise.all(
5973
6060
  assets.map(async (asset) => {
5974
- const newAsset = await noyaManager.assetManager.create({
6061
+ await noyaManager.assetManager.create({
5975
6062
  data: assetMap[asset.id],
5976
- contentType: asset.contentType
6063
+ contentType: asset.contentType,
6064
+ stableId: asset.stableId
5977
6065
  });
5978
- return [asset.id, newAsset.id];
5979
6066
  })
5980
6067
  );
5981
- const replacementMap = Object.fromEntries(idPairs);
5982
- state = replaceDeep(state, replacementMap);
5983
6068
  }
5984
6069
  noyaManager.initialState = state;
5985
6070
  noyaManager.forceInit();
@@ -6495,7 +6580,14 @@ var StateInspector = (0, import_react_utils.memoGeneric)(function StateInspector
6495
6580
  "Upload"
6496
6581
  ))
6497
6582
  },
6498
- /* @__PURE__ */ import_react14.default.createElement(StateInspectorDisclosureRowInner, null, assets.map((asset) => /* @__PURE__ */ import_react14.default.createElement(StateInspectorRow, { key: asset.id, colorScheme }, /* @__PURE__ */ import_react14.default.createElement(import_react_inspector6.ObjectInspector, { name: asset.id, data: asset, theme }), /* @__PURE__ */ import_react14.default.createElement(
6583
+ /* @__PURE__ */ import_react14.default.createElement(StateInspectorDisclosureRowInner, null, assets.map((asset) => /* @__PURE__ */ import_react14.default.createElement(StateInspectorRow, { key: asset.id, colorScheme }, /* @__PURE__ */ import_react14.default.createElement(
6584
+ import_react_inspector6.ObjectInspector,
6585
+ {
6586
+ name: asset.id,
6587
+ data: truncateAsset(asset),
6588
+ theme
6589
+ }
6590
+ ), /* @__PURE__ */ import_react14.default.createElement(
6499
6591
  StateInspectorButton,
6500
6592
  {
6501
6593
  theme,
@@ -6520,10 +6612,8 @@ var StateInspector = (0, import_react_utils.memoGeneric)(function StateInspector
6520
6612
  "Are you sure you want to delete all resources?"
6521
6613
  );
6522
6614
  if (!ok) return;
6523
- await Promise.all(
6524
- resources.map(
6525
- (resource) => resourceManager.deleteResource({ id: resource.id })
6526
- )
6615
+ await resourceManager.deleteResource(
6616
+ resources.map((resource) => ({ id: resource.id }))
6527
6617
  );
6528
6618
  }
6529
6619
  },
@@ -6736,6 +6826,12 @@ var StateInspector = (0, import_react_utils.memoGeneric)(function StateInspector
6736
6826
  )
6737
6827
  );
6738
6828
  });
6829
+ var truncateAsset = memoize((asset) => {
6830
+ if (asset.url.startsWith("data:") || asset.url.startsWith("blob:")) {
6831
+ return { ...asset, url: ellipsis(asset.url, 40) };
6832
+ }
6833
+ return asset;
6834
+ });
6739
6835
 
6740
6836
  // src/inspector/useStateInspector.tsx
6741
6837
  function createShadowRootElement() {
@@ -6746,6 +6842,17 @@ function createShadowRootElement() {
6746
6842
  shadowRoot.appendChild(container);
6747
6843
  return { host, container };
6748
6844
  }
6845
+ function createStateInspectorRoot() {
6846
+ const { host, container } = createShadowRootElement();
6847
+ const root = (0, import_client.createRoot)(container);
6848
+ document.body.appendChild(host);
6849
+ return {
6850
+ root,
6851
+ unmount: () => {
6852
+ document.body.removeChild(host);
6853
+ }
6854
+ };
6855
+ }
6749
6856
  function useStateInspector({
6750
6857
  noyaManager,
6751
6858
  disabled = false,
@@ -6755,13 +6862,9 @@ function useStateInspector({
6755
6862
  const [root, setRoot] = import_react15.default.useState(null);
6756
6863
  (0, import_react_utils2.useIsomorphicLayoutEffect)(() => {
6757
6864
  if (disabled) return;
6758
- const { host, container } = createShadowRootElement();
6759
- const root2 = (0, import_client.createRoot)(container);
6760
- document.body.appendChild(host);
6865
+ const { root: root2, unmount } = createStateInspectorRoot();
6761
6866
  setRoot(root2);
6762
- return () => {
6763
- document.body.removeChild(host);
6764
- };
6867
+ return unmount;
6765
6868
  }, [disabled]);
6766
6869
  (0, import_react_utils2.useIsomorphicLayoutEffect)(() => {
6767
6870
  if (!root) return;
@@ -6779,22 +6882,18 @@ function useStateInspector({
6779
6882
  }
6780
6883
 
6781
6884
  // src/hooks.ts
6782
- function useSyncStateManager(stateManager, path2) {
6783
- const getSnapshot = (0, import_react16.useCallback)(
6784
- () => typeof path2 === "string" ? stateManager.getState(path2) : stateManager.getState(),
6785
- [stateManager, path2]
6885
+ function useManagedState(createInitialState, options) {
6886
+ const [stateManager] = (0, import_react16.useState)(
6887
+ () => new import_state_manager2.StateManager(createInitialState(), options)
6786
6888
  );
6787
- return (0, import_react16.useSyncExternalStore)(
6889
+ const getSnapshot = (0, import_react16.useCallback)(() => {
6890
+ return stateManager.getState();
6891
+ }, [stateManager]);
6892
+ const state = (0, import_react16.useSyncExternalStore)(
6788
6893
  stateManager.addListener,
6789
6894
  getSnapshot,
6790
6895
  getSnapshot
6791
6896
  );
6792
- }
6793
- function useManagedState(createInitialState, options) {
6794
- const [stateManager] = (0, import_react16.useState)(
6795
- () => new import_state_manager2.StateManager(createInitialState(), options)
6796
- );
6797
- const state = useSyncStateManager(stateManager);
6798
6897
  const setState = (0, import_react16.useCallback)(
6799
6898
  (...args) => {
6800
6899
  const [metadata, action] = args.length === 1 ? [void 0, args[0]] : args;
@@ -6837,15 +6936,7 @@ function useManagedHistory(stateManager) {
6837
6936
  stateManager.getHistorySnapshot
6838
6937
  );
6839
6938
  }
6840
- function useMultiplayerState(initialState, options) {
6841
- const {
6842
- sync = (0, import_state_manager2.stubSync)(),
6843
- inspector,
6844
- ...rest
6845
- } = options ?? {};
6846
- const [noyaManager] = (0, import_react16.useState)(
6847
- () => new import_state_manager2.NoyaManager(initialState, rest)
6848
- );
6939
+ function useBindNoyaManager(noyaManager, options) {
6849
6940
  const state = useObservable(
6850
6941
  noyaManager.multiplayerStateManager.optimisticState$
6851
6942
  );
@@ -6869,7 +6960,7 @@ function useMultiplayerState(initialState, options) {
6869
6960
  assets
6870
6961
  };
6871
6962
  }, [noyaManager, assets]);
6872
- const syncRef = (0, import_react16.useRef)(sync);
6963
+ const syncRef = (0, import_react16.useRef)(options?.sync);
6873
6964
  (0, import_react16.useEffect)(() => {
6874
6965
  if (syncRef.current) {
6875
6966
  return syncRef.current({ noyaManager });
@@ -6878,11 +6969,22 @@ function useMultiplayerState(initialState, options) {
6878
6969
  useErrorOverlay(noyaManager);
6879
6970
  useStateInspector({
6880
6971
  noyaManager,
6881
- disabled: !inspector,
6882
- ...typeof inspector === "object" && inspector
6972
+ disabled: !options?.inspector,
6973
+ ...typeof options?.inspector === "object" && options?.inspector
6883
6974
  });
6884
6975
  return [state, noyaManager.multiplayerStateManager.setState, extras];
6885
6976
  }
6977
+ function useMultiplayerState(initialState, options) {
6978
+ const {
6979
+ sync = (0, import_state_manager2.stubSync)(),
6980
+ inspector,
6981
+ ...rest
6982
+ } = options ?? {};
6983
+ const [noyaManager] = (0, import_react16.useState)(
6984
+ () => new import_state_manager2.NoyaManager(initialState, rest)
6985
+ );
6986
+ return useBindNoyaManager(noyaManager, { sync, inspector });
6987
+ }
6886
6988
  function useErrorOverlay(noyaManager) {
6887
6989
  const unrecoverableError = useObservable(noyaManager.unrecoverableError);
6888
6990
  (0, import_react16.useEffect)(() => {
@@ -6938,7 +7040,11 @@ function getAppData(initialState, schema, options) {
6938
7040
  appData.initialState = enforceSchema(appData.initialState, schema);
6939
7041
  return appData;
6940
7042
  }
6941
- function useNoyaState(...args) {
7043
+ function getSyncAdapter(params) {
7044
+ const { multiplayerUrl, offlineStorageKey, debug } = params ?? {};
7045
+ return (0, import_state_manager3.isEmbeddedApp)() ? (0, import_state_manager3.parentFrameSync)({ debug }) : multiplayerUrl ? (0, import_state_manager3.webSocketSync)({ url: multiplayerUrl, debug }) : offlineStorageKey ? (0, import_state_manager3.localStorageSync)({ key: offlineStorageKey }) : (0, import_state_manager3.stubSync)();
7046
+ }
7047
+ function useNoyaStateInternal(...args) {
6942
7048
  const [initialState, options] = typeof args[0] === "object" && args[0] !== null && "schema" in args[0] && import_state_manager3.TypeGuard.IsSchema(args[0].schema) ? [null, args[0]] : [args[0], args[1]];
6943
7049
  const [
6944
7050
  {
@@ -6954,13 +7060,16 @@ function useNoyaState(...args) {
6954
7060
  });
6955
7061
  });
6956
7062
  const sync = (0, import_react17.useMemo)(() => {
6957
- return (0, import_state_manager3.isEmbeddedApp)() ? (0, import_state_manager3.parentFrameSync)({ debug: options?.debug }) : multiplayerUrl ? (0, import_state_manager3.webSocketSync)({
6958
- url: multiplayerUrl,
7063
+ return getSyncAdapter({
7064
+ multiplayerUrl,
7065
+ offlineStorageKey: options?.offlineStorageKey,
6959
7066
  debug: options?.debug
6960
- }) : options?.offlineStorageKey ? (0, import_state_manager3.localStorageSync)({ key: options.offlineStorageKey }) : (0, import_state_manager3.stubSync)();
7067
+ });
6961
7068
  }, [multiplayerUrl, options?.offlineStorageKey, options?.debug]);
6962
- const result = useMultiplayerState(noyaAppInitialState, {
6963
- ...options,
7069
+ const [noyaManager] = (0, import_react17.useState)(
7070
+ () => new import_state_manager3.NoyaManager(noyaAppInitialState, options)
7071
+ );
7072
+ const result = useBindNoyaManager(noyaManager, {
6964
7073
  inspector: options?.inspector ?? inspector,
6965
7074
  sync: options?.sync ?? sync
6966
7075
  });
@@ -6971,11 +7080,164 @@ function useNoyaState(...args) {
6971
7080
  return [result[0], result[1], mergedExtras];
6972
7081
  }
6973
7082
 
7083
+ // src/singleton.tsx
7084
+ var import_state_manager4 = require("@noya-app/state-manager");
7085
+ var import_react18 = __toESM(require("react"));
7086
+ var noyaManagerSingleton;
7087
+ var noyaSingletonBindings;
7088
+ function initializeNoyaSingleton(options) {
7089
+ if (noyaManagerSingleton) {
7090
+ throw new Error(
7091
+ "Noya has already been initialized. Call `useNoyaState` instead."
7092
+ );
7093
+ }
7094
+ const {
7095
+ initialState,
7096
+ sync,
7097
+ inspector,
7098
+ theme,
7099
+ viewType,
7100
+ offlineStorageKey,
7101
+ multiplayerUrl,
7102
+ ...managerOptions
7103
+ } = options ?? {};
7104
+ const appData = getAppData(
7105
+ initialState ?? null,
7106
+ managerOptions?.schema,
7107
+ { overrideExistingState: managerOptions?.overrideExistingState }
7108
+ );
7109
+ noyaManagerSingleton = new import_state_manager4.NoyaManager(
7110
+ appData.initialState,
7111
+ managerOptions
7112
+ );
7113
+ const resolvedSync = sync ?? getSyncAdapter({
7114
+ multiplayerUrl: multiplayerUrl ?? appData.multiplayerUrl,
7115
+ offlineStorageKey,
7116
+ debug: managerOptions?.debug
7117
+ });
7118
+ try {
7119
+ resolvedSync({ noyaManager: noyaManagerSingleton });
7120
+ } catch (error) {
7121
+ console.warn("Failed to activate sync", error);
7122
+ }
7123
+ const resolvedInspector = inspector ?? appData.inspector;
7124
+ const resolvedTheme = theme ?? appData.theme ?? "light";
7125
+ const resolvedViewType = viewType ?? appData.viewType ?? "editable";
7126
+ if (resolvedInspector) {
7127
+ const { root } = createStateInspectorRoot();
7128
+ root.render(
7129
+ /* @__PURE__ */ import_react18.default.createElement(
7130
+ StateInspector,
7131
+ {
7132
+ noyaManager: noyaManagerSingleton,
7133
+ colorScheme: resolvedInspector === true ? resolvedTheme : resolvedInspector.colorScheme,
7134
+ anchor: resolvedInspector === true ? "bottom right" : resolvedInspector.anchor
7135
+ }
7136
+ )
7137
+ );
7138
+ }
7139
+ noyaSingletonBindings = {
7140
+ sync: resolvedSync,
7141
+ inspector: resolvedInspector,
7142
+ theme: resolvedTheme,
7143
+ viewType: resolvedViewType
7144
+ };
7145
+ }
7146
+ function getNoyaManagerSingleton() {
7147
+ if (!noyaManagerSingleton || !noyaSingletonBindings) {
7148
+ throw new Error(
7149
+ "Noya has not been initialized. Call initializeNoya once before using Noya hooks."
7150
+ );
7151
+ }
7152
+ return noyaManagerSingleton;
7153
+ }
7154
+ function getNoyaSingletonBindings() {
7155
+ return noyaSingletonBindings;
7156
+ }
7157
+ function deleteNoyaSingleton() {
7158
+ noyaManagerSingleton = void 0;
7159
+ noyaSingletonBindings = void 0;
7160
+ }
7161
+
6974
7162
  // src/NoyaStateContext.tsx
6975
- var AnyNoyaStateContext = (0, import_react18.createContext)(void 0);
7163
+ function resourceToCreateParameters(resource) {
7164
+ switch (resource.type) {
7165
+ case "directory":
7166
+ return {
7167
+ path: resource.path,
7168
+ type: "directory"
7169
+ };
7170
+ case "asset":
7171
+ return {
7172
+ path: resource.path,
7173
+ type: "asset",
7174
+ assetId: resource.assetId,
7175
+ asset: resource.asset
7176
+ };
7177
+ case "file":
7178
+ return {
7179
+ path: resource.path,
7180
+ type: "file",
7181
+ fileId: resource.fileId
7182
+ };
7183
+ case "resource":
7184
+ return {
7185
+ path: resource.path,
7186
+ type: "resource",
7187
+ fileId: resource.fileId,
7188
+ resourceId: resource.resourceId
7189
+ };
7190
+ default:
7191
+ throw new Error(`Unknown resource type: ${resource.type}`);
7192
+ }
7193
+ }
7194
+ function buildCreateResourcePayload({
7195
+ addedResources,
7196
+ modifiedResources,
7197
+ newResourceMap,
7198
+ resourceMap
7199
+ }) {
7200
+ const toCreateParameters = resourceToCreateParameters;
7201
+ const resourcesById = new Map(
7202
+ Object.values(resourceMap).map((resource) => [resource.id, resource])
7203
+ );
7204
+ const payload = [
7205
+ ...addedResources.map(toCreateParameters)
7206
+ ];
7207
+ const handledModifiedResourceIds = [];
7208
+ const assetReplacements = modifiedResources.filter(
7209
+ (resource) => resource.assetId !== void 0 || resource.asset !== void 0
7210
+ ).map((resource) => {
7211
+ const previousResource = resourcesById.get(resource.id);
7212
+ const path2 = resource.path ?? previousResource?.path;
7213
+ if (!path2) return void 0;
7214
+ const updated = newResourceMap[path2];
7215
+ if (!updated || updated.type !== "asset") return void 0;
7216
+ handledModifiedResourceIds.push(resource.id);
7217
+ return toCreateParameters(updated);
7218
+ }).filter(
7219
+ (resource) => resource !== void 0
7220
+ );
7221
+ const deduped = new Map(
7222
+ [...payload, ...assetReplacements].map((item) => [item.path, item])
7223
+ );
7224
+ return {
7225
+ payload: Array.from(deduped.values()),
7226
+ consumedModifiedResourceIds: [...new Set(handledModifiedResourceIds)]
7227
+ };
7228
+ }
7229
+ var AnyNoyaStateContext = (0, import_react19.createContext)(void 0);
6976
7230
  function useAnyNoyaStateContext() {
6977
- const value = (0, import_react18.useContext)(AnyNoyaStateContext);
7231
+ const value = (0, import_react19.useContext)(AnyNoyaStateContext);
6978
7232
  if (!value) {
7233
+ const bindings = getNoyaSingletonBindings();
7234
+ if (bindings) {
7235
+ return {
7236
+ noyaManager: getNoyaManagerSingleton(),
7237
+ theme: bindings.theme,
7238
+ viewType: bindings.viewType
7239
+ };
7240
+ }
6979
7241
  throw new Error(
6980
7242
  "useNoyaStateContext must be used within a NoyaStateProvider"
6981
7243
  );
@@ -7000,9 +7262,9 @@ function useAssets() {
7000
7262
  }
7001
7263
  function useAsset(id) {
7002
7264
  const { noyaManager } = useAnyNoyaStateContext();
7003
- const observable = (0, import_react18.useMemo)(
7265
+ const observable = (0, import_react19.useMemo)(
7004
7266
  () => noyaManager.assetManager.assets$.map(
7005
- (assets) => assets.find((a) => a.id === id)
7267
+ (assets) => assets.find((a) => a.stableId === id) ?? assets.find((a) => a.id === id)
7006
7268
  ),
7007
7269
  [noyaManager, id]
7008
7270
  );
@@ -7011,7 +7273,7 @@ function useAsset(id) {
7011
7273
  function useAssetManager() {
7012
7274
  const { noyaManager } = useAnyNoyaStateContext();
7013
7275
  const isInitialized = useObservable(noyaManager.assetManager.isInitialized$);
7014
- return (0, import_react18.useMemo)(
7276
+ return (0, import_react19.useMemo)(
7015
7277
  () => ({
7016
7278
  create: noyaManager.assetManager.create,
7017
7279
  delete: noyaManager.assetManager.delete,
@@ -7036,7 +7298,7 @@ function useSecret(name) {
7036
7298
  const { noyaManager } = useAnyNoyaStateContext();
7037
7299
  return useObservable(
7038
7300
  noyaManager.secretManager.secrets$,
7039
- (0, import_react18.useCallback)((secrets) => secrets.find((s) => s.name === name), [name])
7301
+ (0, import_react19.useCallback)((secrets) => secrets.find((s) => s.name === name), [name])
7040
7302
  );
7041
7303
  }
7042
7304
  function useInputs() {
@@ -7054,7 +7316,7 @@ function useIOManager() {
7054
7316
  function usePublish(callback) {
7055
7317
  const { noyaManager } = useAnyNoyaStateContext();
7056
7318
  const stableCallback = (0, import_react_utils3.useStableCallback)(callback);
7057
- (0, import_react18.useEffect)(() => {
7319
+ (0, import_react19.useEffect)(() => {
7058
7320
  noyaManager.publishingManager.setPublishingEnabled(true);
7059
7321
  noyaManager.publishingManager.getFilesToPublish = stableCallback;
7060
7322
  return () => {
@@ -7065,7 +7327,7 @@ function usePublish(callback) {
7065
7327
  }
7066
7328
  function useIsInitialized() {
7067
7329
  const { noyaManager, viewType } = useAnyNoyaStateContext();
7068
- const isInitializedObservable = (0, import_react18.useMemo)(
7330
+ const isInitializedObservable = (0, import_react19.useMemo)(
7069
7331
  () => import_observable.Observable.combine(
7070
7332
  [
7071
7333
  ...viewType === "preview" ? [] : [noyaManager.multiplayerStateManager.isInitialized$],
@@ -7082,9 +7344,9 @@ function usePipelineManager() {
7082
7344
  const { noyaManager } = useAnyNoyaStateContext();
7083
7345
  return noyaManager.pipelineManager;
7084
7346
  }
7085
- var ConnectedUsersContext = (0, import_react18.createContext)(void 0);
7086
7347
  function useConnectedUsersManager() {
7087
- return (0, import_react18.useContext)(ConnectedUsersContext);
7348
+ const { noyaManager } = useAnyNoyaStateContext();
7349
+ return noyaManager.connectedUsersManager;
7088
7350
  }
7089
7351
  function useConnectedUsers() {
7090
7352
  const connectedUsersManager = useConnectedUsersManager();
@@ -7094,7 +7356,7 @@ function useConnectedUser(userId) {
7094
7356
  const connectedUsersManager = useConnectedUsersManager();
7095
7357
  return useObservable(
7096
7358
  connectedUsersManager?.connectedUsers$,
7097
- (0, import_react18.useCallback)(
7359
+ (0, import_react19.useCallback)(
7098
7360
  (users) => {
7099
7361
  return users.find((user) => {
7100
7362
  const prefix = user.id.slice(0, 8);
@@ -7105,9 +7367,9 @@ function useConnectedUser(userId) {
7105
7367
  )
7106
7368
  );
7107
7369
  }
7108
- var AnyEphemeralUserDataManagerContext = (0, import_react18.createContext)(void 0);
7109
7370
  function useAnyEphemeralUserData() {
7110
- return (0, import_react18.useContext)(AnyEphemeralUserDataManagerContext);
7371
+ const { noyaManager } = useAnyNoyaStateContext();
7372
+ return noyaManager.ephemeralUserDataManager;
7111
7373
  }
7112
7374
  function useCurrentUserId() {
7113
7375
  const connectedUsersManager = useConnectedUsersManager();
@@ -7117,6 +7379,19 @@ function useIsProcessing() {
7117
7379
  const { noyaManager } = useAnyNoyaStateContext();
7118
7380
  return useObservable(noyaManager.isProcessing$);
7119
7381
  }
7382
+ function useFileName() {
7383
+ const { noyaManager } = useAnyNoyaStateContext();
7384
+ return useObservable(noyaManager.filePropertyManager.optimisticValue$);
7385
+ }
7386
+ function useFilePropertyManager() {
7387
+ const { noyaManager } = useAnyNoyaStateContext();
7388
+ return noyaManager.filePropertyManager;
7389
+ }
7390
+ function useSetFileNameState() {
7391
+ const fileName = useFileName();
7392
+ const filePropertyManager = useFilePropertyManager();
7393
+ return [fileName, filePropertyManager.updateName];
7394
+ }
7120
7395
  function useResourceManager() {
7121
7396
  const { noyaManager } = useAnyNoyaStateContext();
7122
7397
  return noyaManager.resourceManager;
@@ -7138,69 +7413,48 @@ function useResources({
7138
7413
  const assetManager = useAssetManager();
7139
7414
  const resourceMap = useObservable(
7140
7415
  resourceManager.optimisticResources$,
7141
- (0, import_react18.useCallback)((resources) => {
7416
+ (0, import_react19.useCallback)((resources) => {
7142
7417
  return Object.fromEntries(
7143
7418
  resources.map((resource) => [resource.path, resource])
7144
7419
  );
7145
7420
  }, [])
7146
7421
  );
7147
- const setResourceMap = (0, import_react18.useCallback)(
7422
+ const setResourceMap = (0, import_react19.useCallback)(
7148
7423
  async (action) => {
7149
7424
  const newResourceMap = action instanceof Function ? action(resourceMap) : action;
7150
7425
  const { addedResources, removedResources, modifiedResources } = diffResourceMaps(resourceMap, newResourceMap, "id");
7151
- if (addedResources.length > 0) {
7152
- const payload = addedResources.map((resource) => {
7153
- switch (resource.type) {
7154
- case "directory":
7155
- return {
7156
- path: resource.path,
7157
- type: "directory"
7158
- };
7159
- case "asset":
7160
- return {
7161
- path: resource.path,
7162
- type: "asset",
7163
- assetId: resource.assetId,
7164
- asset: resource.asset
7165
- };
7166
- case "file":
7167
- return {
7168
- path: resource.path,
7169
- type: "file",
7170
- fileId: resource.fileId
7171
- };
7172
- case "resource":
7173
- return {
7174
- path: resource.path,
7175
- type: "resource",
7176
- fileId: resource.fileId,
7177
- resourceId: resource.resourceId
7178
- };
7179
- default:
7180
- throw new Error(
7181
- `Unknown resource type: ${resource.type}`
7182
- );
7183
- }
7184
- });
7185
- await resourceManager.createResource(payload);
7426
+ const { payload: createPayload, consumedModifiedResourceIds } = buildCreateResourcePayload({
7427
+ addedResources,
7428
+ modifiedResources,
7429
+ newResourceMap,
7430
+ resourceMap
7431
+ });
7432
+ if (createPayload.length > 0) {
7433
+ await resourceManager.createResource(createPayload);
7186
7434
  }
7187
- for (const resource of removedResources) {
7188
- await resourceManager.deleteResource({ id: resource.id });
7189
- if (shouldDeleteAssets && resource.type === "asset") {
7190
- try {
7435
+ const consumedModifiedResourceIdsSet = new Set(
7436
+ consumedModifiedResourceIds
7437
+ );
7438
+ const remainingModifiedResources = modifiedResources.filter(
7439
+ (resource) => !consumedModifiedResourceIdsSet.has(resource.id)
7440
+ );
7441
+ await resourceManager.deleteResource(
7442
+ removedResources.map((resource) => ({ id: resource.id }))
7443
+ );
7444
+ if (shouldDeleteAssets) {
7445
+ for (const resource of removedResources) {
7446
+ if (resource.type === "asset") {
7191
7447
  await assetManager.delete(resource.assetId);
7192
- } catch (error) {
7193
- console.error("Failed to delete asset:", error);
7194
7448
  }
7195
7449
  }
7196
7450
  }
7197
7451
  await Promise.all(
7198
- modifiedResources.map(
7452
+ remainingModifiedResources.map(
7199
7453
  ({ id, path: path2, assetId, asset }) => resourceManager.updateResource({
7200
7454
  id,
7201
7455
  path: path2,
7202
7456
  assetId,
7203
- asset
7457
+ ...assetId ? {} : asset ? { asset } : {}
7204
7458
  })
7205
7459
  )
7206
7460
  );
@@ -7218,9 +7472,9 @@ function useActivityEvents(streamFilter) {
7218
7472
  );
7219
7473
  }
7220
7474
  function useActivityEventsForManager(streamFilter, activityEventsManager) {
7221
- const [streamId, setStreamId] = (0, import_react18.useState)(void 0);
7475
+ const [streamId, setStreamId] = (0, import_react19.useState)(void 0);
7222
7476
  const stableStreamFilter = (0, import_react_utils3.useJsonMemo)(streamFilter);
7223
- (0, import_react18.useEffect)(() => {
7477
+ (0, import_react19.useEffect)(() => {
7224
7478
  if (!stableStreamFilter) return;
7225
7479
  const streamId2 = activityEventsManager.subscribe(stableStreamFilter);
7226
7480
  setStreamId(streamId2);
@@ -7247,42 +7501,26 @@ function createNoyaContext({
7247
7501
  safeEval
7248
7502
  }) {
7249
7503
  const NoyaStateContext = AnyNoyaStateContext;
7250
- const EphemeralUserDataManagerContext = AnyEphemeralUserDataManagerContext;
7251
7504
  function NoyaContextProvider({
7252
7505
  children,
7253
7506
  contextValue
7254
7507
  }) {
7255
- return /* @__PURE__ */ import_react18.default.createElement(AnyNoyaStateContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react18.default.createElement(
7256
- ConnectedUsersContext.Provider,
7257
- {
7258
- value: contextValue.noyaManager.connectedUsersManager
7259
- },
7260
- /* @__PURE__ */ import_react18.default.createElement(
7261
- EphemeralUserDataManagerContext.Provider,
7262
- {
7263
- value: contextValue.noyaManager.ephemeralUserDataManager
7264
- },
7265
- children
7266
- )
7267
- ));
7508
+ return /* @__PURE__ */ import_react19.default.createElement(AnyNoyaStateContext.Provider, { value: contextValue }, children);
7268
7509
  }
7269
7510
  function NoyaStateProvider({
7270
7511
  children,
7271
7512
  initialState,
7272
7513
  ...options
7273
7514
  }) {
7274
- const [, , { noyaManager, theme, viewType }] = useNoyaState(
7275
- initialState,
7276
- {
7277
- schema,
7278
- mergeHistoryEntries,
7279
- outputTransforms,
7280
- inputs,
7281
- safeEval,
7282
- ...options
7283
- }
7284
- );
7285
- const contextValue = (0, import_react18.useMemo)(
7515
+ const [, , { noyaManager, theme, viewType }] = useNoyaStateInternal(initialState, {
7516
+ schema,
7517
+ mergeHistoryEntries,
7518
+ outputTransforms,
7519
+ inputs,
7520
+ safeEval,
7521
+ ...options
7522
+ });
7523
+ const contextValue = (0, import_react19.useMemo)(
7286
7524
  () => ({
7287
7525
  noyaManager,
7288
7526
  theme,
@@ -7290,12 +7528,12 @@ function createNoyaContext({
7290
7528
  }),
7291
7529
  [noyaManager, theme, viewType]
7292
7530
  );
7293
- return /* @__PURE__ */ import_react18.default.createElement(NoyaContextProvider, { contextValue }, options.fallback !== void 0 ? /* @__PURE__ */ import_react18.default.createElement(FallbackUntilInitialized, { fallback: options.fallback }, children) : children);
7531
+ return /* @__PURE__ */ import_react19.default.createElement(NoyaContextProvider, { contextValue }, options.fallback !== void 0 ? /* @__PURE__ */ import_react19.default.createElement(FallbackUntilInitialized, { fallback: options.fallback }, children) : children);
7294
7532
  }
7295
7533
  function useValue(path2, options) {
7296
7534
  const { noyaManager } = useAnyNoyaStateContext();
7297
7535
  let actualPath = typeof path2 === "function" || !path2 ? "" : path2;
7298
- const mappedObservable = (0, import_react18.useMemo)(() => {
7536
+ const mappedObservable = (0, import_react19.useMemo)(() => {
7299
7537
  if (typeof path2 === "function") {
7300
7538
  return noyaManager.multiplayerStateManager.optimisticState$.map(path2, {
7301
7539
  isEqual: options?.isEqual
@@ -7308,7 +7546,7 @@ function createNoyaContext({
7308
7546
  }
7309
7547
  function useSetValue(path2) {
7310
7548
  const { noyaManager } = useAnyNoyaStateContext();
7311
- const setValue = (0, import_react18.useCallback)(
7549
+ const setValue = (0, import_react19.useCallback)(
7312
7550
  (...args) => {
7313
7551
  const [metadata, value] = args.length === 2 ? args : [{}, args[0]];
7314
7552
  noyaManager.multiplayerStateManager.setStateAtPath(
@@ -7332,13 +7570,8 @@ function createNoyaContext({
7332
7570
  return noyaManager.multiplayerStateManager;
7333
7571
  }
7334
7572
  function useEphemeralUserDataManager() {
7335
- const ephemeralUserData = (0, import_react18.useContext)(EphemeralUserDataManagerContext);
7336
- if (!ephemeralUserData) {
7337
- throw new Error(
7338
- "useEphemeralUserData must be used within a NoyaStateProvider"
7339
- );
7340
- }
7341
- return ephemeralUserData;
7573
+ const { noyaManager } = useAnyNoyaStateContext();
7574
+ return noyaManager.ephemeralUserDataManager;
7342
7575
  }
7343
7576
  function useNoyaManager() {
7344
7577
  return useAnyNoyaStateContext().noyaManager;
@@ -7349,7 +7582,7 @@ function createNoyaContext({
7349
7582
  }
7350
7583
  function useSetLeftMenuItems(leftMenuItems) {
7351
7584
  const { menuManager } = useNoyaManager();
7352
- (0, import_react18.useEffect)(() => {
7585
+ (0, import_react19.useEffect)(() => {
7353
7586
  if (leftMenuItems) {
7354
7587
  menuManager.setLeftMenuItems(leftMenuItems);
7355
7588
  }
@@ -7361,7 +7594,7 @@ function createNoyaContext({
7361
7594
  }
7362
7595
  function useSetRightMenuItems(rightMenuItems) {
7363
7596
  const { menuManager } = useNoyaManager();
7364
- (0, import_react18.useEffect)(() => {
7597
+ (0, import_react19.useEffect)(() => {
7365
7598
  if (rightMenuItems) {
7366
7599
  menuManager.setRightMenuItems(rightMenuItems);
7367
7600
  }
@@ -7369,19 +7602,19 @@ function createNoyaContext({
7369
7602
  }
7370
7603
  function useHandleMenuItem(callback) {
7371
7604
  const { menuManager } = useNoyaManager();
7372
- (0, import_react18.useEffect)(() => {
7605
+ (0, import_react19.useEffect)(() => {
7373
7606
  return menuManager.addListener(callback);
7374
7607
  }, [menuManager, callback]);
7375
7608
  }
7376
7609
  function useOnSelectMenuItemCallback() {
7377
7610
  const { menuManager } = useNoyaManager();
7378
- return (0, import_react18.useCallback)((type) => menuManager.emit(type), [menuManager]);
7611
+ return (0, import_react19.useCallback)((type) => menuManager.emit(type), [menuManager]);
7379
7612
  }
7380
7613
  function useMenu(options) {
7381
7614
  const { leftMenuItems, rightMenuItems, onSelectMenuItem } = options;
7382
7615
  useSetLeftMenuItems(leftMenuItems);
7383
7616
  useSetRightMenuItems(rightMenuItems);
7384
- const noop = (0, import_react18.useCallback)(() => {
7617
+ const noop = (0, import_react19.useCallback)(() => {
7385
7618
  }, []);
7386
7619
  useHandleMenuItem(onSelectMenuItem ?? noop);
7387
7620
  }
@@ -7408,7 +7641,7 @@ function createNoyaContext({
7408
7641
  // src/ai.ts
7409
7642
  function useRegisterAITool(tool) {
7410
7643
  const aiManager = useAIManager();
7411
- (0, import_react19.useEffect)(() => {
7644
+ (0, import_react20.useEffect)(() => {
7412
7645
  return aiManager.registerTool(tool);
7413
7646
  }, [aiManager, tool]);
7414
7647
  }
@@ -7420,7 +7653,7 @@ function useCallableAITools() {
7420
7653
  // src/components/UserPointersOverlay.tsx
7421
7654
  var import_observable2 = require("@noya-app/observable");
7422
7655
  var import_react_utils4 = require("@noya-app/react-utils");
7423
- var import_react20 = __toESM(require("react"));
7656
+ var import_react21 = __toESM(require("react"));
7424
7657
  function shouldShow(hideAfter, updatedAt) {
7425
7658
  return !!updatedAt && Date.now() - updatedAt < hideAfter;
7426
7659
  }
@@ -7430,7 +7663,7 @@ var UserPointerInternal = (0, import_react_utils4.memoGeneric)(function UserPoin
7430
7663
  hideAfter = 5e3,
7431
7664
  renderUserPointer
7432
7665
  }) {
7433
- const observable = (0, import_react20.useMemo)(() => {
7666
+ const observable = (0, import_react21.useMemo)(() => {
7434
7667
  const metadata$ = ephemeralUserDataManager.metadata$.observePath([user.id]).throttle(50);
7435
7668
  const data$ = ephemeralUserDataManager.data$.observePath([user.id]).throttle(50);
7436
7669
  return import_observable2.Observable.combine([metadata$, data$], ([metadata2, data2]) => {
@@ -7438,10 +7671,10 @@ var UserPointerInternal = (0, import_react_utils4.memoGeneric)(function UserPoin
7438
7671
  });
7439
7672
  }, [ephemeralUserDataManager, user.id]);
7440
7673
  const { metadata, data } = useObservable(observable);
7441
- const [, setForceUpdate] = (0, import_react20.useState)(0);
7674
+ const [, setForceUpdate] = (0, import_react21.useState)(0);
7442
7675
  const updatedAt = metadata?.updatedAt ?? 0;
7443
7676
  const show = shouldShow(hideAfter, updatedAt);
7444
- (0, import_react20.useEffect)(() => {
7677
+ (0, import_react21.useEffect)(() => {
7445
7678
  if (!show) return;
7446
7679
  const timeoutId = setTimeout(() => {
7447
7680
  setForceUpdate((prev) => prev + 1);
@@ -7463,9 +7696,9 @@ var UserPointersOverlay = (0, import_react_utils4.memoGeneric)(function UserPoin
7463
7696
  }) {
7464
7697
  const currentUserId = useObservable(ephemeralUserDataManager.currentUserId$);
7465
7698
  const connectedUsers = useObservable(connectedUsersManager.connectedUsers$);
7466
- return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, connectedUsers.map((user) => {
7699
+ return /* @__PURE__ */ import_react21.default.createElement(import_react21.default.Fragment, null, connectedUsers.map((user) => {
7467
7700
  if (user.id === currentUserId) return null;
7468
- return /* @__PURE__ */ import_react20.default.createElement(
7701
+ return /* @__PURE__ */ import_react21.default.createElement(
7469
7702
  UserPointerInternal,
7470
7703
  {
7471
7704
  key: user.id,
@@ -7478,17 +7711,17 @@ var UserPointersOverlay = (0, import_react_utils4.memoGeneric)(function UserPoin
7478
7711
  });
7479
7712
 
7480
7713
  // src/WebSocketConnection.ts
7481
- var import_state_manager4 = require("@noya-app/state-manager");
7714
+ var import_state_manager5 = require("@noya-app/state-manager");
7482
7715
  var WebSocketConnection = class {
7483
7716
  constructor(url, options = {}) {
7484
7717
  this.url = url;
7485
7718
  this.options = options;
7486
- this.ws = new import_state_manager4.ReconnectingWebSocket({
7719
+ this.ws = new import_state_manager5.ReconnectingWebSocket({
7487
7720
  debug: options.debug,
7488
7721
  onopen: this.handleOpen,
7489
7722
  onmessage: this.handleMessage,
7490
7723
  onclose: this.handleClose,
7491
- activityDetector: new import_state_manager4.UserActivityDetector()
7724
+ activityDetector: new import_state_manager5.UserActivityDetector()
7492
7725
  });
7493
7726
  }
7494
7727
  ws;
@@ -7556,24 +7789,30 @@ var WebSocketConnection = class {
7556
7789
  };
7557
7790
  // Annotate the CommonJS export names for ESM import in node:
7558
7791
  0 && (module.exports = {
7559
- AnyEphemeralUserDataManagerContext,
7560
7792
  AnyNoyaStateContext,
7561
- ConnectedUsersContext,
7562
7793
  FallbackUntilInitialized,
7563
7794
  StateInspector,
7564
7795
  UserPointersOverlay,
7565
7796
  WebSocketConnection,
7797
+ buildCreateResourcePayload,
7566
7798
  createDefaultAppData,
7567
7799
  createNoyaContext,
7800
+ createStateInspectorRoot,
7568
7801
  decodeAll,
7802
+ deleteNoyaSingleton,
7569
7803
  encodeAll,
7570
7804
  enforceSchema,
7571
7805
  exportAll,
7572
7806
  fetchAssetMap,
7573
7807
  getAppData,
7808
+ getNoyaManagerSingleton,
7809
+ getNoyaSingletonBindings,
7810
+ getSyncAdapter,
7574
7811
  importAll,
7812
+ initializeNoyaSingleton,
7575
7813
  parseAppDataParameter,
7576
7814
  replaceDeep,
7815
+ resourceToCreateParameters,
7577
7816
  resourceToMediaItem,
7578
7817
  useAIManager,
7579
7818
  useActivityEvents,
@@ -7584,12 +7823,15 @@ var WebSocketConnection = class {
7584
7823
  useAsset,
7585
7824
  useAssetManager,
7586
7825
  useAssets,
7826
+ useBindNoyaManager,
7587
7827
  useCallableAITools,
7588
7828
  useColorScheme,
7589
7829
  useConnectedUser,
7590
7830
  useConnectedUsers,
7591
7831
  useConnectedUsersManager,
7592
7832
  useCurrentUserId,
7833
+ useFileName,
7834
+ useFilePropertyManager,
7593
7835
  useIOManager,
7594
7836
  useInputs,
7595
7837
  useIsInitialized,
@@ -7597,7 +7839,7 @@ var WebSocketConnection = class {
7597
7839
  useManagedHistory,
7598
7840
  useManagedState,
7599
7841
  useMultiplayerState,
7600
- useNoyaState,
7842
+ useNoyaStateInternal,
7601
7843
  useObservable,
7602
7844
  useOutputTransforms,
7603
7845
  usePipelineManager,
@@ -7608,8 +7850,8 @@ var WebSocketConnection = class {
7608
7850
  useSecret,
7609
7851
  useSecretManager,
7610
7852
  useSecrets,
7853
+ useSetFileNameState,
7611
7854
  useStateInspector,
7612
- useSyncStateManager,
7613
7855
  useViewType,
7614
7856
  ...require("@noya-app/state-manager")
7615
7857
  });