15export type Action = (req: Request, ctx: Context) => Response | Promise<Response>;
1617export function handler(Component, action?: Action) {
18return async (c) => {
19if (action) {
1export type ShaAlgorithm = "SHA-256" | "SHA-512";
23export async function sha(
4input: string | BufferSource | AsyncIterable<BufferSource> | Iterable<BufferSource>,
5algo: ShaAlgorithm = "SHA-256",
midnightpubFeedmain.tsx2 matches
8const reUserFeed = /^\/(?<username>~[a-z0-9-_]+)\.(?<format>atom|rss)$/;
910export default async function(req: Request): Promise<Response> {
11const { pathname } = new URL(req.url);
12const match = pathname.match(reUserFeed);
49}
5051async function grabPosts(profileURL: string | URL) {
52const html = await ky.get(profileURL).text();
53const doc = new DOMParser().parseFromString(html, "text/html");
23}
2425export function testContext<TOptions extends TestContextOptions>(options: TOptions) {
26const tests: Test<TOptions>[] = [];
27
createValFromCljsmain.tsx1 match
2import { updateValByName } from "https://esm.town/v/nbbaier/updateValByName";
34export async function createValFromCljs(name: string, cljs: string) {
5return updateValByName({
6token: Deno.env.get("valtown"),
compileCljsToES6main.tsx1 match
4globalThis.squint_core = squint_core;
56export function compileCljsToES6(cljs: string) {
7return compileString(cljs, { repl: true, "elide-exports": true }).replace(
8"squint-cljs",
7import { vueSfcInline } from "https://esm.town/v/postpostscript/vue";
89export default function() {
10return htmlResponse`
11${vueSfcInline`
multiFormatmain.tsx14 matches
1import { html, RawHTML } from "https://esm.town/v/postpostscript/html";
23export function multiFormat<R extends MultiFormat = { text: string }>(
4strings: TemplateStringsArray,
5...replacements: (string | R)[]
31};
3233export function combineMultiFormat<R extends MultiFormat>(
34values: (R | string)[],
35transformers = DEFAULT_TRANSFORMERS as Transformers<R>,
67}
6869export function joinMultiFormat<R extends MultiFormat>(values: (R | string)[], join: R | string) {
70if (!values.length) {
71return {
84}
8586export function normalizeMultiFormat<R extends MultiFormat>(value: R | string | number | boolean | null | undefined) {
87if (isString(value)) {
88return { text: value };
94}
9596export function getMultiFormatValue<R extends MultiFormat, K extends keyof R>(
97value: R,
98key: K,
110}
111112function isString(value: unknown): value is string {
113return typeof value === "string" || value instanceof String;
114}
115116function toString(value: unknown) {
117if (isString(value)) {
118return value;
124}
125126export function addStrings(valueA: unknown, valueB: unknown) {
127if (!(isString(valueA) && isString(valueB))) {
128return addStrings(
141}
142143export function wrapHTMLTag(
144tag: string,
145text: string | MultiFormatWithHTML,
161}
162163export function createFormatMethod<R extends MultiFormat>(method: (value: R) => R) {
164return (
165strings: TemplateStringsArray,
170}
171172export function createWrapTagFormatMethod(tag: string, attrs: Record<string, string> = {}) {
173return createFormatMethod<MultiFormatWithHTML>((value) => {
174return wrapHTMLTag(tag, value, attrs);
197});
198199export function ListItem(item: string | MultiFormatWithHTML, i: number | undefined = undefined) {
200return combineMultiFormat([
201{
213}
214215export function OrderedList(items: (string | MultiFormatWithHTML)[]) {
216return joinMultiFormat([
217{
233}
234235export function UnorderedList(items: (string | MultiFormatWithHTML)[]) {
236return joinMultiFormat([
237{
2type PR = Parameters<typeof Octokit["rest"]["pulls"]["create"]>;
34export async function submitPR(ghToken: string, ...pr: PR) {
5return new Octokit({ auth: ghToken }).rest.pulls.create(pr);
6}
githubRestClientmain.tsx1 match
1import { Octokit } from "npm:@octokit/rest";
23export async function githubRestClient(ghToken: string | undefined) {
4return new Octokit({ auth: ghToken || Deno.env.get("GITHUB_TOKEN") }).rest;
5}