@noya-app/noya-multiplayer-react 0.1.84 → 0.1.85
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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +8 -0
- package/dist/index.bundle.js +25 -22
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +35 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/NoyaStateContext.tsx +18 -16
- package/src/__tests__/useResourceUrl.test.tsx +92 -0
- package/src/index.ts +1 -0
- package/src/useResourceUrl.ts +19 -0
package/dist/index.mjs
CHANGED
|
@@ -8009,22 +8009,23 @@ function buildResourcePatchPayload({
|
|
|
8009
8009
|
return patch;
|
|
8010
8010
|
}
|
|
8011
8011
|
var AnyNoyaStateContext = createContext(void 0);
|
|
8012
|
-
function
|
|
8012
|
+
function useOptionalAnyNoyaStateContext() {
|
|
8013
8013
|
const value = useContext(AnyNoyaStateContext);
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8014
|
+
const bindings = getNoyaSingletonBindings();
|
|
8015
|
+
if (value) return value;
|
|
8016
|
+
if (!bindings) return void 0;
|
|
8017
|
+
return {
|
|
8018
|
+
noyaManager: getNoyaManagerSingleton(),
|
|
8019
|
+
theme: bindings.theme,
|
|
8020
|
+
viewType: bindings.viewType
|
|
8021
|
+
};
|
|
8022
|
+
}
|
|
8023
|
+
function useAnyNoyaStateContext() {
|
|
8024
|
+
const value = useOptionalAnyNoyaStateContext();
|
|
8025
|
+
if (value) return value;
|
|
8026
|
+
throw new Error(
|
|
8027
|
+
"useNoyaStateContext must be used within a NoyaStateProvider"
|
|
8028
|
+
);
|
|
8028
8029
|
}
|
|
8029
8030
|
function useAnyNoyaManager() {
|
|
8030
8031
|
const { noyaManager } = useAnyNoyaStateContext();
|
|
@@ -8498,6 +8499,18 @@ var UserPointersOverlay = memoGeneric2(function UserPointers({
|
|
|
8498
8499
|
}));
|
|
8499
8500
|
});
|
|
8500
8501
|
|
|
8502
|
+
// src/useResourceUrl.ts
|
|
8503
|
+
import { getResourceUrl } from "@noya-app/state-manager";
|
|
8504
|
+
function useResourceUrl(idOrStableId) {
|
|
8505
|
+
const { noyaManager } = useAnyNoyaStateContext();
|
|
8506
|
+
const resources = useObservable(
|
|
8507
|
+
noyaManager.resourceManager.optimisticResources$
|
|
8508
|
+
);
|
|
8509
|
+
const assets = useObservable(noyaManager.assetManager.assets$);
|
|
8510
|
+
if (!idOrStableId) return void 0;
|
|
8511
|
+
return getResourceUrl(idOrStableId, resources, assets);
|
|
8512
|
+
}
|
|
8513
|
+
|
|
8501
8514
|
// src/WebSocketConnection.ts
|
|
8502
8515
|
import {
|
|
8503
8516
|
ReconnectingWebSocket,
|
|
@@ -8636,11 +8649,13 @@ export {
|
|
|
8636
8649
|
useNoyaUserManager,
|
|
8637
8650
|
useNoyaUsers,
|
|
8638
8651
|
useObservable,
|
|
8652
|
+
useOptionalAnyNoyaStateContext,
|
|
8639
8653
|
useOutputTransforms,
|
|
8640
8654
|
usePipelineManager,
|
|
8641
8655
|
usePublish,
|
|
8642
8656
|
useRegisterAITool,
|
|
8643
8657
|
useResourceManager,
|
|
8658
|
+
useResourceUrl,
|
|
8644
8659
|
useResources,
|
|
8645
8660
|
useScriptEvaluator,
|
|
8646
8661
|
useSecret,
|