@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/dist/index.d.mts CHANGED
@@ -158,6 +158,8 @@ type AppData<State> = {
158
158
  clientId?: string;
159
159
  clientName?: string;
160
160
  clientImage?: string;
161
+ parentOrigin?: string;
162
+ enableDocumentAI?: boolean;
161
163
  };
162
164
  declare function createDefaultAppData<State>(initialState: State): AppData<State>;
163
165
  type GetAppDataOptions = {
@@ -178,6 +180,8 @@ declare function getSyncAdapter<S, M extends object = object, E extends object =
178
180
  policyAuthContext?: PolicyAuthContext;
179
181
  serverScripts?: LocalStorageSyncOptions["serverScripts"];
180
182
  git?: LocalStorageSyncOptions["git"];
183
+ parentOrigin?: string;
184
+ enableDocumentAI?: boolean;
181
185
  }): SyncAdapter<S, M, E, MenuT, I>;
182
186
  type UseNoyaStateOptions<S, M extends object = object, E extends object = object, MenuT extends string = string, I extends Record<string, any> = Record<string, unknown>> = UseMultiplayerStateOptions<S, M, E, MenuT, I> & {
183
187
  offlineStorageKey?: string;
package/dist/index.d.ts CHANGED
@@ -158,6 +158,8 @@ type AppData<State> = {
158
158
  clientId?: string;
159
159
  clientName?: string;
160
160
  clientImage?: string;
161
+ parentOrigin?: string;
162
+ enableDocumentAI?: boolean;
161
163
  };
162
164
  declare function createDefaultAppData<State>(initialState: State): AppData<State>;
163
165
  type GetAppDataOptions = {
@@ -178,6 +180,8 @@ declare function getSyncAdapter<S, M extends object = object, E extends object =
178
180
  policyAuthContext?: PolicyAuthContext;
179
181
  serverScripts?: LocalStorageSyncOptions["serverScripts"];
180
182
  git?: LocalStorageSyncOptions["git"];
183
+ parentOrigin?: string;
184
+ enableDocumentAI?: boolean;
181
185
  }): SyncAdapter<S, M, E, MenuT, I>;
182
186
  type UseNoyaStateOptions<S, M extends object = object, E extends object = object, MenuT extends string = string, I extends Record<string, any> = Record<string, unknown>> = UseMultiplayerStateOptions<S, M, E, MenuT, I> & {
183
187
  offlineStorageKey?: string;
package/dist/index.js CHANGED
@@ -7802,9 +7802,16 @@ function getSyncAdapter(params) {
7802
7802
  debug,
7803
7803
  policyAuthContext,
7804
7804
  serverScripts,
7805
- git
7805
+ git,
7806
+ parentOrigin,
7807
+ enableDocumentAI
7806
7808
  } = params ?? {};
7807
- return (0, import_state_manager3.isEmbeddedApp)() ? (0, import_state_manager3.parentFrameSync)({ debug, policyAuthContext }) : multiplayerUrl ? (0, import_state_manager3.webSocketSync)({ url: multiplayerUrl, debug }) : offlineStorageKey ? (0, import_state_manager3.localStorageSync)({
7809
+ return (0, import_state_manager3.isEmbeddedApp)() ? (0, import_state_manager3.parentFrameSync)({
7810
+ debug,
7811
+ policyAuthContext,
7812
+ origin: parentOrigin,
7813
+ enableDocumentAI
7814
+ }) : multiplayerUrl ? (0, import_state_manager3.webSocketSync)({ url: multiplayerUrl, debug }) : offlineStorageKey ? (0, import_state_manager3.localStorageSync)({
7808
7815
  key: offlineStorageKey,
7809
7816
  ...serverScripts ? { serverScripts } : {},
7810
7817
  ...git ? { git } : {}
@@ -7821,7 +7828,9 @@ function useNoyaStateInternal(...args) {
7821
7828
  viewType,
7822
7829
  userId,
7823
7830
  isDemo,
7824
- access
7831
+ access,
7832
+ parentOrigin,
7833
+ enableDocumentAI
7825
7834
  }
7826
7835
  ] = (0, import_react20.useState)(() => {
7827
7836
  return getAppData(initialState, options?.schema, {
@@ -7846,7 +7855,9 @@ function useNoyaStateInternal(...args) {
7846
7855
  debug: options?.debug,
7847
7856
  policyAuthContext: basePolicyAuthContext,
7848
7857
  serverScripts: options?.serverScripts,
7849
- git: options?.git
7858
+ git: options?.git,
7859
+ parentOrigin,
7860
+ enableDocumentAI
7850
7861
  });
7851
7862
  }, [
7852
7863
  multiplayerUrl,
@@ -7854,10 +7865,15 @@ function useNoyaStateInternal(...args) {
7854
7865
  options?.debug,
7855
7866
  basePolicyAuthContext,
7856
7867
  options?.serverScripts,
7857
- options?.git
7868
+ options?.git,
7869
+ parentOrigin,
7870
+ enableDocumentAI
7858
7871
  ]);
7859
7872
  const [noyaManager] = (0, import_react20.useState)(
7860
- () => new import_state_manager3.NoyaManager(noyaAppInitialState, options)
7873
+ () => new import_state_manager3.NoyaManager(noyaAppInitialState, {
7874
+ ...options,
7875
+ resourceUrlBase: options?.resourceUrlBase ?? parentOrigin ?? (typeof globalThis.location === "undefined" ? void 0 : globalThis.location.origin === "null" ? void 0 : globalThis.location.origin)
7876
+ })
7861
7877
  );
7862
7878
  (0, import_react20.useEffect)(() => {
7863
7879
  if (!userId) return;
@@ -7914,7 +7930,10 @@ function initializeNoyaSingleton(options) {
7914
7930
  } : void 0;
7915
7931
  noyaManagerSingleton = new import_state_manager4.NoyaManager(
7916
7932
  appData.initialState,
7917
- managerOptions
7933
+ {
7934
+ ...managerOptions,
7935
+ resourceUrlBase: managerOptions.resourceUrlBase ?? appData.parentOrigin ?? (typeof globalThis.location === "undefined" ? void 0 : globalThis.location.origin === "null" ? void 0 : globalThis.location.origin)
7936
+ }
7918
7937
  );
7919
7938
  if (appData.userId) {
7920
7939
  noyaManagerSingleton.sharedConnectionDataManager.setCurrentConnectionId(
@@ -7929,7 +7948,9 @@ function initializeNoyaSingleton(options) {
7929
7948
  debug: managerOptions?.debug,
7930
7949
  serverScripts: managerOptions?.serverScripts,
7931
7950
  git: managerOptions?.git,
7932
- policyAuthContext
7951
+ policyAuthContext,
7952
+ parentOrigin: appData.parentOrigin,
7953
+ enableDocumentAI: appData.enableDocumentAI
7933
7954
  });
7934
7955
  try {
7935
7956
  resolvedSync({ noyaManager: noyaManagerSingleton });