Bin
2025-12-17 21f0498f62ada55651f4d232327e15fc47f498b1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import AppStore from "./stores/AppStore";
 
// Get environment settings
const getEnvironment = async () => {
  /* istanbul ignore next */
  if (process.env.NODE_ENV === "development" && !process.env.BUILD_NO_SERVER) {
    return (await import("./env/development")).default;
  }
 
  return (await import("./env/production")).default;
};
 
// Configure default store
export const configureStore = async (params, events) => {
  if (params.options?.secureMode) window.LS_SECURE_MODE = true;
 
  const env = await getEnvironment();
 
  params = { ...params };
 
  // Support forceBottomPanel option
  if (params?.settings?.forceBottomPanel) {
    params.bottomSidePanel = true;
    params.settings = { ...(params.settings || {}), forceBottomPanel: true };
  }
 
  if (!params?.config && env.getExample) {
    const { task, config } = await env.getExample();
 
    params.config = config;
    params.task = task;
  } else if (params?.task) {
    params.task = env.getData(params.task);
  }
  if (params.task?.id) {
    params.taskHistory = [{ taskId: params.task.id, annotationId: null }];
  }
 
  const store = AppStore.create(params, {
    ...env.configureApplication(params),
    events,
  });
 
  store.initializeStore({
    ...(params.task ?? {}),
    // allow external integrations to control when the app is fully hydrated
    // default behaviour is to consider this point as hydrated
    hydrated: params?.hydrated ?? true,
    users: params.users ?? [],
    annotationHistory: params.history ?? [],
  });
 
  return { store, getRoot: env.rootElement };
};