@openuiai/next 16.2.0 → 16.2.1
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/bin/next +2 -2
- package/dist/build/index.js +3 -3
- package/dist/build/webpack-config.js +2 -2
- package/dist/cache/cache-control.js +22 -0
- package/dist/cache/cache-control.js.map +1 -0
- package/dist/cache/clone-response.js +77 -0
- package/dist/cache/clone-response.js.map +1 -0
- package/dist/cache/dedupe-fetch.js +123 -0
- package/dist/cache/dedupe-fetch.js.map +1 -0
- package/dist/cache/lazy-result.js +46 -0
- package/dist/cache/lazy-result.js.map +1 -0
- package/dist/cache/lru-cache.js +177 -0
- package/dist/cache/lru-cache.js.map +1 -0
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/concurrency/batcher.js +65 -0
- package/dist/concurrency/batcher.js.map +1 -0
- package/dist/concurrency/coalesced-function.js +39 -0
- package/dist/concurrency/coalesced-function.js.map +1 -0
- package/dist/concurrency/scheduler.js +64 -0
- package/dist/concurrency/scheduler.js.map +1 -0
- package/dist/concurrency/wait.js +19 -0
- package/dist/concurrency/wait.js.map +1 -0
- package/dist/concurrency/with-promise-cache.js +24 -0
- package/dist/concurrency/with-promise-cache.js.map +1 -0
- package/dist/config/detect-typo.js +51 -0
- package/dist/config/detect-typo.js.map +1 -0
- package/dist/config/find-config.js +102 -0
- package/dist/config/find-config.js.map +1 -0
- package/dist/config/get-package-version.js +118 -0
- package/dist/config/get-package-version.js.map +1 -0
- package/dist/config/get-project-dir.js +51 -0
- package/dist/config/get-project-dir.js.map +1 -0
- package/dist/config/install-dependencies.js +40 -0
- package/dist/config/install-dependencies.js.map +1 -0
- package/dist/config/needs-experimental-react.js +16 -0
- package/dist/config/needs-experimental-react.js.map +1 -0
- package/dist/config/static-env.js +92 -0
- package/dist/config/static-env.js.map +1 -0
- package/dist/constants/constants.js +397 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/errors/compile-error.js +14 -0
- package/dist/errors/compile-error.js.map +1 -0
- package/dist/errors/error-source.js +36 -0
- package/dist/errors/error-source.js.map +1 -0
- package/dist/errors/error-telemetry-utils.js +42 -0
- package/dist/errors/error-telemetry-utils.js.map +1 -0
- package/dist/errors/fatal-error.js +14 -0
- package/dist/errors/fatal-error.js.map +1 -0
- package/dist/errors/format-server-error.js +74 -0
- package/dist/errors/format-server-error.js.map +1 -0
- package/dist/errors/invariant-error.js +18 -0
- package/dist/errors/invariant-error.js.map +1 -0
- package/dist/errors/is-error.js +65 -0
- package/dist/errors/is-error.js.map +1 -0
- package/dist/errors/no-fallback-error.js +18 -0
- package/dist/errors/no-fallback-error.js.map +1 -0
- package/dist/esm/build/index.js +3 -3
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/filesystem/file-exists.js +53 -0
- package/dist/filesystem/file-exists.js.map +1 -0
- package/dist/filesystem/find-pages-dir.js +65 -0
- package/dist/filesystem/find-pages-dir.js.map +1 -0
- package/dist/filesystem/find-root.js +118 -0
- package/dist/filesystem/find-root.js.map +1 -0
- package/dist/filesystem/get-files-in-dir.js +33 -0
- package/dist/filesystem/get-files-in-dir.js.map +1 -0
- package/dist/filesystem/multi-file-writer.js +75 -0
- package/dist/filesystem/multi-file-writer.js.map +1 -0
- package/dist/filesystem/realpath.js +20 -0
- package/dist/filesystem/realpath.js.map +1 -0
- package/dist/filesystem/recursive-copy.js +76 -0
- package/dist/filesystem/recursive-copy.js.map +1 -0
- package/dist/filesystem/recursive-delete.js +137 -0
- package/dist/filesystem/recursive-delete.js.map +1 -0
- package/dist/filesystem/recursive-readdir.js +124 -0
- package/dist/filesystem/recursive-readdir.js.map +1 -0
- package/dist/filesystem/rename.js +87 -0
- package/dist/filesystem/rename.js.map +1 -0
- package/dist/filesystem/write-atomic.js +28 -0
- package/dist/filesystem/write-atomic.js.map +1 -0
- package/dist/fonts/font-utils.js +43 -0
- package/dist/fonts/font-utils.js.map +1 -0
- package/dist/fonts/get-preloadable-fonts.js +39 -0
- package/dist/fonts/get-preloadable-fonts.js.map +1 -0
- package/dist/hash/bloom-filter.js +85 -0
- package/dist/hash/bloom-filter.js.map +1 -0
- package/dist/hash/etag.js +56 -0
- package/dist/hash/etag.js.map +1 -0
- package/dist/hash/fnv1a.js +56 -0
- package/dist/hash/fnv1a.js.map +1 -0
- package/dist/hash/hash.js +39 -0
- package/dist/hash/hash.js.map +1 -0
- package/dist/hostname/format-hostname.js +16 -0
- package/dist/hostname/format-hostname.js.map +1 -0
- package/dist/hostname/get-hostname.js +23 -0
- package/dist/hostname/get-hostname.js.map +1 -0
- package/dist/hostname/get-network-host.js +44 -0
- package/dist/hostname/get-network-host.js.map +1 -0
- package/dist/hostname/is-ipv6.js +41 -0
- package/dist/hostname/is-ipv6.js.map +1 -0
- package/dist/image/find-closest-quality.js +19 -0
- package/dist/image/find-closest-quality.js.map +1 -0
- package/dist/image/get-img-props.js +573 -0
- package/dist/image/get-img-props.js.map +1 -0
- package/dist/image/image-blur-svg.js +22 -0
- package/dist/image/image-blur-svg.js.map +1 -0
- package/dist/image/image-config-context.shared-runtime.js +19 -0
- package/dist/image/image-config-context.shared-runtime.js.map +1 -0
- package/dist/image/image-config.js +74 -0
- package/dist/image/image-config.js.map +1 -0
- package/dist/image/image-loader.js +91 -0
- package/dist/image/image-loader.js.map +1 -0
- package/dist/image/image-optimizer.js +1019 -0
- package/dist/image/image-optimizer.js.map +1 -0
- package/dist/image/match-local-pattern.js +46 -0
- package/dist/image/match-local-pattern.js.map +1 -0
- package/dist/image/match-remote-pattern.js +63 -0
- package/dist/image/match-remote-pattern.js.map +1 -0
- package/dist/image/mime-type.js +20 -0
- package/dist/image/mime-type.js.map +1 -0
- package/dist/memory/gc-observer.js +53 -0
- package/dist/memory/gc-observer.js.map +1 -0
- package/dist/memory/shutdown.js +29 -0
- package/dist/memory/shutdown.js.map +1 -0
- package/dist/memory/startup.js +47 -0
- package/dist/memory/startup.js.map +1 -0
- package/dist/memory/trace.js +109 -0
- package/dist/memory/trace.js.map +1 -0
- package/dist/module/client-and-server-references.js +54 -0
- package/dist/module/client-and-server-references.js.map +1 -0
- package/dist/module/format-dynamic-import-path.js +24 -0
- package/dist/module/format-dynamic-import-path.js.map +1 -0
- package/dist/module/interop-default.js +15 -0
- package/dist/module/interop-default.js.map +1 -0
- package/dist/module/resolve-from.js +79 -0
- package/dist/module/resolve-from.js.map +1 -0
- package/dist/module/semver-noop.js +18 -0
- package/dist/module/semver-noop.js.map +1 -0
- package/dist/object/deep-freeze.js +30 -0
- package/dist/object/deep-freeze.js.map +1 -0
- package/dist/object/deep-readonly.js +10 -0
- package/dist/object/deep-readonly.js.map +1 -0
- package/dist/object/is-plain-object.js +42 -0
- package/dist/object/is-plain-object.js.map +1 -0
- package/dist/object/non-nullable.js +15 -0
- package/dist/object/non-nullable.js.map +1 -0
- package/dist/object/pick.js +19 -0
- package/dist/object/pick.js.map +1 -0
- package/dist/process/setup-exception-listeners.js +11 -0
- package/dist/process/setup-exception-listeners.js.map +1 -0
- package/dist/promise/detached-promise.js +32 -0
- package/dist/promise/detached-promise.js.map +1 -0
- package/dist/promise/is-thenable.js +20 -0
- package/dist/promise/is-thenable.js.map +1 -0
- package/dist/promise/promise-with-resolvers.js +26 -0
- package/dist/promise/promise-with-resolvers.js.map +1 -0
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/string/encode-uri-path.js +15 -0
- package/dist/string/encode-uri-path.js.map +1 -0
- package/dist/string/escape-regexp.js +22 -0
- package/dist/string/escape-regexp.js.map +1 -0
- package/dist/string/normalize-path.js +21 -0
- package/dist/string/normalize-path.js.map +1 -0
- package/dist/string/oxford-comma-list.js +15 -0
- package/dist/string/oxford-comma-list.js.map +1 -0
- package/dist/string/pretty-bytes.js +74 -0
- package/dist/string/pretty-bytes.js.map +1 -0
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/dist/typescript/diagnosticFormatter.js +240 -0
- package/dist/typescript/diagnosticFormatter.js.map +1 -0
- package/dist/typescript/getTypeScriptConfiguration.js +73 -0
- package/dist/typescript/getTypeScriptConfiguration.js.map +1 -0
- package/dist/typescript/getTypeScriptIntent.js +52 -0
- package/dist/typescript/getTypeScriptIntent.js.map +1 -0
- package/dist/typescript/missingDependencyError.js +27 -0
- package/dist/typescript/missingDependencyError.js.map +1 -0
- package/dist/typescript/runTypeCheck.js +95 -0
- package/dist/typescript/runTypeCheck.js.map +1 -0
- package/dist/typescript/writeAppTypeDeclarations.js +65 -0
- package/dist/typescript/writeAppTypeDeclarations.js.map +1 -0
- package/dist/typescript/writeConfigurationDefaults.js +403 -0
- package/dist/typescript/writeConfigurationDefaults.js.map +1 -0
- package/dist/validation/is-serializable-props.js +106 -0
- package/dist/validation/is-serializable-props.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "calculateSizeAdjustValues", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return calculateSizeAdjustValues;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _constants = require("../shared/lib/constants");
|
|
12
|
+
const capsizeFontsMetrics = require('next/dist/server/capsize-font-metrics.json');
|
|
13
|
+
function formatName(str) {
|
|
14
|
+
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
|
|
15
|
+
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
16
|
+
}).replace(/\s+/g, '');
|
|
17
|
+
}
|
|
18
|
+
function formatOverrideValue(val) {
|
|
19
|
+
return Math.abs(val * 100).toFixed(2);
|
|
20
|
+
}
|
|
21
|
+
function calculateSizeAdjustValues(fontName) {
|
|
22
|
+
const fontKey = formatName(fontName);
|
|
23
|
+
const fontMetrics = capsizeFontsMetrics[fontKey];
|
|
24
|
+
let { category, ascent, descent, lineGap, unitsPerEm, xWidthAvg } = fontMetrics;
|
|
25
|
+
const mainFontAvgWidth = xWidthAvg / unitsPerEm;
|
|
26
|
+
const fallbackFont = category === 'serif' ? _constants.DEFAULT_SERIF_FONT : _constants.DEFAULT_SANS_SERIF_FONT;
|
|
27
|
+
const fallbackFontName = formatName(fallbackFont.name);
|
|
28
|
+
const fallbackFontMetrics = capsizeFontsMetrics[fallbackFontName];
|
|
29
|
+
const fallbackFontAvgWidth = fallbackFontMetrics.xWidthAvg / fallbackFontMetrics.unitsPerEm;
|
|
30
|
+
let sizeAdjust = xWidthAvg ? mainFontAvgWidth / fallbackFontAvgWidth : 1;
|
|
31
|
+
ascent = formatOverrideValue(ascent / (unitsPerEm * sizeAdjust));
|
|
32
|
+
descent = formatOverrideValue(descent / (unitsPerEm * sizeAdjust));
|
|
33
|
+
lineGap = formatOverrideValue(lineGap / (unitsPerEm * sizeAdjust));
|
|
34
|
+
return {
|
|
35
|
+
ascent,
|
|
36
|
+
descent,
|
|
37
|
+
lineGap,
|
|
38
|
+
fallbackFont: fallbackFont.name,
|
|
39
|
+
sizeAdjust: formatOverrideValue(sizeAdjust)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=font-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../fonts/font-utils.ts"],"sourcesContent":["import {\n DEFAULT_SERIF_FONT,\n DEFAULT_SANS_SERIF_FONT,\n} from '../shared/lib/constants'\nconst capsizeFontsMetrics = require('next/dist/server/capsize-font-metrics.json')\n\nfunction formatName(str: string): string {\n return str\n .replace(/(?:^\\w|[A-Z]|\\b\\w)/g, function (word, index) {\n return index === 0 ? word.toLowerCase() : word.toUpperCase()\n })\n .replace(/\\s+/g, '')\n}\n\nfunction formatOverrideValue(val: number) {\n return Math.abs(val * 100).toFixed(2)\n}\n\nexport function calculateSizeAdjustValues(fontName: string) {\n const fontKey = formatName(fontName)\n const fontMetrics = capsizeFontsMetrics[fontKey]\n let { category, ascent, descent, lineGap, unitsPerEm, xWidthAvg } =\n fontMetrics\n const mainFontAvgWidth = xWidthAvg / unitsPerEm\n const fallbackFont =\n category === 'serif' ? DEFAULT_SERIF_FONT : DEFAULT_SANS_SERIF_FONT\n const fallbackFontName = formatName(fallbackFont.name)\n const fallbackFontMetrics = capsizeFontsMetrics[fallbackFontName]\n const fallbackFontAvgWidth =\n fallbackFontMetrics.xWidthAvg / fallbackFontMetrics.unitsPerEm\n let sizeAdjust = xWidthAvg ? mainFontAvgWidth / fallbackFontAvgWidth : 1\n\n ascent = formatOverrideValue(ascent / (unitsPerEm * sizeAdjust))\n descent = formatOverrideValue(descent / (unitsPerEm * sizeAdjust))\n lineGap = formatOverrideValue(lineGap / (unitsPerEm * sizeAdjust))\n\n return {\n ascent,\n descent,\n lineGap,\n fallbackFont: fallbackFont.name,\n sizeAdjust: formatOverrideValue(sizeAdjust),\n }\n}\n"],"names":["calculateSizeAdjustValues","capsizeFontsMetrics","require","formatName","str","replace","word","index","toLowerCase","toUpperCase","formatOverrideValue","val","Math","abs","toFixed","fontName","fontKey","fontMetrics","category","ascent","descent","lineGap","unitsPerEm","xWidthAvg","mainFontAvgWidth","fallbackFont","DEFAULT_SERIF_FONT","DEFAULT_SANS_SERIF_FONT","fallbackFontName","name","fallbackFontMetrics","fallbackFontAvgWidth","sizeAdjust"],"mappings":";;;;+BAkBgBA;;;eAAAA;;;2BAfT;AACP,MAAMC,sBAAsBC,QAAQ;AAEpC,SAASC,WAAWC,GAAW;IAC7B,OAAOA,IACJC,OAAO,CAAC,uBAAuB,SAAUC,IAAI,EAAEC,KAAK;QACnD,OAAOA,UAAU,IAAID,KAAKE,WAAW,KAAKF,KAAKG,WAAW;IAC5D,GACCJ,OAAO,CAAC,QAAQ;AACrB;AAEA,SAASK,oBAAoBC,GAAW;IACtC,OAAOC,KAAKC,GAAG,CAACF,MAAM,KAAKG,OAAO,CAAC;AACrC;AAEO,SAASd,0BAA0Be,QAAgB;IACxD,MAAMC,UAAUb,WAAWY;IAC3B,MAAME,cAAchB,mBAAmB,CAACe,QAAQ;IAChD,IAAI,EAAEE,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,UAAU,EAAEC,SAAS,EAAE,GAC/DN;IACF,MAAMO,mBAAmBD,YAAYD;IACrC,MAAMG,eACJP,aAAa,UAAUQ,6BAAkB,GAAGC,kCAAuB;IACrE,MAAMC,mBAAmBzB,WAAWsB,aAAaI,IAAI;IACrD,MAAMC,sBAAsB7B,mBAAmB,CAAC2B,iBAAiB;IACjE,MAAMG,uBACJD,oBAAoBP,SAAS,GAAGO,oBAAoBR,UAAU;IAChE,IAAIU,aAAaT,YAAYC,mBAAmBO,uBAAuB;IAEvEZ,SAAST,oBAAoBS,SAAUG,CAAAA,aAAaU,UAAS;IAC7DZ,UAAUV,oBAAoBU,UAAWE,CAAAA,aAAaU,UAAS;IAC/DX,UAAUX,oBAAoBW,UAAWC,CAAAA,aAAaU,UAAS;IAE/D,OAAO;QACLb;QACAC;QACAC;QACAI,cAAcA,aAAaI,IAAI;QAC/BG,YAAYtB,oBAAoBsB;IAClC;AACF","ignoreList":[0]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getPreloadableFonts", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getPreloadableFonts;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function getPreloadableFonts(nextFontManifest, filePath, injectedFontPreloadTags) {
|
|
12
|
+
if (!nextFontManifest || !filePath) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const filepathWithoutExtension = filePath.replace(/\.[^.]+$/, '');
|
|
16
|
+
const fontFiles = new Set();
|
|
17
|
+
let foundFontUsage = false;
|
|
18
|
+
const preloadedFontFiles = nextFontManifest.app[filepathWithoutExtension];
|
|
19
|
+
if (preloadedFontFiles) {
|
|
20
|
+
foundFontUsage = true;
|
|
21
|
+
for (const fontFile of preloadedFontFiles){
|
|
22
|
+
if (!injectedFontPreloadTags.has(fontFile)) {
|
|
23
|
+
fontFiles.add(fontFile);
|
|
24
|
+
injectedFontPreloadTags.add(fontFile);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (fontFiles.size) {
|
|
29
|
+
return [
|
|
30
|
+
...fontFiles
|
|
31
|
+
].sort();
|
|
32
|
+
} else if (foundFontUsage && injectedFontPreloadTags.size === 0) {
|
|
33
|
+
return [];
|
|
34
|
+
} else {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=get-preloadable-fonts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../fonts/get-preloadable-fonts.ts"],"sourcesContent":["import type { NextFontManifest } from '../build/webpack/plugins/next-font-manifest-plugin'\nimport type { DeepReadonly } from '../shared/lib/deep-readonly'\n\n/**\n * Get hrefs for fonts to preload\n * Returns null if there are no fonts at all.\n * Returns string[] if there are fonts to preload (font paths)\n * Returns empty string[] if there are fonts but none to preload and no other fonts have been preloaded\n * Returns null if there are fonts but none to preload and at least some were previously preloaded\n */\nexport function getPreloadableFonts(\n nextFontManifest: DeepReadonly<NextFontManifest> | undefined,\n filePath: string | undefined,\n injectedFontPreloadTags: Set<string>\n): string[] | null {\n if (!nextFontManifest || !filePath) {\n return null\n }\n const filepathWithoutExtension = filePath.replace(/\\.[^.]+$/, '')\n const fontFiles = new Set<string>()\n let foundFontUsage = false\n\n const preloadedFontFiles = nextFontManifest.app[filepathWithoutExtension]\n if (preloadedFontFiles) {\n foundFontUsage = true\n for (const fontFile of preloadedFontFiles) {\n if (!injectedFontPreloadTags.has(fontFile)) {\n fontFiles.add(fontFile)\n injectedFontPreloadTags.add(fontFile)\n }\n }\n }\n\n if (fontFiles.size) {\n return [...fontFiles].sort()\n } else if (foundFontUsage && injectedFontPreloadTags.size === 0) {\n return []\n } else {\n return null\n }\n}\n"],"names":["getPreloadableFonts","nextFontManifest","filePath","injectedFontPreloadTags","filepathWithoutExtension","replace","fontFiles","Set","foundFontUsage","preloadedFontFiles","app","fontFile","has","add","size","sort"],"mappings":";;;;+BAUgBA;;;eAAAA;;;AAAT,SAASA,oBACdC,gBAA4D,EAC5DC,QAA4B,EAC5BC,uBAAoC;IAEpC,IAAI,CAACF,oBAAoB,CAACC,UAAU;QAClC,OAAO;IACT;IACA,MAAME,2BAA2BF,SAASG,OAAO,CAAC,YAAY;IAC9D,MAAMC,YAAY,IAAIC;IACtB,IAAIC,iBAAiB;IAErB,MAAMC,qBAAqBR,iBAAiBS,GAAG,CAACN,yBAAyB;IACzE,IAAIK,oBAAoB;QACtBD,iBAAiB;QACjB,KAAK,MAAMG,YAAYF,mBAAoB;YACzC,IAAI,CAACN,wBAAwBS,GAAG,CAACD,WAAW;gBAC1CL,UAAUO,GAAG,CAACF;gBACdR,wBAAwBU,GAAG,CAACF;YAC9B;QACF;IACF;IAEA,IAAIL,UAAUQ,IAAI,EAAE;QAClB,OAAO;eAAIR;SAAU,CAACS,IAAI;IAC5B,OAAO,IAAIP,kBAAkBL,wBAAwBW,IAAI,KAAK,GAAG;QAC/D,OAAO,EAAE;IACX,OAAO;QACL,OAAO;IACT;AACF","ignoreList":[0]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// minimal implementation MurmurHash2 hash function
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BloomFilter", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return BloomFilter;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
function murmurhash2(str) {
|
|
13
|
+
let h = 0;
|
|
14
|
+
for(let i = 0; i < str.length; i++){
|
|
15
|
+
const c = str.charCodeAt(i);
|
|
16
|
+
h = Math.imul(h ^ c, 0x5bd1e995);
|
|
17
|
+
h ^= h >>> 13;
|
|
18
|
+
h = Math.imul(h, 0x5bd1e995);
|
|
19
|
+
}
|
|
20
|
+
return h >>> 0;
|
|
21
|
+
}
|
|
22
|
+
// default to 0.01% error rate as the filter compresses very well
|
|
23
|
+
const DEFAULT_ERROR_RATE = 0.0001;
|
|
24
|
+
class BloomFilter {
|
|
25
|
+
constructor(numItems, errorRate = DEFAULT_ERROR_RATE){
|
|
26
|
+
this.numItems = numItems;
|
|
27
|
+
this.errorRate = errorRate;
|
|
28
|
+
this.numBits = Math.ceil(-(numItems * Math.log(errorRate)) / (Math.log(2) * Math.log(2)));
|
|
29
|
+
this.numHashes = Math.ceil(this.numBits / numItems * Math.log(2));
|
|
30
|
+
this.bitArray = new Array(this.numBits).fill(0);
|
|
31
|
+
}
|
|
32
|
+
static from(items, errorRate = DEFAULT_ERROR_RATE) {
|
|
33
|
+
const filter = new BloomFilter(items.length, errorRate);
|
|
34
|
+
for (const item of items){
|
|
35
|
+
filter.add(item);
|
|
36
|
+
}
|
|
37
|
+
return filter;
|
|
38
|
+
}
|
|
39
|
+
export() {
|
|
40
|
+
const data = {
|
|
41
|
+
numItems: this.numItems,
|
|
42
|
+
errorRate: this.errorRate,
|
|
43
|
+
numBits: this.numBits,
|
|
44
|
+
numHashes: this.numHashes,
|
|
45
|
+
bitArray: this.bitArray
|
|
46
|
+
};
|
|
47
|
+
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
48
|
+
if (this.errorRate < DEFAULT_ERROR_RATE) {
|
|
49
|
+
const filterData = JSON.stringify(data);
|
|
50
|
+
const gzipSize = require('next/dist/compiled/gzip-size').sync(filterData);
|
|
51
|
+
if (gzipSize > 1024) {
|
|
52
|
+
console.warn(`Creating filter with error rate less than 0.1% (0.001) can increase the size dramatically proceed with caution. Received error rate ${this.errorRate} resulted in size ${filterData.length} bytes, ${gzipSize} bytes (gzip)`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
import(data) {
|
|
59
|
+
this.numItems = data.numItems;
|
|
60
|
+
this.errorRate = data.errorRate;
|
|
61
|
+
this.numBits = data.numBits;
|
|
62
|
+
this.numHashes = data.numHashes;
|
|
63
|
+
this.bitArray = data.bitArray;
|
|
64
|
+
}
|
|
65
|
+
add(item) {
|
|
66
|
+
const hashValues = this.getHashValues(item);
|
|
67
|
+
hashValues.forEach((hash)=>{
|
|
68
|
+
this.bitArray[hash] = 1;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
contains(item) {
|
|
72
|
+
const hashValues = this.getHashValues(item);
|
|
73
|
+
return hashValues.every((hash)=>this.bitArray[hash]);
|
|
74
|
+
}
|
|
75
|
+
getHashValues(item) {
|
|
76
|
+
const hashValues = [];
|
|
77
|
+
for(let i = 1; i <= this.numHashes; i++){
|
|
78
|
+
const hash = murmurhash2(`${item}${i}`) % this.numBits;
|
|
79
|
+
hashValues.push(hash);
|
|
80
|
+
}
|
|
81
|
+
return hashValues;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=bloom-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../hash/bloom-filter.ts"],"sourcesContent":["// minimal implementation MurmurHash2 hash function\nfunction murmurhash2(str: string) {\n let h = 0\n for (let i = 0; i < str.length; i++) {\n const c = str.charCodeAt(i)\n h = Math.imul(h ^ c, 0x5bd1e995)\n h ^= h >>> 13\n h = Math.imul(h, 0x5bd1e995)\n }\n return h >>> 0\n}\n\n// default to 0.01% error rate as the filter compresses very well\nconst DEFAULT_ERROR_RATE = 0.0001\n\nexport class BloomFilter {\n numItems: number\n errorRate: number\n numBits: number\n numHashes: number\n bitArray: number[]\n\n constructor(numItems: number, errorRate: number = DEFAULT_ERROR_RATE) {\n this.numItems = numItems\n this.errorRate = errorRate\n this.numBits = Math.ceil(\n -(numItems * Math.log(errorRate)) / (Math.log(2) * Math.log(2))\n )\n this.numHashes = Math.ceil((this.numBits / numItems) * Math.log(2))\n this.bitArray = new Array(this.numBits).fill(0)\n }\n\n static from(items: string[], errorRate = DEFAULT_ERROR_RATE) {\n const filter = new BloomFilter(items.length, errorRate)\n\n for (const item of items) {\n filter.add(item)\n }\n return filter\n }\n\n export() {\n const data = {\n numItems: this.numItems,\n errorRate: this.errorRate,\n numBits: this.numBits,\n numHashes: this.numHashes,\n bitArray: this.bitArray,\n }\n\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n if (this.errorRate < DEFAULT_ERROR_RATE) {\n const filterData = JSON.stringify(data)\n const gzipSize = (\n require('next/dist/compiled/gzip-size') as typeof import('next/dist/compiled/gzip-size')\n ).sync(filterData)\n\n if (gzipSize > 1024) {\n console.warn(\n `Creating filter with error rate less than 0.1% (0.001) can increase the size dramatically proceed with caution. Received error rate ${this.errorRate} resulted in size ${filterData.length} bytes, ${gzipSize} bytes (gzip)`\n )\n }\n }\n }\n\n return data\n }\n\n import(data: ReturnType<(typeof this)['export']>) {\n this.numItems = data.numItems\n this.errorRate = data.errorRate\n this.numBits = data.numBits\n this.numHashes = data.numHashes\n this.bitArray = data.bitArray\n }\n\n add(item: string) {\n const hashValues = this.getHashValues(item)\n hashValues.forEach((hash) => {\n this.bitArray[hash] = 1\n })\n }\n\n contains(item: string) {\n const hashValues = this.getHashValues(item)\n return hashValues.every((hash) => this.bitArray[hash])\n }\n\n getHashValues(item: string) {\n const hashValues = []\n for (let i = 1; i <= this.numHashes; i++) {\n const hash = murmurhash2(`${item}${i}`) % this.numBits\n hashValues.push(hash)\n }\n return hashValues\n }\n}\n"],"names":["BloomFilter","murmurhash2","str","h","i","length","c","charCodeAt","Math","imul","DEFAULT_ERROR_RATE","constructor","numItems","errorRate","numBits","ceil","log","numHashes","bitArray","Array","fill","from","items","filter","item","add","export","data","process","env","NEXT_RUNTIME","filterData","JSON","stringify","gzipSize","require","sync","console","warn","import","hashValues","getHashValues","forEach","hash","contains","every","push"],"mappings":"AAAA,mDAAmD;;;;;+BAetCA;;;eAAAA;;;AAdb,SAASC,YAAYC,GAAW;IAC9B,IAAIC,IAAI;IACR,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIG,MAAM,EAAED,IAAK;QACnC,MAAME,IAAIJ,IAAIK,UAAU,CAACH;QACzBD,IAAIK,KAAKC,IAAI,CAACN,IAAIG,GAAG;QACrBH,KAAKA,MAAM;QACXA,IAAIK,KAAKC,IAAI,CAACN,GAAG;IACnB;IACA,OAAOA,MAAM;AACf;AAEA,iEAAiE;AACjE,MAAMO,qBAAqB;AAEpB,MAAMV;IAOXW,YAAYC,QAAgB,EAAEC,YAAoBH,kBAAkB,CAAE;QACpE,IAAI,CAACE,QAAQ,GAAGA;QAChB,IAAI,CAACC,SAAS,GAAGA;QACjB,IAAI,CAACC,OAAO,GAAGN,KAAKO,IAAI,CACtB,CAAEH,CAAAA,WAAWJ,KAAKQ,GAAG,CAACH,UAAS,IAAML,CAAAA,KAAKQ,GAAG,CAAC,KAAKR,KAAKQ,GAAG,CAAC,EAAC;QAE/D,IAAI,CAACC,SAAS,GAAGT,KAAKO,IAAI,CAAC,AAAC,IAAI,CAACD,OAAO,GAAGF,WAAYJ,KAAKQ,GAAG,CAAC;QAChE,IAAI,CAACE,QAAQ,GAAG,IAAIC,MAAM,IAAI,CAACL,OAAO,EAAEM,IAAI,CAAC;IAC/C;IAEA,OAAOC,KAAKC,KAAe,EAAET,YAAYH,kBAAkB,EAAE;QAC3D,MAAMa,SAAS,IAAIvB,YAAYsB,MAAMjB,MAAM,EAAEQ;QAE7C,KAAK,MAAMW,QAAQF,MAAO;YACxBC,OAAOE,GAAG,CAACD;QACb;QACA,OAAOD;IACT;IAEAG,SAAS;QACP,MAAMC,OAAO;YACXf,UAAU,IAAI,CAACA,QAAQ;YACvBC,WAAW,IAAI,CAACA,SAAS;YACzBC,SAAS,IAAI,CAACA,OAAO;YACrBG,WAAW,IAAI,CAACA,SAAS;YACzBC,UAAU,IAAI,CAACA,QAAQ;QACzB;QAEA,IAAIU,QAAQC,GAAG,CAACC,YAAY,KAAK,UAAU;YACzC,IAAI,IAAI,CAACjB,SAAS,GAAGH,oBAAoB;gBACvC,MAAMqB,aAAaC,KAAKC,SAAS,CAACN;gBAClC,MAAMO,WAAW,AACfC,QAAQ,gCACRC,IAAI,CAACL;gBAEP,IAAIG,WAAW,MAAM;oBACnBG,QAAQC,IAAI,CACV,CAAC,oIAAoI,EAAE,IAAI,CAACzB,SAAS,CAAC,kBAAkB,EAAEkB,WAAW1B,MAAM,CAAC,QAAQ,EAAE6B,SAAS,aAAa,CAAC;gBAEjO;YACF;QACF;QAEA,OAAOP;IACT;IAEAY,OAAOZ,IAAyC,EAAE;QAChD,IAAI,CAACf,QAAQ,GAAGe,KAAKf,QAAQ;QAC7B,IAAI,CAACC,SAAS,GAAGc,KAAKd,SAAS;QAC/B,IAAI,CAACC,OAAO,GAAGa,KAAKb,OAAO;QAC3B,IAAI,CAACG,SAAS,GAAGU,KAAKV,SAAS;QAC/B,IAAI,CAACC,QAAQ,GAAGS,KAAKT,QAAQ;IAC/B;IAEAO,IAAID,IAAY,EAAE;QAChB,MAAMgB,aAAa,IAAI,CAACC,aAAa,CAACjB;QACtCgB,WAAWE,OAAO,CAAC,CAACC;YAClB,IAAI,CAACzB,QAAQ,CAACyB,KAAK,GAAG;QACxB;IACF;IAEAC,SAASpB,IAAY,EAAE;QACrB,MAAMgB,aAAa,IAAI,CAACC,aAAa,CAACjB;QACtC,OAAOgB,WAAWK,KAAK,CAAC,CAACF,OAAS,IAAI,CAACzB,QAAQ,CAACyB,KAAK;IACvD;IAEAF,cAAcjB,IAAY,EAAE;QAC1B,MAAMgB,aAAa,EAAE;QACrB,IAAK,IAAIpC,IAAI,GAAGA,KAAK,IAAI,CAACa,SAAS,EAAEb,IAAK;YACxC,MAAMuC,OAAO1C,YAAY,GAAGuB,OAAOpB,GAAG,IAAI,IAAI,CAACU,OAAO;YACtD0B,WAAWM,IAAI,CAACH;QAClB;QACA,OAAOH;IACT;AACF","ignoreList":[0]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FNV-1a Hash implementation
|
|
3
|
+
* @author Travis Webb (tjwebb) <me@traviswebb.com>
|
|
4
|
+
*
|
|
5
|
+
* Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
|
|
6
|
+
*
|
|
7
|
+
* Simplified, optimized and add modified for 52 bit, which provides a larger hash space
|
|
8
|
+
* and still making use of Javascript's 53-bit integer space.
|
|
9
|
+
*/ "use strict";
|
|
10
|
+
Object.defineProperty(exports, "__esModule", {
|
|
11
|
+
value: true
|
|
12
|
+
});
|
|
13
|
+
0 && (module.exports = {
|
|
14
|
+
fnv1a52: null,
|
|
15
|
+
generateETag: null
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
fnv1a52: function() {
|
|
25
|
+
return fnv1a52;
|
|
26
|
+
},
|
|
27
|
+
generateETag: function() {
|
|
28
|
+
return generateETag;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const fnv1a52 = (str)=>{
|
|
32
|
+
const len = str.length;
|
|
33
|
+
let i = 0, t0 = 0, v0 = 0x2325, t1 = 0, v1 = 0x8422, t2 = 0, v2 = 0x9ce4, t3 = 0, v3 = 0xcbf2;
|
|
34
|
+
while(i < len){
|
|
35
|
+
v0 ^= str.charCodeAt(i++);
|
|
36
|
+
t0 = v0 * 435;
|
|
37
|
+
t1 = v1 * 435;
|
|
38
|
+
t2 = v2 * 435;
|
|
39
|
+
t3 = v3 * 435;
|
|
40
|
+
t2 += v0 << 8;
|
|
41
|
+
t3 += v1 << 8;
|
|
42
|
+
t1 += t0 >>> 16;
|
|
43
|
+
v0 = t0 & 65535;
|
|
44
|
+
t2 += t1 >>> 16;
|
|
45
|
+
v1 = t1 & 65535;
|
|
46
|
+
v3 = t3 + (t2 >>> 16) & 65535;
|
|
47
|
+
v2 = t2 & 65535;
|
|
48
|
+
}
|
|
49
|
+
return (v3 & 15) * 281474976710656 + v2 * 4294967296 + v1 * 65536 + (v0 ^ v3 >> 4);
|
|
50
|
+
};
|
|
51
|
+
const generateETag = (payload, weak = false)=>{
|
|
52
|
+
const prefix = weak ? 'W/"' : '"';
|
|
53
|
+
return prefix + fnv1a52(payload).toString(36) + payload.length.toString(36) + '"';
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=etag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../hash/etag.ts"],"sourcesContent":["/**\n * FNV-1a Hash implementation\n * @author Travis Webb (tjwebb) <me@traviswebb.com>\n *\n * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js\n *\n * Simplified, optimized and add modified for 52 bit, which provides a larger hash space\n * and still making use of Javascript's 53-bit integer space.\n */\nexport const fnv1a52 = (str: string) => {\n const len = str.length\n let i = 0,\n t0 = 0,\n v0 = 0x2325,\n t1 = 0,\n v1 = 0x8422,\n t2 = 0,\n v2 = 0x9ce4,\n t3 = 0,\n v3 = 0xcbf2\n\n while (i < len) {\n v0 ^= str.charCodeAt(i++)\n t0 = v0 * 435\n t1 = v1 * 435\n t2 = v2 * 435\n t3 = v3 * 435\n t2 += v0 << 8\n t3 += v1 << 8\n t1 += t0 >>> 16\n v0 = t0 & 65535\n t2 += t1 >>> 16\n v1 = t1 & 65535\n v3 = (t3 + (t2 >>> 16)) & 65535\n v2 = t2 & 65535\n }\n\n return (\n (v3 & 15) * 281474976710656 +\n v2 * 4294967296 +\n v1 * 65536 +\n (v0 ^ (v3 >> 4))\n )\n}\n\nexport const generateETag = (payload: string, weak = false) => {\n const prefix = weak ? 'W/\"' : '\"'\n return (\n prefix + fnv1a52(payload).toString(36) + payload.length.toString(36) + '\"'\n )\n}\n"],"names":["fnv1a52","generateETag","str","len","length","i","t0","v0","t1","v1","t2","v2","t3","v3","charCodeAt","payload","weak","prefix","toString"],"mappings":"AAAA;;;;;;;;CAQC;;;;;;;;;;;;;;;IACYA,OAAO;eAAPA;;IAoCAC,YAAY;eAAZA;;;AApCN,MAAMD,UAAU,CAACE;IACtB,MAAMC,MAAMD,IAAIE,MAAM;IACtB,IAAIC,IAAI,GACNC,KAAK,GACLC,KAAK,QACLC,KAAK,GACLC,KAAK,QACLC,KAAK,GACLC,KAAK,QACLC,KAAK,GACLC,KAAK;IAEP,MAAOR,IAAIF,IAAK;QACdI,MAAML,IAAIY,UAAU,CAACT;QACrBC,KAAKC,KAAK;QACVC,KAAKC,KAAK;QACVC,KAAKC,KAAK;QACVC,KAAKC,KAAK;QACVH,MAAMH,MAAM;QACZK,MAAMH,MAAM;QACZD,MAAMF,OAAO;QACbC,KAAKD,KAAK;QACVI,MAAMF,OAAO;QACbC,KAAKD,KAAK;QACVK,KAAK,AAACD,KAAMF,CAAAA,OAAO,EAAC,IAAM;QAC1BC,KAAKD,KAAK;IACZ;IAEA,OACE,AAACG,CAAAA,KAAK,EAAC,IAAK,kBACZF,KAAK,aACLF,KAAK,QACJF,CAAAA,KAAMM,MAAM,CAAC;AAElB;AAEO,MAAMZ,eAAe,CAACc,SAAiBC,OAAO,KAAK;IACxD,MAAMC,SAASD,OAAO,QAAQ;IAC9B,OACEC,SAASjB,QAAQe,SAASG,QAAQ,CAAC,MAAMH,QAAQX,MAAM,CAACc,QAAQ,CAAC,MAAM;AAE3E","ignoreList":[0]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// source: https://github.com/sindresorhus/fnv1a
|
|
2
|
+
// FNV_PRIMES and FNV_OFFSETS from
|
|
3
|
+
// http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param
|
|
4
|
+
"use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "default", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return fnv1a;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const FNV_PRIMES = {
|
|
15
|
+
32: BigInt(16777619),
|
|
16
|
+
64: BigInt(1099511628211),
|
|
17
|
+
128: BigInt(309485009821345068724781371),
|
|
18
|
+
256: BigInt(374144419156711147060143317175368453031918731002211),
|
|
19
|
+
512: BigInt(35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759),
|
|
20
|
+
1024: BigInt(5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573)
|
|
21
|
+
};
|
|
22
|
+
const FNV_OFFSETS = {
|
|
23
|
+
32: BigInt(2166136261),
|
|
24
|
+
64: BigInt(14695981039346656037),
|
|
25
|
+
128: BigInt(144066263297769815596495629667062367629),
|
|
26
|
+
256: BigInt(100029257958052580907070968620625704837092796014241193945225284501741471925557),
|
|
27
|
+
512: BigInt(9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785),
|
|
28
|
+
1024: BigInt(14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915)
|
|
29
|
+
};
|
|
30
|
+
function fnv1a(inputString, { size = 32, seed = 0 } = {}) {
|
|
31
|
+
if (!FNV_PRIMES[size]) {
|
|
32
|
+
throw Object.defineProperty(new Error('The `size` option must be one of 32, 64, 128, 256, 512, or 1024'), "__NEXT_ERROR_CODE", {
|
|
33
|
+
value: "E462",
|
|
34
|
+
enumerable: false,
|
|
35
|
+
configurable: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
let hash = FNV_OFFSETS[size] ^ BigInt(seed);
|
|
39
|
+
const fnvPrime = FNV_PRIMES[size];
|
|
40
|
+
// Handle Unicode code points > 0x7f
|
|
41
|
+
let isUnicoded = false;
|
|
42
|
+
for(let index = 0; index < inputString.length; index++){
|
|
43
|
+
let characterCode = inputString.charCodeAt(index);
|
|
44
|
+
// Non-ASCII characters trigger the Unicode escape logic
|
|
45
|
+
if (characterCode > 0x7f && !isUnicoded) {
|
|
46
|
+
inputString = unescape(encodeURIComponent(inputString));
|
|
47
|
+
characterCode = inputString.charCodeAt(index);
|
|
48
|
+
isUnicoded = true;
|
|
49
|
+
}
|
|
50
|
+
hash ^= BigInt(characterCode);
|
|
51
|
+
hash = BigInt.asUintN(size, hash * fnvPrime);
|
|
52
|
+
}
|
|
53
|
+
return hash;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=fnv1a.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../hash/fnv1a.ts"],"sourcesContent":["// source: https://github.com/sindresorhus/fnv1a\n// FNV_PRIMES and FNV_OFFSETS from\n// http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param\n\nconst FNV_PRIMES = {\n 32: BigInt(16_777_619),\n 64: BigInt(1_099_511_628_211),\n 128: BigInt(309_485_009_821_345_068_724_781_371),\n 256: BigInt(\n 374_144_419_156_711_147_060_143_317_175_368_453_031_918_731_002_211\n ),\n 512: BigInt(\n 35_835_915_874_844_867_368_919_076_489_095_108_449_946_327_955_754_392_558_399_825_615_420_669_938_882_575_126_094_039_892_345_713_852_759\n ),\n 1024: BigInt(\n 5_016_456_510_113_118_655_434_598_811_035_278_955_030_765_345_404_790_744_303_017_523_831_112_055_108_147_451_509_157_692_220_295_382_716_162_651_878_526_895_249_385_292_291_816_524_375_083_746_691_371_804_094_271_873_160_484_737_966_720_260_389_217_684_476_157_468_082_573\n ),\n} as const\n\nconst FNV_OFFSETS = {\n 32: BigInt(2_166_136_261),\n 64: BigInt(14_695_981_039_346_656_037),\n 128: BigInt(144_066_263_297_769_815_596_495_629_667_062_367_629),\n 256: BigInt(\n 100_029_257_958_052_580_907_070_968_620_625_704_837_092_796_014_241_193_945_225_284_501_741_471_925_557\n ),\n 512: BigInt(\n 9_659_303_129_496_669_498_009_435_400_716_310_466_090_418_745_672_637_896_108_374_329_434_462_657_994_582_932_197_716_438_449_813_051_892_206_539_805_784_495_328_239_340_083_876_191_928_701_583_869_517_785\n ),\n 1024: BigInt(\n 14_197_795_064_947_621_068_722_070_641_403_218_320_880_622_795_441_933_960_878_474_914_617_582_723_252_296_732_303_717_722_150_864_096_521_202_355_549_365_628_174_669_108_571_814_760_471_015_076_148_029_755_969_804_077_320_157_692_458_563_003_215_304_957_150_157_403_644_460_363_550_505_412_711_285_966_361_610_267_868_082_893_823_963_790_439_336_411_086_884_584_107_735_010_676_915\n ),\n} as const\n\nexport default function fnv1a(\n inputString: string,\n {\n size = 32,\n seed = 0,\n }: {\n size?: keyof typeof FNV_PRIMES\n seed?: number\n } = {}\n) {\n if (!FNV_PRIMES[size]) {\n throw new Error(\n 'The `size` option must be one of 32, 64, 128, 256, 512, or 1024'\n )\n }\n\n let hash: bigint = FNV_OFFSETS[size] ^ BigInt(seed)\n const fnvPrime = FNV_PRIMES[size]\n\n // Handle Unicode code points > 0x7f\n let isUnicoded = false\n\n for (let index = 0; index < inputString.length; index++) {\n let characterCode = inputString.charCodeAt(index)\n\n // Non-ASCII characters trigger the Unicode escape logic\n if (characterCode > 0x7f && !isUnicoded) {\n inputString = unescape(encodeURIComponent(inputString))\n characterCode = inputString.charCodeAt(index)\n isUnicoded = true\n }\n\n hash ^= BigInt(characterCode)\n hash = BigInt.asUintN(size, hash * fnvPrime)\n }\n\n return hash\n}\n"],"names":["fnv1a","FNV_PRIMES","BigInt","FNV_OFFSETS","inputString","size","seed","Error","hash","fnvPrime","isUnicoded","index","length","characterCode","charCodeAt","unescape","encodeURIComponent","asUintN"],"mappings":"AAAA,gDAAgD;AAChD,kCAAkC;AAClC,iEAAiE;;;;;+BAgCjE;;;eAAwBA;;;AA9BxB,MAAMC,aAAa;IACjB,IAAIC,OAAO;IACX,IAAIA,OAAO;IACX,KAAKA,OAAO;IACZ,KAAKA,OACH;IAEF,KAAKA,OACH;IAEF,MAAMA,OACJ;AAEJ;AAEA,MAAMC,cAAc;IAClB,IAAID,OAAO;IACX,IAAIA,OAAO;IACX,KAAKA,OAAO;IACZ,KAAKA,OACH;IAEF,KAAKA,OACH;IAEF,MAAMA,OACJ;AAEJ;AAEe,SAASF,MACtBI,WAAmB,EACnB,EACEC,OAAO,EAAE,EACTC,OAAO,CAAC,EAIT,GAAG,CAAC,CAAC;IAEN,IAAI,CAACL,UAAU,CAACI,KAAK,EAAE;QACrB,MAAM,qBAEL,CAFK,IAAIE,MACR,oEADI,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,IAAIC,OAAeL,WAAW,CAACE,KAAK,GAAGH,OAAOI;IAC9C,MAAMG,WAAWR,UAAU,CAACI,KAAK;IAEjC,oCAAoC;IACpC,IAAIK,aAAa;IAEjB,IAAK,IAAIC,QAAQ,GAAGA,QAAQP,YAAYQ,MAAM,EAAED,QAAS;QACvD,IAAIE,gBAAgBT,YAAYU,UAAU,CAACH;QAE3C,wDAAwD;QACxD,IAAIE,gBAAgB,QAAQ,CAACH,YAAY;YACvCN,cAAcW,SAASC,mBAAmBZ;YAC1CS,gBAAgBT,YAAYU,UAAU,CAACH;YACvCD,aAAa;QACf;QAEAF,QAAQN,OAAOW;QACfL,OAAON,OAAOe,OAAO,CAACZ,MAAMG,OAAOC;IACrC;IAEA,OAAOD;AACT","ignoreList":[0]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// http://www.cse.yorku.ca/~oz/hash.html
|
|
2
|
+
// More specifically, 32-bit hash via djbxor
|
|
3
|
+
// (ref: https://gist.github.com/eplawless/52813b1d8ad9af510d85?permalink_comment_id=3367765#gistcomment-3367765)
|
|
4
|
+
// 32-bit hash for consistent output across different runtime implementations.
|
|
5
|
+
"use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
0 && (module.exports = {
|
|
10
|
+
djb2Hash: null,
|
|
11
|
+
hexHash: null
|
|
12
|
+
});
|
|
13
|
+
function _export(target, all) {
|
|
14
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: all[name]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
_export(exports, {
|
|
20
|
+
djb2Hash: function() {
|
|
21
|
+
return djb2Hash;
|
|
22
|
+
},
|
|
23
|
+
hexHash: function() {
|
|
24
|
+
return hexHash;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
function djb2Hash(str) {
|
|
28
|
+
let hash = 5381;
|
|
29
|
+
for(let i = 0; i < str.length; i++){
|
|
30
|
+
const char = str.charCodeAt(i);
|
|
31
|
+
hash = (hash << 5) + hash + char & 0xffffffff;
|
|
32
|
+
}
|
|
33
|
+
return hash >>> 0;
|
|
34
|
+
}
|
|
35
|
+
function hexHash(str) {
|
|
36
|
+
return djb2Hash(str).toString(36).slice(0, 5);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../hash/hash.ts"],"sourcesContent":["// http://www.cse.yorku.ca/~oz/hash.html\n// More specifically, 32-bit hash via djbxor\n// (ref: https://gist.github.com/eplawless/52813b1d8ad9af510d85?permalink_comment_id=3367765#gistcomment-3367765)\n// 32-bit hash for consistent output across different runtime implementations.\nexport function djb2Hash(str: string) {\n let hash = 5381\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i)\n hash = ((hash << 5) + hash + char) & 0xffffffff\n }\n return hash >>> 0\n}\n\nexport function hexHash(str: string) {\n return djb2Hash(str).toString(36).slice(0, 5)\n}\n"],"names":["djb2Hash","hexHash","str","hash","i","length","char","charCodeAt","toString","slice"],"mappings":"AAAA,wCAAwC;AACxC,4CAA4C;AAC5C,iHAAiH;AACjH,8EAA8E;;;;;;;;;;;;;;;;IAC9DA,QAAQ;eAARA;;IASAC,OAAO;eAAPA;;;AATT,SAASD,SAASE,GAAW;IAClC,IAAIC,OAAO;IACX,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIG,MAAM,EAAED,IAAK;QACnC,MAAME,OAAOJ,IAAIK,UAAU,CAACH;QAC5BD,OAAO,AAAEA,CAAAA,QAAQ,CAAA,IAAKA,OAAOG,OAAQ;IACvC;IACA,OAAOH,SAAS;AAClB;AAEO,SAASF,QAAQC,GAAW;IACjC,OAAOF,SAASE,KAAKM,QAAQ,CAAC,IAAIC,KAAK,CAAC,GAAG;AAC7C","ignoreList":[0]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "formatHostname", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return formatHostname;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _isipv6 = require("./is-ipv6");
|
|
12
|
+
function formatHostname(hostname) {
|
|
13
|
+
return (0, _isipv6.isIPv6)(hostname) ? `[${hostname}]` : hostname;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=format-hostname.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../hostname/format-hostname.ts"],"sourcesContent":["import { isIPv6 } from './is-ipv6'\n\n/**\n * Formats a hostname so that it is a valid host that can be fetched by wrapping\n * IPv6 hosts with brackets.\n * @param hostname\n * @returns\n */\nexport function formatHostname(hostname: string): string {\n return isIPv6(hostname) ? `[${hostname}]` : hostname\n}\n"],"names":["formatHostname","hostname","isIPv6"],"mappings":";;;;+BAQgBA;;;eAAAA;;;wBARO;AAQhB,SAASA,eAAeC,QAAgB;IAC7C,OAAOC,IAAAA,cAAM,EAACD,YAAY,CAAC,CAAC,EAAEA,SAAS,CAAC,CAAC,GAAGA;AAC9C","ignoreList":[0]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getHostname", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getHostname;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function getHostname(parsed, headers) {
|
|
12
|
+
// Get the hostname from the headers if it exists, otherwise use the parsed
|
|
13
|
+
// hostname.
|
|
14
|
+
let hostname;
|
|
15
|
+
if ((headers == null ? void 0 : headers.host) && !Array.isArray(headers.host)) {
|
|
16
|
+
hostname = headers.host.toString().split(':', 1)[0];
|
|
17
|
+
} else if (parsed.hostname) {
|
|
18
|
+
hostname = parsed.hostname;
|
|
19
|
+
} else return;
|
|
20
|
+
return hostname.toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=get-hostname.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../hostname/get-hostname.ts"],"sourcesContent":["import type { OutgoingHttpHeaders } from 'http'\n\n/**\n * Takes an object with a hostname property (like a parsed URL) and some\n * headers that may contain Host and returns the preferred hostname.\n * @param parsed An object containing a hostname property.\n * @param headers A dictionary with headers containing a `host`.\n */\nexport function getHostname(\n parsed: { hostname?: string | null },\n headers?: OutgoingHttpHeaders\n): string | undefined {\n // Get the hostname from the headers if it exists, otherwise use the parsed\n // hostname.\n let hostname: string\n if (headers?.host && !Array.isArray(headers.host)) {\n hostname = headers.host.toString().split(':', 1)[0]\n } else if (parsed.hostname) {\n hostname = parsed.hostname\n } else return\n\n return hostname.toLowerCase()\n}\n"],"names":["getHostname","parsed","headers","hostname","host","Array","isArray","toString","split","toLowerCase"],"mappings":";;;;+BAQgBA;;;eAAAA;;;AAAT,SAASA,YACdC,MAAoC,EACpCC,OAA6B;IAE7B,2EAA2E;IAC3E,YAAY;IACZ,IAAIC;IACJ,IAAID,CAAAA,2BAAAA,QAASE,IAAI,KAAI,CAACC,MAAMC,OAAO,CAACJ,QAAQE,IAAI,GAAG;QACjDD,WAAWD,QAAQE,IAAI,CAACG,QAAQ,GAAGC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE;IACrD,OAAO,IAAIP,OAAOE,QAAQ,EAAE;QAC1BA,WAAWF,OAAOE,QAAQ;IAC5B,OAAO;IAEP,OAAOA,SAASM,WAAW;AAC7B","ignoreList":[0]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getNetworkHost", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getNetworkHost;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getNetworkHosts(family) {
|
|
18
|
+
const interfaces = _os.default.networkInterfaces();
|
|
19
|
+
const hosts = [];
|
|
20
|
+
Object.keys(interfaces).forEach((key)=>{
|
|
21
|
+
var _interfaces_key;
|
|
22
|
+
(_interfaces_key = interfaces[key]) == null ? void 0 : _interfaces_key.filter((networkInterface)=>{
|
|
23
|
+
switch(networkInterface.family){
|
|
24
|
+
case 'IPv6':
|
|
25
|
+
return family === 'IPv6' && networkInterface.scopeid === 0 && networkInterface.address !== '::1';
|
|
26
|
+
case 'IPv4':
|
|
27
|
+
return family === 'IPv4' && networkInterface.address !== '127.0.0.1';
|
|
28
|
+
default:
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}).forEach((networkInterface)=>{
|
|
32
|
+
if (networkInterface.address) {
|
|
33
|
+
hosts.push(networkInterface.address);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return hosts;
|
|
38
|
+
}
|
|
39
|
+
function getNetworkHost(family) {
|
|
40
|
+
const hosts = getNetworkHosts(family);
|
|
41
|
+
return hosts[0] ?? null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=get-network-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../hostname/get-network-host.ts"],"sourcesContent":["import os from 'os'\n\nfunction getNetworkHosts(family: 'IPv4' | 'IPv6'): string[] {\n const interfaces = os.networkInterfaces()\n const hosts: string[] = []\n\n Object.keys(interfaces).forEach((key) => {\n interfaces[key]\n ?.filter((networkInterface) => {\n switch (networkInterface.family) {\n case 'IPv6':\n return (\n family === 'IPv6' &&\n networkInterface.scopeid === 0 &&\n networkInterface.address !== '::1'\n )\n case 'IPv4':\n return family === 'IPv4' && networkInterface.address !== '127.0.0.1'\n default:\n return false\n }\n })\n .forEach((networkInterface) => {\n if (networkInterface.address) {\n hosts.push(networkInterface.address)\n }\n })\n })\n\n return hosts\n}\n\nexport function getNetworkHost(family: 'IPv4' | 'IPv6'): string | null {\n const hosts = getNetworkHosts(family)\n return hosts[0] ?? null\n}\n"],"names":["getNetworkHost","getNetworkHosts","family","interfaces","os","networkInterfaces","hosts","Object","keys","forEach","key","filter","networkInterface","scopeid","address","push"],"mappings":";;;;+BAgCgBA;;;eAAAA;;;2DAhCD;;;;;;AAEf,SAASC,gBAAgBC,MAAuB;IAC9C,MAAMC,aAAaC,WAAE,CAACC,iBAAiB;IACvC,MAAMC,QAAkB,EAAE;IAE1BC,OAAOC,IAAI,CAACL,YAAYM,OAAO,CAAC,CAACC;YAC/BP;SAAAA,kBAAAA,UAAU,CAACO,IAAI,qBAAfP,gBACIQ,MAAM,CAAC,CAACC;YACR,OAAQA,iBAAiBV,MAAM;gBAC7B,KAAK;oBACH,OACEA,WAAW,UACXU,iBAAiBC,OAAO,KAAK,KAC7BD,iBAAiBE,OAAO,KAAK;gBAEjC,KAAK;oBACH,OAAOZ,WAAW,UAAUU,iBAAiBE,OAAO,KAAK;gBAC3D;oBACE,OAAO;YACX;QACF,GACCL,OAAO,CAAC,CAACG;YACR,IAAIA,iBAAiBE,OAAO,EAAE;gBAC5BR,MAAMS,IAAI,CAACH,iBAAiBE,OAAO;YACrC;QACF;IACJ;IAEA,OAAOR;AACT;AAEO,SAASN,eAAeE,MAAuB;IACpD,MAAMI,QAAQL,gBAAgBC;IAC9B,OAAOI,KAAK,CAAC,EAAE,IAAI;AACrB","ignoreList":[0]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Regex from `node/lib/internal/net.js`: https://github.com/nodejs/node/blob/9fc57006c27564ed7f75eee090eca86786508f51/lib/internal/net.js#L19-L29
|
|
2
|
+
// License included below:
|
|
3
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
4
|
+
//
|
|
5
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
6
|
+
// copy of this software and associated documentation files (the
|
|
7
|
+
// "Software"), to deal in the Software without restriction, including
|
|
8
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
10
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
11
|
+
// following conditions:
|
|
12
|
+
//
|
|
13
|
+
// The above copyright notice and this permission notice shall be included
|
|
14
|
+
// in all copies or substantial portions of the Software.
|
|
15
|
+
//
|
|
16
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
19
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
20
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
21
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
22
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
"use strict";
|
|
24
|
+
Object.defineProperty(exports, "__esModule", {
|
|
25
|
+
value: true
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "isIPv6", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function() {
|
|
30
|
+
return isIPv6;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const v4Seg = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
|
|
34
|
+
const v4Str = `(${v4Seg}[.]){3}${v4Seg}`;
|
|
35
|
+
const v6Seg = '(?:[0-9a-fA-F]{1,4})';
|
|
36
|
+
const IPv6Reg = new RegExp('^(' + `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` + `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` + `(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|` + `(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|` + `(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|` + `(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` + `(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` + `(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` + ')(%[0-9a-zA-Z-.:]{1,})?$');
|
|
37
|
+
function isIPv6(s) {
|
|
38
|
+
return IPv6Reg.test(s);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=is-ipv6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../hostname/is-ipv6.ts"],"sourcesContent":["// Regex from `node/lib/internal/net.js`: https://github.com/nodejs/node/blob/9fc57006c27564ed7f75eee090eca86786508f51/lib/internal/net.js#L19-L29\n// License included below:\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nconst v4Seg = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'\nconst v4Str = `(${v4Seg}[.]){3}${v4Seg}`\nconst v6Seg = '(?:[0-9a-fA-F]{1,4})'\nconst IPv6Reg = new RegExp(\n '^(' +\n `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` +\n `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` +\n `(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|` +\n `(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|` +\n `(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|` +\n `(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` +\n `(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` +\n `(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` +\n ')(%[0-9a-zA-Z-.:]{1,})?$'\n)\n\nexport function isIPv6(s: string) {\n return IPv6Reg.test(s)\n}\n"],"names":["isIPv6","v4Seg","v4Str","v6Seg","IPv6Reg","RegExp","s","test"],"mappings":"AAAA,kJAAkJ;AAClJ,0BAA0B;AAC1B,sDAAsD;AACtD,EAAE;AACF,0EAA0E;AAC1E,gEAAgE;AAChE,sEAAsE;AACtE,sEAAsE;AACtE,4EAA4E;AAC5E,qEAAqE;AACrE,wBAAwB;AACxB,EAAE;AACF,0EAA0E;AAC1E,yDAAyD;AACzD,EAAE;AACF,0EAA0E;AAC1E,6DAA6D;AAC7D,4EAA4E;AAC5E,2EAA2E;AAC3E,wEAAwE;AACxE,4EAA4E;AAC5E,yCAAyC;;;;;+BAkBzBA;;;eAAAA;;;AAhBhB,MAAMC,QAAQ;AACd,MAAMC,QAAQ,CAAC,CAAC,EAAED,MAAM,OAAO,EAAEA,OAAO;AACxC,MAAME,QAAQ;AACd,MAAMC,UAAU,IAAIC,OAClB,OACE,CAAC,GAAG,EAAEF,MAAM,QAAQ,EAAEA,MAAM,IAAI,CAAC,GACjC,CAAC,GAAG,EAAEA,MAAM,QAAQ,EAAED,MAAM,EAAE,EAAEC,MAAM,IAAI,CAAC,GAC3C,CAAC,GAAG,EAAEA,MAAM,SAAS,EAAED,MAAM,GAAG,EAAEC,MAAM,UAAU,CAAC,GACnD,CAAC,GAAG,EAAEA,MAAM,UAAU,EAAEA,MAAM,OAAO,EAAED,MAAM,GAAG,EAAEC,MAAM,UAAU,CAAC,GACnE,CAAC,GAAG,EAAEA,MAAM,UAAU,EAAEA,MAAM,OAAO,EAAED,MAAM,GAAG,EAAEC,MAAM,UAAU,CAAC,GACnE,CAAC,GAAG,EAAEA,MAAM,UAAU,EAAEA,MAAM,OAAO,EAAED,MAAM,GAAG,EAAEC,MAAM,UAAU,CAAC,GACnE,CAAC,GAAG,EAAEA,MAAM,UAAU,EAAEA,MAAM,OAAO,EAAED,MAAM,GAAG,EAAEC,MAAM,UAAU,CAAC,GACnE,CAAC,SAAS,EAAEA,MAAM,OAAO,EAAED,MAAM,KAAK,EAAEC,MAAM,UAAU,CAAC,GACzD;AAGG,SAASH,OAAOM,CAAS;IAC9B,OAAOF,QAAQG,IAAI,CAACD;AACtB","ignoreList":[0]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "findClosestQuality", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return findClosestQuality;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function findClosestQuality(quality, config) {
|
|
12
|
+
const q = quality || 75;
|
|
13
|
+
if (!config?.qualities?.length) {
|
|
14
|
+
return q;
|
|
15
|
+
}
|
|
16
|
+
return config.qualities.reduce((prev, cur)=>Math.abs(cur - q) < Math.abs(prev - q) ? cur : prev, 0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=find-closest-quality.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../image/find-closest-quality.ts"],"sourcesContent":["import type { NextConfig } from '../server/config-shared'\n\n/**\n * Find the closest matching `quality` in the list of `config.qualities`\n * @param quality the quality prop passed to the image component\n * @param config the \"images\" configuration from next.config.js\n * @returns the closest matching quality value\n */\nexport function findClosestQuality(\n quality: number | undefined,\n config: NextConfig['images'] | undefined\n): number {\n const q = quality || 75\n if (!config?.qualities?.length) {\n return q\n }\n return config.qualities.reduce(\n (prev, cur) => (Math.abs(cur - q) < Math.abs(prev - q) ? cur : prev),\n 0\n )\n}\n"],"names":["findClosestQuality","quality","config","q","qualities","length","reduce","prev","cur","Math","abs"],"mappings":";;;;+BAQgBA;;;eAAAA;;;AAAT,SAASA,mBACdC,OAA2B,EAC3BC,MAAwC;IAExC,MAAMC,IAAIF,WAAW;IACrB,IAAI,CAACC,QAAQE,WAAWC,QAAQ;QAC9B,OAAOF;IACT;IACA,OAAOD,OAAOE,SAAS,CAACE,MAAM,CAC5B,CAACC,MAAMC,MAASC,KAAKC,GAAG,CAACF,MAAML,KAAKM,KAAKC,GAAG,CAACH,OAAOJ,KAAKK,MAAMD,MAC/D;AAEJ","ignoreList":[0]}
|