@noya-app/noya-multiplayer-react 0.1.85 → 0.1.87
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 +15 -0
- package/dist/index.bundle.js +37 -53
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +29 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/noyaApp.ts +30 -2
- package/src/singleton.tsx +13 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noya-app/noya-multiplayer-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.87",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dev": "npm run build -- --watch"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@noya-app/state-manager": "0.1.
|
|
14
|
+
"@noya-app/state-manager": "0.1.69",
|
|
15
15
|
"@noya-app/emitter": "0.1.0",
|
|
16
16
|
"@noya-app/observable": "0.1.12",
|
|
17
17
|
"@noya-app/task-runner": "0.1.7",
|
package/src/noyaApp.ts
CHANGED
|
@@ -40,6 +40,8 @@ export type AppData<State> = {
|
|
|
40
40
|
clientId?: string;
|
|
41
41
|
clientName?: string;
|
|
42
42
|
clientImage?: string;
|
|
43
|
+
parentOrigin?: string;
|
|
44
|
+
enableDocumentAI?: boolean;
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
export function createDefaultAppData<State>(
|
|
@@ -150,6 +152,8 @@ export function getSyncAdapter<
|
|
|
150
152
|
policyAuthContext?: PolicyAuthContext;
|
|
151
153
|
serverScripts?: LocalStorageSyncOptions["serverScripts"];
|
|
152
154
|
git?: LocalStorageSyncOptions["git"];
|
|
155
|
+
parentOrigin?: string;
|
|
156
|
+
enableDocumentAI?: boolean;
|
|
153
157
|
}): SyncAdapter<S, M, E, MenuT, I> {
|
|
154
158
|
const {
|
|
155
159
|
multiplayerUrl,
|
|
@@ -158,10 +162,17 @@ export function getSyncAdapter<
|
|
|
158
162
|
policyAuthContext,
|
|
159
163
|
serverScripts,
|
|
160
164
|
git,
|
|
165
|
+
parentOrigin,
|
|
166
|
+
enableDocumentAI,
|
|
161
167
|
} = params ?? {};
|
|
162
168
|
|
|
163
169
|
return isEmbeddedApp()
|
|
164
|
-
? parentFrameSync<S, M, E, MenuT, I>({
|
|
170
|
+
? parentFrameSync<S, M, E, MenuT, I>({
|
|
171
|
+
debug,
|
|
172
|
+
policyAuthContext,
|
|
173
|
+
origin: parentOrigin,
|
|
174
|
+
enableDocumentAI,
|
|
175
|
+
})
|
|
165
176
|
: multiplayerUrl
|
|
166
177
|
? webSocketSync<S, M, E, MenuT, I>({ url: multiplayerUrl, debug })
|
|
167
178
|
: offlineStorageKey
|
|
@@ -258,6 +269,8 @@ export function useNoyaStateInternal<
|
|
|
258
269
|
userId,
|
|
259
270
|
isDemo,
|
|
260
271
|
access,
|
|
272
|
+
parentOrigin,
|
|
273
|
+
enableDocumentAI,
|
|
261
274
|
},
|
|
262
275
|
] = useState(() => {
|
|
263
276
|
return getAppData(initialState, options?.schema, {
|
|
@@ -289,6 +302,8 @@ export function useNoyaStateInternal<
|
|
|
289
302
|
policyAuthContext: basePolicyAuthContext,
|
|
290
303
|
serverScripts: options?.serverScripts,
|
|
291
304
|
git: options?.git,
|
|
305
|
+
parentOrigin,
|
|
306
|
+
enableDocumentAI,
|
|
292
307
|
});
|
|
293
308
|
}, [
|
|
294
309
|
multiplayerUrl,
|
|
@@ -297,10 +312,23 @@ export function useNoyaStateInternal<
|
|
|
297
312
|
basePolicyAuthContext,
|
|
298
313
|
options?.serverScripts,
|
|
299
314
|
options?.git,
|
|
315
|
+
parentOrigin,
|
|
316
|
+
enableDocumentAI,
|
|
300
317
|
]);
|
|
301
318
|
|
|
302
319
|
const [noyaManager] = useState(
|
|
303
|
-
() =>
|
|
320
|
+
() =>
|
|
321
|
+
new NoyaManager<S, M, E, MenuT, I>(noyaAppInitialState as S, {
|
|
322
|
+
...options,
|
|
323
|
+
resourceUrlBase:
|
|
324
|
+
options?.resourceUrlBase ??
|
|
325
|
+
parentOrigin ??
|
|
326
|
+
(typeof globalThis.location === "undefined"
|
|
327
|
+
? undefined
|
|
328
|
+
: globalThis.location.origin === "null"
|
|
329
|
+
? undefined
|
|
330
|
+
: globalThis.location.origin),
|
|
331
|
+
})
|
|
304
332
|
);
|
|
305
333
|
|
|
306
334
|
useEffect(() => {
|
package/src/singleton.tsx
CHANGED
|
@@ -89,7 +89,17 @@ export function initializeNoyaSingleton<
|
|
|
89
89
|
|
|
90
90
|
noyaManagerSingleton = new NoyaManager<S, M, E, MenuT, I>(
|
|
91
91
|
appData.initialState as S,
|
|
92
|
-
|
|
92
|
+
{
|
|
93
|
+
...managerOptions,
|
|
94
|
+
resourceUrlBase:
|
|
95
|
+
managerOptions.resourceUrlBase ??
|
|
96
|
+
appData.parentOrigin ??
|
|
97
|
+
(typeof globalThis.location === "undefined"
|
|
98
|
+
? undefined
|
|
99
|
+
: globalThis.location.origin === "null"
|
|
100
|
+
? undefined
|
|
101
|
+
: globalThis.location.origin),
|
|
102
|
+
}
|
|
93
103
|
);
|
|
94
104
|
|
|
95
105
|
if (appData.userId) {
|
|
@@ -109,6 +119,8 @@ export function initializeNoyaSingleton<
|
|
|
109
119
|
serverScripts: managerOptions?.serverScripts,
|
|
110
120
|
git: managerOptions?.git,
|
|
111
121
|
policyAuthContext,
|
|
122
|
+
parentOrigin: appData.parentOrigin,
|
|
123
|
+
enableDocumentAI: appData.enableDocumentAI,
|
|
112
124
|
});
|
|
113
125
|
|
|
114
126
|
// Activate sync immediately for the singleton
|