@noya-app/noya-multiplayer-react 0.1.84 → 0.1.86
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 +16 -0
- package/dist/index.bundle.js +37 -50
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +64 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -23
- 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/noyaApp.ts +30 -2
- package/src/singleton.tsx +13 -1
- package/src/useResourceUrl.ts +19 -0
package/dist/index.mjs
CHANGED
|
@@ -7764,9 +7764,16 @@ function getSyncAdapter(params) {
|
|
|
7764
7764
|
debug,
|
|
7765
7765
|
policyAuthContext,
|
|
7766
7766
|
serverScripts,
|
|
7767
|
-
git
|
|
7767
|
+
git,
|
|
7768
|
+
parentOrigin,
|
|
7769
|
+
enableDocumentAI
|
|
7768
7770
|
} = params ?? {};
|
|
7769
|
-
return isEmbeddedApp() ? parentFrameSync({
|
|
7771
|
+
return isEmbeddedApp() ? parentFrameSync({
|
|
7772
|
+
debug,
|
|
7773
|
+
policyAuthContext,
|
|
7774
|
+
origin: parentOrigin,
|
|
7775
|
+
enableDocumentAI
|
|
7776
|
+
}) : multiplayerUrl ? webSocketSync({ url: multiplayerUrl, debug }) : offlineStorageKey ? localStorageSync({
|
|
7770
7777
|
key: offlineStorageKey,
|
|
7771
7778
|
...serverScripts ? { serverScripts } : {},
|
|
7772
7779
|
...git ? { git } : {}
|
|
@@ -7783,7 +7790,9 @@ function useNoyaStateInternal(...args) {
|
|
|
7783
7790
|
viewType,
|
|
7784
7791
|
userId,
|
|
7785
7792
|
isDemo,
|
|
7786
|
-
access
|
|
7793
|
+
access,
|
|
7794
|
+
parentOrigin,
|
|
7795
|
+
enableDocumentAI
|
|
7787
7796
|
}
|
|
7788
7797
|
] = useState4(() => {
|
|
7789
7798
|
return getAppData(initialState, options?.schema, {
|
|
@@ -7808,7 +7817,9 @@ function useNoyaStateInternal(...args) {
|
|
|
7808
7817
|
debug: options?.debug,
|
|
7809
7818
|
policyAuthContext: basePolicyAuthContext,
|
|
7810
7819
|
serverScripts: options?.serverScripts,
|
|
7811
|
-
git: options?.git
|
|
7820
|
+
git: options?.git,
|
|
7821
|
+
parentOrigin,
|
|
7822
|
+
enableDocumentAI
|
|
7812
7823
|
});
|
|
7813
7824
|
}, [
|
|
7814
7825
|
multiplayerUrl,
|
|
@@ -7816,10 +7827,15 @@ function useNoyaStateInternal(...args) {
|
|
|
7816
7827
|
options?.debug,
|
|
7817
7828
|
basePolicyAuthContext,
|
|
7818
7829
|
options?.serverScripts,
|
|
7819
|
-
options?.git
|
|
7830
|
+
options?.git,
|
|
7831
|
+
parentOrigin,
|
|
7832
|
+
enableDocumentAI
|
|
7820
7833
|
]);
|
|
7821
7834
|
const [noyaManager] = useState4(
|
|
7822
|
-
() => new NoyaManager3(noyaAppInitialState,
|
|
7835
|
+
() => new NoyaManager3(noyaAppInitialState, {
|
|
7836
|
+
...options,
|
|
7837
|
+
resourceUrlBase: options?.resourceUrlBase ?? parentOrigin ?? (typeof globalThis.location === "undefined" ? void 0 : globalThis.location.origin === "null" ? void 0 : globalThis.location.origin)
|
|
7838
|
+
})
|
|
7823
7839
|
);
|
|
7824
7840
|
useEffect5(() => {
|
|
7825
7841
|
if (!userId) return;
|
|
@@ -7878,7 +7894,10 @@ function initializeNoyaSingleton(options) {
|
|
|
7878
7894
|
} : void 0;
|
|
7879
7895
|
noyaManagerSingleton = new NoyaManager4(
|
|
7880
7896
|
appData.initialState,
|
|
7881
|
-
|
|
7897
|
+
{
|
|
7898
|
+
...managerOptions,
|
|
7899
|
+
resourceUrlBase: managerOptions.resourceUrlBase ?? appData.parentOrigin ?? (typeof globalThis.location === "undefined" ? void 0 : globalThis.location.origin === "null" ? void 0 : globalThis.location.origin)
|
|
7900
|
+
}
|
|
7882
7901
|
);
|
|
7883
7902
|
if (appData.userId) {
|
|
7884
7903
|
noyaManagerSingleton.sharedConnectionDataManager.setCurrentConnectionId(
|
|
@@ -7893,7 +7912,9 @@ function initializeNoyaSingleton(options) {
|
|
|
7893
7912
|
debug: managerOptions?.debug,
|
|
7894
7913
|
serverScripts: managerOptions?.serverScripts,
|
|
7895
7914
|
git: managerOptions?.git,
|
|
7896
|
-
policyAuthContext
|
|
7915
|
+
policyAuthContext,
|
|
7916
|
+
parentOrigin: appData.parentOrigin,
|
|
7917
|
+
enableDocumentAI: appData.enableDocumentAI
|
|
7897
7918
|
});
|
|
7898
7919
|
try {
|
|
7899
7920
|
resolvedSync({ noyaManager: noyaManagerSingleton });
|
|
@@ -8009,22 +8030,23 @@ function buildResourcePatchPayload({
|
|
|
8009
8030
|
return patch;
|
|
8010
8031
|
}
|
|
8011
8032
|
var AnyNoyaStateContext = createContext(void 0);
|
|
8012
|
-
function
|
|
8033
|
+
function useOptionalAnyNoyaStateContext() {
|
|
8013
8034
|
const value = useContext(AnyNoyaStateContext);
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8035
|
+
const bindings = getNoyaSingletonBindings();
|
|
8036
|
+
if (value) return value;
|
|
8037
|
+
if (!bindings) return void 0;
|
|
8038
|
+
return {
|
|
8039
|
+
noyaManager: getNoyaManagerSingleton(),
|
|
8040
|
+
theme: bindings.theme,
|
|
8041
|
+
viewType: bindings.viewType
|
|
8042
|
+
};
|
|
8043
|
+
}
|
|
8044
|
+
function useAnyNoyaStateContext() {
|
|
8045
|
+
const value = useOptionalAnyNoyaStateContext();
|
|
8046
|
+
if (value) return value;
|
|
8047
|
+
throw new Error(
|
|
8048
|
+
"useNoyaStateContext must be used within a NoyaStateProvider"
|
|
8049
|
+
);
|
|
8028
8050
|
}
|
|
8029
8051
|
function useAnyNoyaManager() {
|
|
8030
8052
|
const { noyaManager } = useAnyNoyaStateContext();
|
|
@@ -8498,6 +8520,18 @@ var UserPointersOverlay = memoGeneric2(function UserPointers({
|
|
|
8498
8520
|
}));
|
|
8499
8521
|
});
|
|
8500
8522
|
|
|
8523
|
+
// src/useResourceUrl.ts
|
|
8524
|
+
import { getResourceUrl } from "@noya-app/state-manager";
|
|
8525
|
+
function useResourceUrl(idOrStableId) {
|
|
8526
|
+
const { noyaManager } = useAnyNoyaStateContext();
|
|
8527
|
+
const resources = useObservable(
|
|
8528
|
+
noyaManager.resourceManager.optimisticResources$
|
|
8529
|
+
);
|
|
8530
|
+
const assets = useObservable(noyaManager.assetManager.assets$);
|
|
8531
|
+
if (!idOrStableId) return void 0;
|
|
8532
|
+
return getResourceUrl(idOrStableId, resources, assets);
|
|
8533
|
+
}
|
|
8534
|
+
|
|
8501
8535
|
// src/WebSocketConnection.ts
|
|
8502
8536
|
import {
|
|
8503
8537
|
ReconnectingWebSocket,
|
|
@@ -8636,11 +8670,13 @@ export {
|
|
|
8636
8670
|
useNoyaUserManager,
|
|
8637
8671
|
useNoyaUsers,
|
|
8638
8672
|
useObservable,
|
|
8673
|
+
useOptionalAnyNoyaStateContext,
|
|
8639
8674
|
useOutputTransforms,
|
|
8640
8675
|
usePipelineManager,
|
|
8641
8676
|
usePublish,
|
|
8642
8677
|
useRegisterAITool,
|
|
8643
8678
|
useResourceManager,
|
|
8679
|
+
useResourceUrl,
|
|
8644
8680
|
useResources,
|
|
8645
8681
|
useScriptEvaluator,
|
|
8646
8682
|
useSecret,
|