PageSourceSearch

https://site.fr/_static/8c8af5c529149f32/scripts/features/dashboard/domain-detail/shared/lazy-tab-registry.js

js site.fr collected 2026-09-24 18:22:21 UTC 2,107 bytes, 85 lines download raw bytes

1const createLazyTabRegistry = (definitions = {}) => {
2  const records = new Map(
3    Object.entries(definitions).map(([key, definition]) => [
4      key,
5      {
6        key,
7        load: definition?.load,
8        module: definition?.module || null,
9        pending: null,
10        error: null,
11      },
12    ]),
13  );
14
15  const getRecord = (key) => records.get(String(key || '')) || null;
16
17  const get = (key) => getRecord(key)?.module || null;
18
19  const getError = (key) => getRecord(key)?.error || null;
20
21  const getStatus = (key) => {
22    const record = getRecord(key);
23    if (!record) {
24      return 'missing';
25    }
26    if (record.module) {
27      return 'loaded';
28    }
29    if (record.pending) {
30      return 'loading';
31    }
32    if (record.error) {
33      return 'error';
34    }
35    return 'idle';
36  };
37
38  const load = (key, { retry = false } = {}) => {
39    const record = getRecord(key);
40    if (!record || typeof record.load !== 'function') {
41      return Promise.reject(new Error(`Unknown dashboard domain-detail tab: ${String(key || '')}`));
42    }
43    if (record.module) {
44      return Promise.resolve(record.module);
45    }
46    if (record.pending) {
47      return record.pending;
48    }
49    if (record.error && !retry) {
50      return Promise.reject(record.error);
51    }
52
53    record.error = null;
54    const pending = Promise.resolve()
55      .then(() => record.load())
56      .then((tabModule) => {
57        if (!tabModule || typeof tabModule.render !== 'function') {
58          throw new TypeError(`Invalid dashboard domain-detail tab module: ${record.key}`);
59        }
60        record.module = tabModule;
61        return tabModule;
62      })
63      .catch((error) => {
64        record.error = error instanceof Error ? error : new Error(String(error || 'Failed to load tab module'));
65        throw record.error;
66      })
67      .finally(() => {
68        if (record.pending === pending) {
69          record.pending = null;
70        }
71      });
72
73    record.pending = pending;
74    return pending;
75  };
76
77  return Object.freeze({
78    get,
79    getError,
80    getStatus,
81    load,
82  });
83};
84
85export { createLazyTabRegistry };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.