PageSourceSearch

https://interra.bz/s/static/builtin/chunks/chunk.DJMN7NEM.js

js interra.bz collected 2026-09-29 21:35:02 UTC 5,059 bytes, 147 lines download raw bytes

1// src/core/utils/fileServicePureFns.ts
2function fileServiceThumbnailUrlRaw(fileServiceHost, hash, width, height, oneTimeToken) {
3  if (hash.endsWith(".ico")) {
4    return fileServiceOriginalUrlRaw(fileServiceHost, hash, oneTimeToken);
5  }
6  if (!width && !height || width && height && !(width > 0 && height > 0)) {
7    width = 800;
8    height = void 0;
9  }
10  const size = (width ? width : "") + "x" + (height ? height : "");
11  return `${fileServiceHost}/thumbnail${oneTimeToken ? `/p/${oneTimeToken}` : ""}/${hash}/s/${size}`;
12}
13function fileServiceDownloadUrlRaw(fileServiceHost, hash, oneTimeToken) {
14  return `${fileServiceHost}/download${oneTimeToken ? `/p/${oneTimeToken}` : ""}/${hash}`;
15}
16function fileServiceOriginalUrlRaw(fileServiceHost, hash, oneTimeToken) {
17  return `${fileServiceHost}/get${oneTimeToken ? `/p/${oneTimeToken}` : ""}/${hash}`;
18}
19function getFileTypeFromHash(hash) {
20  if (hash.startsWith("video_")) {
21    return "video";
22  }
23  if (hash.startsWith("audio_")) {
24    return "audio";
25  }
26  if (hash.startsWith("image_")) {
27    return "image";
28  }
29  return "file";
30}
31function getDurationFromHash(hash) {
32  if (hash) {
33    const parts = hash.split(".");
34    if (parts.length > 2 && parts[1].startsWith("d")) {
35      return Number(parts[1].substring(1));
36    }
37  }
38  return void 0;
39}
40function getSizesFromHash(hash) {
41  if (!hash) {
42    return void 0;
43  }
44  const parts = hash.split(".");
45  for (let i = 1; i < parts.length; i++) {
46    if (startsWithDigit(parts[i])) {
47      const sizeParts = parts[i].split("x");
48      if (sizeParts.length === 2) {
49        return {
50          width: Math.round(Number.parseInt(sizeParts[0])),
51          height: Math.round(Number.parseInt(sizeParts[1]))
52        };
53      }
54    }
55  }
56  return void 0;
57}
58function isProtectedFileHash(hash) {
59  const dotIndex = hash.indexOf(".");
60  return dotIndex === -1 ? hash.endsWith("_p") : hash.slice(dotIndex - 2, dotIndex) === "_p";
61}
62function changeExtensionInHash(hash, newExtension) {
63  return hash.replace(/\.\w+$/, newExtension);
64}
65function getAudioTrackHash(hash) {
66  return getFileTypeFromHash(hash) === "video" ? changeExtensionInHash(hash, ".m4a") : hash;
67}
68function startsWithDigit(str) {
69  return firstDigitRe.test(str);
70}
71var firstDigitRe = /^\d/;
72
73// src/services/ugc-runner/runtime/utils/fsUtils.browser.ts
74function getUploadGetPutUrlImpl(_ctx, _options) {
75  const fsGetPutUrl = getBrowserInternals().helpers?.fsGetPutUrl;
76  if (fsGetPutUrl) {
77    return fsGetPutUrl;
78  }
79  throw new Error(`Upload getPutUrl is not provided in browser environment`);
80}
81function getDownloadUrlImpl(ctx, hash) {
82  const fileHash = extractHash(hash);
83  if (fileHash && isProtectedFileHash(fileHash)) {
84    throw new Error(`Can't generate download URL for protected file '${fileHash}' in browser environment`);
85  }
86  return fileServiceDownloadUrlRaw(getFsHostByCtx(ctx), fileHash);
87}
88function getThumbnailUrlImpl(ctx, hash, width, height) {
89  const fileHash = extractHash(hash);
90  if (fileHash && isProtectedFileHash(fileHash)) {
91    throw new Error(`Can't generate thumbnail URL for protected file '${fileHash}' in browser environment`);
92  }
93  return fileServiceThumbnailUrlRaw(getFsHostByCtx(ctx), fileHash, width, height);
94}
95function getPublicThumbnailUrlImpl(ctx, hash, width, height) {
96  return fileServiceThumbnailUrlRaw(getFsHostByCtx(ctx), extractHash(hash), width, height);
97}
98function getPublicFileUrlImpl(ctx, hash) {
99  return fileServiceOriginalUrlRaw(getFsHostByCtx(ctx), extractHash(hash));
100}
101function getOriginalUrlImpl(ctx, hash) {
102  const fileHash = extractHash(hash);
103  if (fileHash && isProtectedFileHash(fileHash)) {
104    throw new Error(`Can't generate thumbnail URL for protected file '${fileHash}' in browser environment`);
105  }
106  return fileServiceOriginalUrlRaw(getFsHostByCtx(ctx), fileHash);
107}
108function getThumbnailUrlByIdImpl(_ctx, _id, _width, _height) {
109  throw new Error(`By ID file storage operations are not provided in browser environment`);
110}
111function getDownloadUrlByIdImpl(_ctx, _id) {
112  throw new Error(`By ID file storage operations are not provided in browser environment`);
113}
114async function createSharedDownloadUrlImpl(_ctx, _type, _hash, _options) {
115  throw new Error(`This method is not supported in browser environment`);
116}
117function getFsHostByCtx(ctx) {
118  return "RU" === ctx?.location?.country ? __ugc_internals__.out.fileService.fileServiceHost : __ugc_internals__.out.fileService.fileServiceCdnHost;
119}
120function extractHash(hash) {
121  return isHashHolder(hash) ? hash.hash : hash;
122}
123function isHashHolder(value) {
124  if (!value || typeof value !== "object") {
125    return false;
126  }
127  return typeof value.hash === "string";
128}
129function getBrowserInternals() {
130  return window.__ugc_internals__ ?? {};
131}
132
133export {
134  getFileTypeFromHash,
135  getDurationFromHash,
136  getSizesFromHash,
137  getAudioTrackHash,
138  getUploadGetPutUrlImpl,
139  getDownloadUrlImpl,
140  getThumbnailUrlImpl,
141  getPublicThumbnailUrlImpl,
142  getPublicFileUrlImpl,
143  getOriginalUrlImpl,
144  getThumbnailUrlByIdImpl,
145  getDownloadUrlByIdImpl,
146  createSharedDownloadUrlImpl
147};

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.