[READ-ONLY] a fast, modern browser for the npm registry
at main 81 lines 3.6 kB view raw
1import * as dev from '../types/lexicons/dev' 2 3// Duration 4export const CACHE_MAX_AGE_ONE_MINUTE = 60 5export const CACHE_MAX_AGE_FIVE_MINUTES = 60 * 5 6export const CACHE_MAX_AGE_ONE_HOUR = 60 * 60 7export const CACHE_MAX_AGE_ONE_DAY = 60 * 60 * 24 8export const CACHE_MAX_AGE_ONE_YEAR = 60 * 60 * 24 * 365 9 10// API Strings 11export const NPMX_SITE = 'https://npmx.dev' 12export const NPMX_DOCS_SITE = 'https://docs.npmx.dev' 13export const BLUESKY_API = 'https://public.api.bsky.app' 14export const BLUESKY_COMMENTS_REQUEST = '/api/atproto/bluesky-comments' 15export const NPM_REGISTRY = 'https://registry.npmjs.org' 16export const NPM_API = 'https://api.npmjs.org' 17export const ERROR_PACKAGE_ANALYSIS_FAILED = 'Failed to analyze package.' 18export const ERROR_PACKAGE_VERSION_AND_FILE_FAILED = 'Version and file path are required.' 19export const ERROR_PACKAGE_REQUIREMENTS_FAILED = 20 'Package name, version, and file path are required.' 21export const ERROR_FILE_LIST_FETCH_FAILED = 'Failed to fetch file list.' 22export const ERROR_CALC_INSTALL_SIZE_FAILED = 'Failed to calculate install size.' 23export const NPM_MISSING_README_SENTINEL = 'ERROR: No README data found!' 24/** The npm registry truncates the packument readme field at 65,536 characters (2^16) */ 25export const NPM_README_TRUNCATION_THRESHOLD = 64_000 26export const ERROR_JSR_FETCH_FAILED = 'Failed to fetch package from JSR registry.' 27export const ERROR_NPM_FETCH_FAILED = 'Failed to fetch package from npm registry.' 28export const ERROR_PROVENANCE_FETCH_FAILED = 'Failed to fetch provenance.' 29export const UNSET_NUXT_SESSION_PASSWORD = 'NUXT_SESSION_PASSWORD not set' 30export const ERROR_SUGGESTIONS_FETCH_FAILED = 'Failed to fetch suggestions.' 31export const ERROR_SKILLS_FETCH_FAILED = 'Failed to fetch skills.' 32export const ERROR_SKILL_NOT_FOUND = 'Skill not found.' 33export const ERROR_SKILL_FILE_NOT_FOUND = 'Skill file not found.' 34/** @public */ 35export const ERROR_GRAVATAR_FETCH_FAILED = 'Failed to fetch Gravatar profile.' 36/** @public */ 37export const ERROR_GRAVATAR_EMAIL_UNAVAILABLE = "User's email not accessible." 38export const ERROR_NEED_REAUTH = 'User needs to reauthenticate' 39 40// microcosm services 41export const CONSTELLATION_HOST = 'constellation.microcosm.blue' 42export const SLINGSHOT_HOST = 'slingshot.microcosm.blue' 43 44// ATProtocol 45// Refrences used to link packages to things that are not inherently atproto 46export const PACKAGE_SUBJECT_REF = (packageName: string) => 47 `https://npmx.dev/package/${packageName}` 48// OAuth scopes as we add new ones we need to check these on certain actions. If not redirect the user to login again to upgrade the scopes 49export const LIKES_SCOPE = `repo:${dev.npmx.feed.like.$nsid}` 50 51// Theming 52export const ACCENT_COLORS = { 53 light: { 54 coral: 'oklch(0.70 0.19 14.75)', 55 amber: 'oklch(0.8 0.25 84.429)', 56 emerald: 'oklch(0.70 0.17 166.95)', 57 sky: 'oklch(0.70 0.15 230.318)', 58 violet: 'oklch(0.70 0.17 286.067)', 59 magenta: 'oklch(0.75 0.18 330)', 60 }, 61 dark: { 62 coral: 'oklch(0.704 0.177 14.75)', 63 amber: 'oklch(0.828 0.165 84.429)', 64 emerald: 'oklch(0.792 0.153 166.95)', 65 sky: 'oklch(0.787 0.128 230.318)', 66 violet: 'oklch(0.78 0.148 286.067)', 67 magenta: 'oklch(0.78 0.15 330)', 68 }, 69} as const 70 71export const BACKGROUND_THEMES = { 72 neutral: 'oklch(0.555 0 0)', 73 stone: 'oklch(0.555 0.013 58.123)', 74 zinc: 'oklch(0.555 0.016 285.931)', 75 slate: 'oklch(0.555 0.046 257.407)', 76 black: 'oklch(0.4 0 0)', 77} as const 78 79// Regex 80export const BSKY_POST_AT_URI_REGEX = 81 /^at:\/\/(did:plc:[a-z0-9]+)\/app\.bsky\.feed\.post\/([a-z0-9]+)$/