sirv.ts — astro Source File
Architecture documentation for sirv.ts, a typescript file in the astro codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR afcb3082_013d_93cb_836e_f55956dc999b["sirv.ts"] e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] afcb3082_013d_93cb_836e_f55956dc999b --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"] afcb3082_013d_93cb_836e_f55956dc999b --> c52a5f83_66e3_37d7_9ebb_767f7129bc62 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] afcb3082_013d_93cb_836e_f55956dc999b --> d9a92db9_c95e_9165_13ac_24b3d859d946 d5d79daf_16b4_bece_5a98_63bc92fc1431["mrmime"] afcb3082_013d_93cb_836e_f55956dc999b --> d5d79daf_16b4_bece_5a98_63bc92fc1431 style afcb3082_013d_93cb_836e_f55956dc999b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// TODO: The below has been modified from the original sirv package to support
// the feature of mounting the served files from a certain path (in this case, `/~partytown/`)
// It would be good to bring this into Astro for all integrations to take advantage of,
// and potentially also to respect your config automatically for things like `base` path.
// @ts-nocheck
/**
* @license
*
* The MIT License (MIT)
*
* Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (https://lukeed.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import * as fs from 'node:fs';
import { join, normalize, resolve } from 'node:path';
import { URL } from 'node:url';
// import { totalist } from 'totalist/sync';
// import { parse } from '@polka/url';
import { lookup } from 'mrmime';
const noop = () => {};
function isMatch(uri, arr) {
for (const candidate of arr) {
if (candidate.test(uri)) return true;
}
}
function toAssume(uri, extns) {
let i = 0,
x,
len = uri.length - 1;
if (uri.charCodeAt(len) === 47) {
uri = uri.substring(0, len);
}
let arr = [],
tmp = `${uri}/index`;
for (; i < extns.length; i++) {
x = extns[i] ? `.${extns[i]}` : '';
if (uri) arr.push(uri + x);
// ... (186 more lines)
Domain
Subdomains
Dependencies
- mrmime
- node:fs
- node:path
- node:url
Source
Frequently Asked Questions
What does sirv.ts do?
sirv.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in sirv.ts?
sirv.ts defines 8 function(s): is404, isMatch, noop, send, toAssume, toHeaders, viaCache, viaLocal.
What does sirv.ts depend on?
sirv.ts imports 4 module(s): mrmime, node:fs, node:path, node:url.
Where is sirv.ts in the architecture?
sirv.ts is located at packages/integrations/partytown/src/sirv.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/integrations/partytown/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free