index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 1be97932_632b_c693_3537_b60cd384a0f5["index.ts"] ec44a8f8_f62b_4c65_add4_5935edf32368["./sirv.js"] 1be97932_632b_c693_3537_b60cd384a0f5 --> ec44a8f8_f62b_4c65_add4_5935edf32368 e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] 1be97932_632b_c693_3537_b60cd384a0f5 --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 3955a637_4c78_0528_fe7c_92190a232cb0["node:module"] 1be97932_632b_c693_3537_b60cd384a0f5 --> 3955a637_4c78_0528_fe7c_92190a232cb0 c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"] 1be97932_632b_c693_3537_b60cd384a0f5 --> c52a5f83_66e3_37d7_9ebb_767f7129bc62 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] 1be97932_632b_c693_3537_b60cd384a0f5 --> d9a92db9_c95e_9165_13ac_24b3d859d946 8e1e0363_4a84_9068_1f67_6e1f8f274b8d["integration"] 1be97932_632b_c693_3537_b60cd384a0f5 --> 8e1e0363_4a84_9068_1f67_6e1f8f274b8d f6697489_2144_8063_feaf_a10436211727["utils"] 1be97932_632b_c693_3537_b60cd384a0f5 --> f6697489_2144_8063_feaf_a10436211727 f16d8c76_2866_6150_bd14_0347b59abfe9["astro"] 1be97932_632b_c693_3537_b60cd384a0f5 --> f16d8c76_2866_6150_bd14_0347b59abfe9 style 1be97932_632b_c693_3537_b60cd384a0f5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as fs from 'node:fs';
import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import type { PartytownConfig } from '@qwik.dev/partytown/integration';
import { partytownSnippet } from '@qwik.dev/partytown/integration';
import { copyLibFiles, libDirPath } from '@qwik.dev/partytown/utils';
import type { AstroIntegration } from 'astro';
import sirv from './sirv.js';
const resolve = createRequire(import.meta.url).resolve;
export type PartytownOptions = {
config?: PartytownConfig;
};
function appendForwardSlash(str: string) {
return str.endsWith('/') ? str : str + '/';
}
export default function createPlugin(options?: PartytownOptions): AstroIntegration {
let partytownSnippetHtml: string;
const partytownEntrypoint = resolve('@qwik.dev/partytown/package.json');
const partytownLibDirectory = path.resolve(partytownEntrypoint, '../lib');
return {
name: '@astrojs/partytown',
hooks: {
'astro:config:setup': ({ config: _config, command, injectScript }) => {
const lib = `${appendForwardSlash(_config.base)}~partytown/`;
const recreateIFrameScript = `;(e=>{e.addEventListener("astro:before-swap",e=>{let r=document.body.querySelector("iframe[src*='${lib}']");if(r)e.newDocument.body.append(r)})})(document);`;
const partytownConfig = {
lib,
...options?.config,
debug: options?.config?.debug ?? command === 'dev',
};
partytownSnippetHtml = partytownSnippet(partytownConfig);
partytownSnippetHtml += recreateIFrameScript;
injectScript('head-inline', partytownSnippetHtml);
},
'astro:server:setup': ({ server }) => {
const lib = options?.config?.lib ?? `/~partytown/`;
server.middlewares.use(
sirv(partytownLibDirectory, {
mount: lib,
dev: true,
etag: true,
extensions: [],
}),
);
},
'astro:build:done': async ({ dir }) => {
await copyLibFiles(
fileURLToPath(new URL(options?.config?.lib?.replace(/^\/?/, '') ?? '~partytown', dir)),
{
debugDir: options?.config?.debug ?? false,
},
);
},
'astro:build:ssr': async ({ manifest }) => {
const dirpath = libDirPath({ debugDir: false });
const files = await fs.promises.readdir(dirpath);
for (const file of files) {
if (file === 'debug') continue;
manifest.assets.push(`/~partytown/${file}`);
}
},
},
};
}
Domain
Subdomains
Functions
Types
Dependencies
- ./sirv.js
- astro
- integration
- node:fs
- node:module
- node:path
- node:url
- utils
Source
Frequently Asked Questions
What does index.ts do?
index.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 index.ts?
index.ts defines 2 function(s): appendForwardSlash, createPlugin.
What does index.ts depend on?
index.ts imports 8 module(s): ./sirv.js, astro, integration, node:fs, node:module, node:path, node:url, utils.
Where is index.ts in the architecture?
index.ts is located at packages/integrations/partytown/src/index.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