├── site ├── static │ ├── .nojekyll │ ├── img │ │ ├── logo.png │ │ ├── dotted.png │ │ ├── favicon.ico │ │ ├── favicon.png │ │ ├── logo-sm.png │ │ ├── social-card.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── apple-touch-icon.png │ │ ├── serverless-circle.webp │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── stack-overflow.svg │ │ ├── cursor.svg │ │ ├── nirrius-repeat.svg │ │ └── github-icon.svg │ ├── fonts │ │ └── go │ │ │ ├── Go-Bold.ttf │ │ │ ├── Go-Mono.ttf │ │ │ ├── Go-Italic.ttf │ │ │ ├── Go-Medium.ttf │ │ │ ├── Go-Mono-Bold.ttf │ │ │ ├── Go-Regular.ttf │ │ │ ├── Go-Smallcaps.ttf │ │ │ ├── Go-Bold-Italic.ttf │ │ │ ├── Go-Mono-Italic.ttf │ │ │ ├── Go-Medium-Italic.ttf │ │ │ ├── Go-Mono-Bold-Italic.ttf │ │ │ └── Go-Smallcaps-Italic.ttf │ ├── site.webmanifest │ └── scripts │ │ └── main.mjs ├── src │ ├── theme │ │ ├── DocSidebarItem │ │ │ └── Link │ │ │ │ └── styles.module.css │ │ ├── DocItem │ │ │ ├── Footer │ │ │ │ └── styles.module.css │ │ │ └── Layout │ │ │ │ └── styles.module.css │ │ ├── DocPage │ │ │ └── Layout │ │ │ │ ├── styles.module.css │ │ │ │ └── index.tsx │ │ ├── DocTagDocListPage │ │ │ └── styles.module.css │ │ ├── DocSidebar │ │ │ └── Desktop │ │ │ │ ├── Content │ │ │ │ ├── styles.module.css │ │ │ │ └── index.tsx │ │ │ │ ├── styles.module.css │ │ │ │ └── index.tsx │ │ ├── TOCCollapsible │ │ │ ├── styles.module.css │ │ │ └── index.tsx │ │ ├── Heading │ │ │ ├── styles.module.css │ │ │ └── index.tsx │ │ └── Tag │ │ │ └── index.tsx │ ├── components │ │ ├── HomepageFeatures │ │ │ └── styles.module.css │ │ └── DocIssueURL.tsx │ ├── pages │ │ └── index.module.css │ └── css │ │ ├── scanline.css │ │ ├── cursor.css │ │ ├── scrollbar.css │ │ ├── backgrounds.css │ │ ├── menu.css │ │ └── fonts.css ├── tsconfig.json ├── .gitignore ├── babel.config.cjs ├── docusaurus.config.js ├── package.json └── algolia.json ├── .node-version ├── .prettierignore ├── _category_.json ├── docgen ├── theme │ ├── resources │ │ └── partials │ │ │ ├── main.hbs │ │ │ ├── title.hbs │ │ │ ├── header.hbs │ │ │ ├── comment.hbs │ │ │ ├── member.getterSetter.hbs │ │ │ ├── members.group.hbs │ │ │ ├── members.hbs │ │ │ ├── member.hbs │ │ │ ├── member.sources.hbs │ │ │ ├── member.declaration.hbs │ │ │ └── member.signature.hbs │ ├── options-reader.ts │ ├── groups.ts │ └── navigation-item.ts ├── templates │ ├── index.hbs │ └── reflection.member.hbs ├── index.ts ├── utils │ ├── index.ts │ ├── runtime.ts │ └── front-matter.ts ├── helpers │ ├── escape.ts │ ├── relative-url.ts │ ├── if-show-returns.ts │ ├── if-named-anchors.ts │ ├── attemptExternalResolution.ts │ ├── if-show-breadcrumbs.ts │ ├── if-show-page-title.ts │ ├── if-show-named-anchors.ts │ ├── if-is-reference.ts │ ├── returns.ts │ ├── if-show-type-hierarchy.ts │ ├── index-signature-title.ts │ ├── usage-tabs.ts │ ├── humanizeReflectionName.ts │ ├── reference-member.ts │ ├── reflection-title.ts │ ├── hierarchy.ts │ ├── reflection-path.ts │ ├── comments.ts │ └── index.ts └── mdx │ ├── relativeLinks.mjs │ └── headingClasses.mjs ├── files ├── _category_.json ├── extensions │ ├── Styles.ts │ ├── PlainText.ts │ ├── Forms.ts │ ├── index.ts │ ├── XML.ts │ ├── Images.ts │ └── JavaScript.ts ├── common.ts ├── files.ts ├── extensionToMimeType.ts ├── index.ts └── mime.ts ├── http ├── _category_.json ├── headers │ ├── _category_.json │ └── index.ts ├── HTTPMethod.ts ├── responses │ ├── index.ts │ ├── NotModifiedResponse.ts │ └── HTMLResponse.ts ├── RouterMethod.ts ├── isInstanceOfRequest.ts ├── isInstanceOfResponse.ts ├── isRequestLike.ts ├── routerMethodToHTTPMethod.ts ├── methodVerbToRouterMethod.ts ├── cloneAsMutableResponse.ts ├── shouldCompress.ts ├── RequestContext.ts ├── index.ts └── IncomingRequestCfProperties.ts ├── node ├── _category_.json ├── files.ts ├── polyfills.ts ├── createServerHandler.test.tsx └── index.ts ├── router ├── _category_.json ├── MiddlewareDeclarationLike.ts ├── FetcherLike.ts ├── RouteMatch.ts ├── WorkerEnvFetchBinding.ts ├── MiddlewareDeclaration.ts ├── isMiddlewareDeclarationOption.ts ├── isFetcher.ts ├── ParsedRoute.ts ├── createRouteRedirect.ts └── RouteRequestHandler.ts ├── errors ├── _category_.json └── index.ts ├── events ├── _category_.json ├── index.ts └── IsomorphicFetchEventInit.ts ├── ssr ├── _category_.json ├── KeyworkProvidersComponent.tsx └── stream.ts ├── middleware ├── _category_.json └── SessionMiddleware.test.ts ├── .eslintignore ├── typedoc.json ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── doc.md │ └── feature-request.md ├── codecov.yml ├── dependabot.yml └── workflows │ ├── keywork-site.yml │ └── keywork-ci.yml ├── .editorconfig ├── .prettierrc.mjs ├── docs ├── license │ ├── index.md │ └── commercial.md ├── examples │ ├── url-params.md │ └── parsing-requests.md ├── PULL_REQUEST_TEMPLATE.md ├── getting-started │ └── index.md └── THIRD_PARTY_NOTICES.md ├── cli ├── index.ts └── yargs.ts ├── logging ├── index.ts └── LoggerContext.tsx ├── .gitignore ├── types ├── react-dom-server-node.d.ts └── react-dom-server-browser.d.ts ├── cloudflare ├── index.ts ├── EnvironmentBindingKinds.ts └── CloudflarePagesAssetRouter.ts ├── .yarnrc.yml ├── lifecycle └── index.ts ├── uri ├── index.ts ├── query.ts └── URLContext.ts ├── client ├── index.ts ├── hooks.ts ├── SSRRoute.tsx ├── hydrate.ts └── animation.ts ├── examples └── simple │ ├── public │ ├── main.tsx │ └── pages │ │ ├── TodoItem.tsx │ │ └── Index.tsx │ ├── api.ts │ └── _worker.tsx ├── utils ├── index.ts ├── json.ts ├── datetime.ts ├── globals.ts ├── constants.ts └── map.ts ├── index.cli.ts ├── SECURITY.md ├── testing └── index.ts ├── scripts └── import-map │ └── index.ts ├── .vscode └── settings.json └── tsconfig.json /site/static/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | 17.4.0 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | build/header.js 2 | -------------------------------------------------------------------------------- /_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "URI", 3 | "collapsible": true 4 | } 5 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/main.hbs: -------------------------------------------------------------------------------- 1 | {{{ toc }}} 2 | 3 | {{> members}} 4 | -------------------------------------------------------------------------------- /files/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Files", 3 | "collapsible": true 4 | } 5 | -------------------------------------------------------------------------------- /http/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "HTTP", 3 | "collapsible": true 4 | } 5 | -------------------------------------------------------------------------------- /node/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Node", 3 | "collapsible": true 4 | } 5 | -------------------------------------------------------------------------------- /router/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Routing", 3 | "position": 1 4 | } 5 | -------------------------------------------------------------------------------- /errors/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Errors", 3 | "collapsible": true 4 | } 5 | -------------------------------------------------------------------------------- /events/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Events", 3 | "collapsible": true 4 | } 5 | -------------------------------------------------------------------------------- /http/headers/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Headers", 3 | "collapsible": true 4 | } 5 | -------------------------------------------------------------------------------- /ssr/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "React", 3 | "collapsible": true, 4 | "position": 2 5 | } 6 | -------------------------------------------------------------------------------- /site/static/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/logo.png -------------------------------------------------------------------------------- /site/src/theme/DocSidebarItem/Link/styles.module.css: -------------------------------------------------------------------------------- 1 | .menuExternalLink { 2 | align-items: center; 3 | } 4 | -------------------------------------------------------------------------------- /site/static/img/dotted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/dotted.png -------------------------------------------------------------------------------- /site/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/favicon.ico -------------------------------------------------------------------------------- /site/static/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/favicon.png -------------------------------------------------------------------------------- /site/static/img/logo-sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/logo-sm.png -------------------------------------------------------------------------------- /middleware/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Middleware", 3 | "collapsible": true, 4 | "position": 2 5 | } 6 | -------------------------------------------------------------------------------- /docgen/templates/index.hbs: -------------------------------------------------------------------------------- 1 | {{> header}} 2 | 3 | {{#with model.readme}} 4 | 5 | {{{comment this}}} 6 | 7 | {{/with}} 8 | -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Bold.ttf -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Mono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Mono.ttf -------------------------------------------------------------------------------- /site/static/img/social-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/social-card.png -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Italic.ttf -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Medium.ttf -------------------------------------------------------------------------------- /site/static/img/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/favicon-16x16.png -------------------------------------------------------------------------------- /site/static/img/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/favicon-32x32.png -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/header.js 2 | dist/**/* 3 | site/build/**/* 4 | dist-worker/**/* 5 | dist-node/**/* 6 | node_modules/**/* 7 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/title.hbs: -------------------------------------------------------------------------------- 1 | {{#ifShowPageTitle}} 2 | 3 | {{{reflectionTitle true}}} 4 | 5 | {{/ifShowPageTitle}} 6 | -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Mono-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Mono-Bold.ttf -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Regular.ttf -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Smallcaps.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Smallcaps.ttf -------------------------------------------------------------------------------- /site/static/img/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/apple-touch-icon.png -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Bold-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Bold-Italic.ttf -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Mono-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Mono-Italic.ttf -------------------------------------------------------------------------------- /site/static/img/serverless-circle.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/serverless-circle.webp -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Medium-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Medium-Italic.ttf -------------------------------------------------------------------------------- /site/static/img/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/android-chrome-192x192.png -------------------------------------------------------------------------------- /site/static/img/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/img/android-chrome-512x512.png -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Mono-Bold-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Mono-Bold-Italic.ttf -------------------------------------------------------------------------------- /site/static/fonts/go/Go-Smallcaps-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sister-software/keywork/HEAD/site/static/fonts/go/Go-Smallcaps-Italic.ttf -------------------------------------------------------------------------------- /docgen/templates/reflection.member.hbs: -------------------------------------------------------------------------------- 1 | {{> header}} 2 | 3 | {{> title}} 4 | 5 | {{#with model}} 6 | 7 | {{> member}} 8 | 9 | {{/with}} 10 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/header.hbs: -------------------------------------------------------------------------------- 1 | {{{frontmatter}}} 2 | 3 | {{#ifShowBreadcrumbs}} 4 | 5 | {{{breadcrumbs}}} 6 | 7 | {{/ifShowBreadcrumbs}} 8 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/comment.hbs: -------------------------------------------------------------------------------- 1 | {{#with comment}} 2 | 3 | {{#if hasVisibleComponent}} 4 | 5 | {{{comments this}}} 6 | 7 | {{/if}} 8 | 9 | {{/with}} 10 | 11 | 12 | -------------------------------------------------------------------------------- /typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://typedoc.org/schema.json", 3 | "cname": "keywork.app", 4 | "excludeInternal": true, 5 | "exclude": ["**/test/**"], 6 | "excludeExternals": true, 7 | "name": "Keywork" 8 | } 9 | -------------------------------------------------------------------------------- /site/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // This file is not used in compilation. It is here just for a nice editor experience. 3 | "extends": "@tsconfig/docusaurus/tsconfig.json", 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /site/src/components/HomepageFeatures/styles.module.css: -------------------------------------------------------------------------------- 1 | .features { 2 | display: flex; 3 | align-items: center; 4 | padding: 2rem 0; 5 | width: 100%; 6 | } 7 | 8 | .featureSvg { 9 | height: 200px; 10 | width: 200px; 11 | } 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Question? 4 | url: https://github.com/sister-software/keywork/discussions/new 5 | about: Ask the community for help on our GitHub Discussions board 6 | -------------------------------------------------------------------------------- /site/src/theme/DocItem/Footer/styles.module.css: -------------------------------------------------------------------------------- 1 | .lastUpdated { 2 | margin-top: 0.2rem; 3 | font-style: italic; 4 | font-size: smaller; 5 | } 6 | 7 | @media (min-width: 997px) { 8 | .lastUpdated { 9 | text-align: right; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /site/src/theme/DocItem/Layout/styles.module.css: -------------------------------------------------------------------------------- 1 | .docItemContainer header + *, 2 | .docItemContainer article > *:first-child { 3 | margin-top: 0; 4 | } 5 | 6 | @media (min-width: 997px) { 7 | .docItemCol { 8 | max-width: 75% !important; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.github/codecov.yml: -------------------------------------------------------------------------------- 1 | comment: true 2 | codecov: 3 | require_ci_to_pass: true 4 | coverage: 5 | status: 6 | project: 7 | default: 8 | informational: true 9 | ignore: 10 | - "examples" 11 | - "docs" 12 | - "site" 13 | - ".vscode" 14 | - "build" 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/doc.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation improvement 3 | about: Suggest a documentation improvement 4 | title: "[Docs]: " 5 | labels: "documentation" 6 | --- 7 | 8 | ## What is your suggestion? 9 | 10 | ## How will this improve the docs? 11 | 12 | ## Are you interested in submitting a PR for this? 13 | -------------------------------------------------------------------------------- /site/src/theme/DocPage/Layout/styles.module.css: -------------------------------------------------------------------------------- 1 | .docPage { 2 | display: flex; 3 | position: relative; 4 | width: 100%; 5 | min-height: 100%; 6 | } 7 | 8 | .docsWrapper { 9 | display: flex; 10 | } 11 | 12 | 13 | @media (min-width: 768px) { 14 | .docPage { 15 | max-width: var(--docs-max-page-width); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /site/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | /api 7 | 8 | # Generated files 9 | .docusaurus 10 | .cache-loader 11 | 12 | # Misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /site/src/theme/DocTagDocListPage/styles.module.css: -------------------------------------------------------------------------------- 1 | 2 | .tagEntry { 3 | padding: 0.5rem; 4 | border: 1px solid var(--ifm-color-emphasis-400); 5 | background-color: white; 6 | } 7 | 8 | .tagEntry:nth-child(odd) { 9 | background-color: var(--nirrius-yellow-light); 10 | } 11 | 12 | .tagEntry p:last-child{ 13 | margin-bottom: 0; 14 | } 15 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/member.getterSetter.hbs: -------------------------------------------------------------------------------- 1 | {{#if getSignature}} 2 | 3 | {{#with getSignature}} 4 | 5 | {{> member.signature accessor="get" showSources=true }} 6 | 7 | {{/with}} 8 | 9 | {{/if}} 10 | 11 | {{#if setSignature}} 12 | 13 | {{#with setSignature}} 14 | 15 | {{> member.signature accessor="set" showSources=true }} 16 | 17 | {{/with}} 18 | 19 | {{/if}} -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea to improve Keywork 4 | title: "[Feat]: " 5 | labels: enhancement 6 | assignees: "" 7 | --- 8 | 9 | ## What is your suggestion? 10 | 11 | ## Why do you want this feature? 12 | 13 | ## Are there any workarounds to get this functionality today? 14 | 15 | ## Are you interested in submitting a PR for this? 16 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/members.group.hbs: -------------------------------------------------------------------------------- 1 | {{#if categories}} 2 | 3 | {{#each categories}} 4 | 5 | ## {{title}} {{../title}} 6 | 7 | {{#each children}} 8 | 9 |
10 | 11 | {{> member}} 12 | 13 |
14 | {{/each}} 15 | 16 | {{/each}} 17 | 18 | {{else}} 19 | 20 | ## {{title}} 21 | 22 | {{#each children}} 23 | 24 | {{> member}} 25 | 26 | {{/each}} 27 | 28 | {{/if}} 29 | -------------------------------------------------------------------------------- /site/static/img/stack-overflow.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /site/src/theme/DocSidebar/Desktop/Content/styles.module.css: -------------------------------------------------------------------------------- 1 | @media (min-width: 997px) { 2 | .menu { 3 | flex-grow: 1; 4 | padding: 0.5rem; 5 | } 6 | @supports (scrollbar-gutter: stable) { 7 | .menu { 8 | padding: 0.5rem 0 0.5rem 0.5rem; 9 | scrollbar-gutter: stable; 10 | } 11 | } 12 | 13 | .menuWithAnnouncementBar { 14 | margin-bottom: var(--docusaurus-announcement-bar-height); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 2 9 | end_of_line = lf 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [*.hbs] 14 | insert_final_newline = false 15 | 16 | [*.json] 17 | indent_size = 2 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [*.{yml,yaml}] 23 | indent_size = 2 24 | 25 | [Makefile] 26 | indent_style = tab 27 | -------------------------------------------------------------------------------- /.prettierrc.mjs: -------------------------------------------------------------------------------- 1 | import sisterSoftwarePrettierConfig from '@sister.software/prettier-config' 2 | 3 | /** 4 | * @type {import('prettier').Options} 5 | */ 6 | const prettierConfig = { 7 | ...sisterSoftwarePrettierConfig, 8 | useTabs: false, 9 | tabWidth: 2, 10 | trailingComma: 'es5', 11 | singleQuote: true, 12 | plugins: ['prettier-plugin-organize-imports'], 13 | organizeImportsSkipDestructiveCodeActions: false, 14 | } 15 | 16 | export default prettierConfig 17 | -------------------------------------------------------------------------------- /site/static/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Keywork", 3 | "short_name": "Keywork", 4 | "icons": [ 5 | { 6 | "src": "/img/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/img/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#eaffff", 17 | "background_color": "#fff6f6", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /site/src/pages/index.module.css: -------------------------------------------------------------------------------- 1 | /** 2 | * CSS files with the .module.css suffix will be treated as CSS modules 3 | * and scoped locally. 4 | */ 5 | 6 | .heroBanner { 7 | padding: 4rem 0; 8 | text-align: center; 9 | position: relative; 10 | overflow: hidden; 11 | } 12 | 13 | @media screen and (max-width: 996px) { 14 | .heroBanner { 15 | padding: 2rem; 16 | } 17 | } 18 | 19 | .buttons { 20 | display: flex; 21 | align-items: center; 22 | justify-content: center; 23 | } 24 | -------------------------------------------------------------------------------- /site/src/css/scanline.css: -------------------------------------------------------------------------------- 1 | #__docusaurus::before { 2 | content: ''; 3 | background-size: 8px; 4 | background-image: repeating-linear-gradient( 5 | 180deg, 6 | transparent 0, 7 | transparent 1px, 8 | hsl(0deg 0% 45% / 5%) 0, 9 | hsl(0deg 0% 45% / 5%) 2px 10 | ); 11 | display: block; 12 | z-index: 9999; 13 | position: fixed; 14 | top: 0; 15 | left: 0; 16 | right: 0; 17 | bottom: 0; 18 | width: 100%; 19 | height: 100%; 20 | pointer-events: none; 21 | } 22 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/members.hbs: -------------------------------------------------------------------------------- 1 | {{#if categories}} 2 | 3 | {{#each categories}} 4 | 5 | {{#unless allChildrenHaveOwnDocument}} 6 | 7 | ## {{title}} 8 | 9 | {{#each children}} 10 | 11 | {{#unless hasOwnDocument}} 12 | 13 | {{> member}} 14 | 15 | {{/unless}} 16 | 17 | {{/each}} 18 | 19 | {{/unless}} 20 | 21 | {{/each}} 22 | 23 | {{else}} 24 | 25 | {{#each groups}} 26 | 27 | {{#unless allChildrenHaveOwnDocument}} 28 | 29 | {{> members.group}} 30 | 31 | {{/unless}} 32 | 33 | {{/each}} 34 | 35 | {{/if}} 36 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/member.hbs: -------------------------------------------------------------------------------- 1 | {{#unless hasOwnDocument}} 2 | 3 | {{#if name}} 4 | 5 | ## {{{humanizeReflectionName}}} 6 | 7 | {{/if}} 8 | 9 | {{/unless}} 10 | 11 | {{#if signatures}} 12 | 13 | {{#each signatures}} 14 | 15 | {{> member.signature showSources=true }} 16 | 17 | {{/each}} 18 | 19 | {{else}} 20 | 21 | {{#if hasGetterOrSetter}} 22 | 23 | {{> member.getterSetter}} 24 | 25 | {{else}} 26 | 27 | {{#ifIsReference}} 28 | 29 | {{{referenceMember}}} 30 | 31 | {{else}} 32 | 33 | {{> member.declaration}} 34 | 35 | {{/ifIsReference}} 36 | 37 | {{/if}} 38 | 39 | {{/if}} 40 | -------------------------------------------------------------------------------- /site/static/img/cursor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/license/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_title: Licensing Overview 3 | title: Overview 4 | sidebar_position: 0 5 | hide_footer: true 6 | --- 7 | 8 | # Licensing Overview 9 | 10 | Whether your business runs on Cloudflare Workers, or Deno Deploy, 11 | building web apps is made faster and easier with **Keywork.** 12 | 13 | A [**commercial license**](/license/commercial) grants you full ownership and control over your products, 14 | and saves you from having to conform to our open-source requirements and restrictions. 15 | 16 | When you purchase a commercial license, you'll also have direct contact with the engineers who built Keywork. 17 | -------------------------------------------------------------------------------- /docgen/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './utils/runtime.js' 16 | -------------------------------------------------------------------------------- /docs/license/commercial.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Commercial Usage 3 | sidebar_label: Commercial Usage 4 | sidebar_position: 1 5 | id: commercial 6 | hide_footer: true 7 | --- 8 | 9 | # Commercial Usage 10 | 11 | A **commercial license** grants you full ownership and control over your products, 12 | and saves you from having to conform to our open-source requirements and restrictions. 13 | 14 | When you purchase a commercial license, you'll also have direct contact with the engineers who built Keywork. 15 | 16 | A ‘commercial use’ license is mandatory as soon as you develop commercial activities involving the Keywork software without disclosing the source code of your own applications. 17 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" 12 | - package-ecosystem: "npm" 13 | directory: "/modules" 14 | schedule: 15 | interval: "weekly" 16 | - package-ecosystem: "npm" 17 | directory: "/site" 18 | schedule: 19 | interval: "weekly" 20 | -------------------------------------------------------------------------------- /cli/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './serve.js' 16 | export * from './yargs.js' 17 | -------------------------------------------------------------------------------- /site/static/img/nirrius-repeat.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /site/src/theme/TOCCollapsible/styles.module.css: -------------------------------------------------------------------------------- 1 | .tocCollapsible { 2 | background-color: var(--ifm-menu-color-background-active); 3 | border-radius: var(--ifm-global-radius); 4 | margin: 1rem 0; 5 | border: 4px solid var(--ifm-color-emphasis-600); 6 | box-shadow: -6px 9px 0 var(--nirrius-shadow) !important; 7 | } 8 | 9 | .tocCollapsibleContent > ul { 10 | border-left: none; 11 | border-top: 1px solid var(--ifm-color-emphasis-300); 12 | padding: 0.2rem 0; 13 | font-size: 15px; 14 | } 15 | 16 | .tocCollapsibleContent ul li { 17 | margin: 0.4rem 0.8rem; 18 | } 19 | 20 | .tocCollapsibleContent a { 21 | display: block; 22 | } 23 | 24 | .tocCollapsibleExpanded { 25 | transform: none; 26 | } 27 | -------------------------------------------------------------------------------- /logging/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './KeyworkLogger.js' 16 | export * from './LoggerContext.js' 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .mf 4 | .tmp 5 | dist 6 | tsconfig.tsbuildinfo 7 | 8 | # Dependencies 9 | node_modules 10 | 11 | # Production 12 | /site/build 13 | /docs/modules 14 | 15 | # Generated files 16 | api-extractor/temp 17 | .docusaurus 18 | .cache-loader 19 | import_map.node.json 20 | import_map.worker.json 21 | cov.lcov 22 | cov/ 23 | modules/cov/ 24 | modules/cov.lcov 25 | 26 | # Misc 27 | .DS_Store 28 | .env.local 29 | .env.development.local 30 | .env.test.local 31 | .env.production.local 32 | 33 | npm-debug.log* 34 | yarn-debug.log* 35 | yarn-error.log* 36 | 37 | # Disable zero-install 38 | .pnp.* 39 | .yarn/* 40 | !.yarn/patches 41 | !.yarn/plugins 42 | !.yarn/releases 43 | !.yarn/sdks 44 | !.yarn/versions 45 | -------------------------------------------------------------------------------- /types/react-dom-server-node.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | declare module 'react-dom/server.node' { 15 | export * from 'react-dom/server' 16 | } 17 | -------------------------------------------------------------------------------- /site/babel.config.cjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | module.exports = { 16 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 17 | } 18 | -------------------------------------------------------------------------------- /types/react-dom-server-browser.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | declare module 'react-dom/server.browser' { 15 | export * from 'react-dom/server' 16 | } 17 | -------------------------------------------------------------------------------- /files/extensions/Styles.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export const CSS = { 16 | extension: 'css', 17 | mimeType: 'text/css; charset=utf-8', 18 | } as const 19 | -------------------------------------------------------------------------------- /files/extensions/PlainText.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export const PlainText = { 16 | extension: 'txt', 17 | mimeType: 'text/plain; charset=utf-8', 18 | } as const 19 | -------------------------------------------------------------------------------- /files/extensions/Forms.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export const URLFormData = { 16 | extension: 'url', 17 | mimeType: 'application/x-www-form-urlencoded', 18 | } as const 19 | -------------------------------------------------------------------------------- /cloudflare/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './CloudflarePagesAssetRouter.js' 16 | export * from './EnvironmentBindingKinds.js' 17 | export * from './bundling.js' 18 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/member.sources.hbs: -------------------------------------------------------------------------------- 1 | {{#if implementationOf}} 2 | 3 | #### Implementation of 4 | 5 | {{#with implementationOf}} 6 | 7 | {{{typeAndParent}}} 8 | 9 | {{/with}} 10 | 11 | {{/if}} 12 | 13 | {{#if inheritedFrom}} 14 | 15 | #### Inherited from 16 | 17 | {{#with inheritedFrom}} 18 | 19 | {{{typeAndParent}}} 20 | 21 | {{/with}} 22 | 23 | {{/if}} 24 | 25 | {{#if overwrites}} 26 | 27 | #### Overrides 28 | 29 | {{#with overwrites}} 30 | 31 | {{{typeAndParent}}} 32 | 33 | {{/with}} 34 | 35 | {{/if}} 36 | 37 | {{#if sources}} 38 | 39 | #### Defined in 40 | 41 | {{#each sources}} 42 | 43 | {{#if url}} 44 | 45 | [{{fileName}}:{{line}}]({{url}}) 46 | 47 | {{else}} 48 | 49 | {{fileName}}:{{line}} 50 | 51 | {{/if}} 52 | 53 | {{/each}} 54 | 55 | {{/if}} 56 | -------------------------------------------------------------------------------- /http/HTTPMethod.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * HTTP method verbs. 17 | */ 18 | export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | '*' 19 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | 3 | yarnPath: .yarn/releases/yarn-3.2.2.cjs 4 | 5 | supportedArchitectures: 6 | os: 7 | - 'current' 8 | - 'darwin' 9 | - 'linux' 10 | 11 | cpu: 12 | - 'current' 13 | - 'x86' 14 | - 'x64' 15 | - 'arm64' 16 | - 'ia32' 17 | 18 | packageExtensions: 19 | 'typedoc@*': 20 | peerDependencies: 21 | "typescript": "*" 22 | 23 | # This fixes an issue with docsearch's peer dependencies 24 | # https://github.com/algolia/docsearch/issues/1272 25 | '@docsearch/react@*': 26 | peerDependenciesMeta: 27 | '@algolia/client-search': 28 | optional: true 29 | '@types/react': 30 | optional: true 31 | 'react': 32 | optional: true 33 | 'react-dom': 34 | optional: true 35 | -------------------------------------------------------------------------------- /files/common.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * @internal 17 | */ 18 | export interface FileExtensionMime { 19 | readonly extension: string 20 | readonly mimeType: string 21 | } 22 | -------------------------------------------------------------------------------- /site/static/img/github-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /site/docusaurus.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /* eslint-disable @typescript-eslint/no-var-requires */ 16 | 17 | // @ts-check 18 | 19 | module.exports = import('./docusaurus.config.mjs').then(($) => $.default) 20 | -------------------------------------------------------------------------------- /docgen/utils/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './front-matter.js' 16 | export * from './model.js' 17 | export * from './reflections.js' 18 | export * from './runtime.js' 19 | export * from './sources.js' 20 | -------------------------------------------------------------------------------- /site/src/theme/Heading/styles.module.css: -------------------------------------------------------------------------------- 1 | /* stylelint-disable selector-pseudo-class-no-unknown */ 2 | 3 | /* 4 | When the navbar is sticky, ensure that on anchor click, 5 | the browser does not scroll that anchor behind the navbar 6 | See https://twitter.com/JoshWComeau/status/1332015868725891076 7 | */ 8 | 9 | .anchorWithStickyNavbar { 10 | scroll-margin-top: calc(var(--ifm-navbar-height) + 0.5rem); 11 | } 12 | 13 | .anchorWithHideOnScrollNavbar { 14 | scroll-margin-top: 0.5rem; 15 | } 16 | 17 | :global(.hash-link) { 18 | opacity: 0; 19 | padding-left: 0.5rem; 20 | transition: opacity var(--ifm-transition-fast); 21 | user-select: none; 22 | } 23 | 24 | :global(.hash-link::before) { 25 | content: '#'; 26 | } 27 | 28 | :global(.hash-link:focus), 29 | :global(*:hover > .hash-link) { 30 | opacity: 1; 31 | } 32 | -------------------------------------------------------------------------------- /lifecycle/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * @internal 17 | * @todo Migrate to native Symbol.dispose when it's available. 18 | */ 19 | export interface IDisposable { 20 | dispose(reason?: string): void | Promise 21 | } 22 | -------------------------------------------------------------------------------- /files/extensions/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './Forms.js' 16 | export * from './Images.js' 17 | export * from './JavaScript.js' 18 | export * from './PlainText.js' 19 | export * from './Styles.js' 20 | export * from './XML.js' 21 | -------------------------------------------------------------------------------- /http/responses/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './CachableResponse.js' 16 | export * from './ErrorResponse.js' 17 | export * from './HTMLResponse.js' 18 | export * from './JSONResponse.js' 19 | export * from './NotModifiedResponse.js' 20 | -------------------------------------------------------------------------------- /uri/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './URLContext.js' 16 | export * from './URLMatchContext.js' 17 | export * from './URLPattern.js' 18 | export * from './URLPatternRouteMap.js' 19 | export * from './modules.js' 20 | export * from './query.js' 21 | -------------------------------------------------------------------------------- /http/RouterMethod.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * Normalized HTTP methods in a JavaScript friendly format. 17 | * 18 | * @see {RequestRouter} 19 | */ 20 | export type RouterMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head' | 'options' | 'all' 21 | -------------------------------------------------------------------------------- /client/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './BrowserRouter.js' 16 | export * from './KeyworkPatternToPageComponent.js' 17 | export * from './SSRPropsProvider.js' 18 | export * from './animation.js' 19 | export * from './dom.js' 20 | export * from './hydrate.js' 21 | -------------------------------------------------------------------------------- /site/src/css/cursor.css: -------------------------------------------------------------------------------- 1 | #__docusaurus { 2 | cursor: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjE0cHgiIGhlaWdodD0iMTRweCIgdmlld0JveD0iMCAwIDI0IDI0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbG5zOnNrZXRjaD0iaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoL25zIj4KICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMC43IiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPgogICAgPHBhdGggZD0iTTEyLjY2NzI2MTYsMTkuNzQ3ODQzNyBMMjAuMjIwNTYyNCwxMi4xOTQ1NDI5IEwxNC45MTcyNjE2LDYuODkxMjQyMDEgTDIxLjA0NDAzNjksMSBMMSwxIEwxLDIwLjQ3ODE3OTkgTDcuMzYzOTYwNzEsMTQuNDQ0NTQyOSBMMTIuNjY3MjYxNiwxOS43NDc4NDM3IFoiIGlkPSJSZWN0YW5nbGUtMSIgc3Ryb2tlPSIjRkZGRkZGIiBmaWxsPSIjMDAwMDAwIj48L3BhdGg+CiAgPC9nPgo8L3N2Zz4K"), 3 | default; 4 | } 5 | -------------------------------------------------------------------------------- /files/files.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * Returns the given `fileName` extension. 17 | */ 18 | export const fileNameToExtension = (fileName: string) => { 19 | const dotIndex = fileName.lastIndexOf('.') 20 | return dotIndex === -1 ? '' : fileName.slice(dotIndex + 1) 21 | } 22 | -------------------------------------------------------------------------------- /router/MiddlewareDeclarationLike.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { Fetcher } from './Fetcher.js' 16 | import type { MiddlewareDeclaration } from './MiddlewareDeclaration.js' 17 | 18 | /** @ignore */ 19 | export type MiddlewareDeclarationLike = Fetcher | MiddlewareDeclaration 20 | -------------------------------------------------------------------------------- /docgen/helpers/escape.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import Handlebars from 'handlebars' 15 | import { escapeChars } from '../utils/index.js' 16 | 17 | export function escapeHelper() { 18 | Handlebars.registerHelper('escape', function (str: string) { 19 | return escapeChars(str) 20 | }) 21 | } 22 | -------------------------------------------------------------------------------- /files/extensionToMimeType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import * as extensions from './extensions/index.js' 16 | 17 | export const extensionToMimeType = new Map( 18 | Object.values(extensions).map(({ extension, mimeType }) => { 19 | return [extension, mimeType] 20 | }) 21 | ) 22 | -------------------------------------------------------------------------------- /router/FetcherLike.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { Fetcher } from './Fetcher.js' 16 | import type { RouteRequestHandler } from './RouteRequestHandler.js' 17 | 18 | /** @ignore */ 19 | export type FetcherLike = Fetcher | RouteRequestHandler 20 | -------------------------------------------------------------------------------- /router/RouteMatch.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { URLPatternResult } from '../uri/index.js' 16 | import type { ParsedRoute } from './ParsedRoute.js' 17 | /** 18 | * @ignore 19 | */ 20 | export interface RouteMatch { 21 | match: URLPatternResult 22 | parsedRoute: ParsedRoute 23 | } 24 | -------------------------------------------------------------------------------- /router/WorkerEnvFetchBinding.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * An environment binding within a worker that has a `fetch` method. 17 | * This usually is related to static assets uploaded to Cloudflare KV via Wrangler's Worker Sites. 18 | */ 19 | export interface WorkerEnvFetchBinding { 20 | fetch: typeof fetch 21 | } 22 | -------------------------------------------------------------------------------- /examples/simple/public/main.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { BrowserRouter } from 'keywork' 16 | import { IndexPage } from './pages/Index.js' 17 | import { TodoItemPage } from './pages/TodoItem.js' 18 | 19 | export default ( 20 | 26 | ) 27 | -------------------------------------------------------------------------------- /utils/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './constants.js' 16 | export * from './datetime.js' 17 | export * from './globals.js' 18 | export * from './ids.js' 19 | export * from './json.js' 20 | export * from './map.js' 21 | export * from './numbers.js' 22 | export * from './paths.js' 23 | export * from './polyfills.js' 24 | export * from './strings.js' 25 | -------------------------------------------------------------------------------- /site/src/theme/DocSidebar/Desktop/Content/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Content from '@theme-original/DocSidebar/Desktop/Content' 16 | import React from 'react' 17 | 18 | export default function ContentWrapper(props) { 19 | return ( 20 | <> 21 |
22 | 23 | 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /files/extensions/XML.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export const HTML = { 16 | extension: 'html', 17 | mimeType: 'text/html; charset=utf-8', 18 | } as const 19 | 20 | export const XML = { 21 | extension: 'xml', 22 | mimeType: 'application/xml; charset=utf-8', 23 | } as const 24 | 25 | export const SVG = { 26 | extension: 'svg', 27 | mimeType: 'image/svg+xml', 28 | } as const 29 | -------------------------------------------------------------------------------- /http/isInstanceOfRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * Checks if the given object is an instance of `Request` 17 | * @param requestish An object that's possibly a `Request` 18 | * @category Type Cast 19 | */ 20 | export function isInstanceOfRequest(requestish: unknown): requestish is Request { 21 | return Boolean(requestish instanceof Request || requestish instanceof Request) 22 | } 23 | -------------------------------------------------------------------------------- /http/isInstanceOfResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * Checks if the given object is an instance of `Response` 17 | * @param responsish An object that's possibly a `Response` 18 | * @category Type Cast 19 | */ 20 | export function isInstanceOfResponse(responsish: unknown): responsish is Response { 21 | return Boolean(responsish instanceof Response || responsish instanceof Response) 22 | } 23 | -------------------------------------------------------------------------------- /docgen/helpers/relative-url.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | 17 | import type { MarkdownTheme } from '../theme/index.js' 18 | 19 | export function relativeURLHelper(theme: MarkdownTheme) { 20 | Handlebars.registerHelper('relativeURL', function (url: string) { 21 | return url ? (theme.publicPath ? theme.publicPath + url : theme.getRelativeUrl(url)) : url 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /docgen/theme/options-reader.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { Options, OptionsReader } from 'typedoc' 16 | 17 | export class MarkdownThemeOptionsReader implements OptionsReader { 18 | priority = 1000 19 | name = 'markdown-theme-reader' 20 | read(container: Options) { 21 | if (container.getValue('theme') === 'default') { 22 | container.setValue('theme', 'markdown') 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /utils/json.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * @category JSON 17 | * @ignore 18 | */ 19 | export type PrettyJSON = (...args: Parameters) => string 20 | 21 | /** 22 | * Stringifies JSON into an indented string. 23 | * 24 | * @category JSON 25 | */ 26 | export const prettyJSON: PrettyJSON = (value, replacer = null, space = 2) => { 27 | return JSON.stringify(value, replacer, space) 28 | } 29 | -------------------------------------------------------------------------------- /examples/simple/public/pages/TodoItem.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export interface TodoItemPageProps { 16 | id: string 17 | title: string 18 | completed: boolean 19 | } 20 | 21 | export const TodoItemPage: React.FC = ({ title, completed, id }) => { 22 | return ( 23 |
24 |

{title}

25 |

{completed ? 'Complete' : 'Not complete'}

26 |

{id}

27 |
28 | ) 29 | } 30 | -------------------------------------------------------------------------------- /docgen/helpers/if-show-returns.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import Handlebars from 'handlebars' 15 | import { ReflectionKind, SignatureReflection } from 'typedoc' 16 | 17 | export function ifShowReturnsHelper() { 18 | Handlebars.registerHelper('ifShowReturns', function (this: SignatureReflection, options: Handlebars.HelperOptions) { 19 | return this.type && !this.parent?.kindOf(ReflectionKind.Constructor) ? options.fn(this) : options.inverse(this) 20 | }) 21 | } 22 | -------------------------------------------------------------------------------- /docgen/helpers/if-named-anchors.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import Handlebars from 'handlebars' 15 | import type { PageEvent } from 'typedoc' 16 | import type { MarkdownTheme } from '../theme/index.js' 17 | 18 | export function ifNamedAnchors(theme: MarkdownTheme) { 19 | Handlebars.registerHelper('ifNamedAnchors', function (this: PageEvent, options: Handlebars.HelperOptions) { 20 | return theme.namedAnchors ? options.fn(this) : options.inverse(this) 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /files/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Keywork includes utilities for working with files, 3 | * such as determining the MIME type while handling an incoming HTTP request. 4 | * 5 | * @packageDocumentation 6 | * @module Keywork#FileUtils 7 | * 8 | * @file This file is part of the Keywork project. 9 | * @copyright Nirrius, LLC. All rights reserved. 10 | * @author Teffen Ellis, et al. 11 | * @license AGPL-3.0 12 | * 13 | * @remarks Keywork is free software for non-commercial purposes. 14 | * You can be released from the requirements of the license by purchasing a commercial license. 15 | * Buying such a license is mandatory as soon as you develop commercial activities 16 | * involving the Keywork software without disclosing the source code of your own applications. 17 | * 18 | * @see LICENSE.md in the project root for further licensing information. 19 | */ 20 | /* eslint-disable header/header */ 21 | 22 | export * from './common.js' 23 | export * from './extensionToMimeType.js' 24 | export * from './files.js' 25 | export * from './import-map.js' 26 | export * from './mime.js' 27 | -------------------------------------------------------------------------------- /docgen/helpers/attemptExternalResolution.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | import type { ReferenceType } from 'typedoc' 17 | import type { MarkdownTheme } from '../theme/index.js' 18 | 19 | export function attemptExternalResolutionHelper(theme: MarkdownTheme) { 20 | Handlebars.registerHelper('attemptExternalResolution', function (type: ReferenceType) { 21 | return (theme.owner as any).attemptExternalResolution(type) 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /docgen/helpers/if-show-breadcrumbs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import Handlebars from 'handlebars' 15 | import { PageEvent } from 'typedoc' 16 | import type { MarkdownTheme } from '../theme/index.js' 17 | 18 | export function ifShowBreadcrumbsHelper(theme: MarkdownTheme) { 19 | Handlebars.registerHelper('ifShowBreadcrumbs', function (this: PageEvent, options: Handlebars.HelperOptions) { 20 | return theme.hideBreadcrumbs ? options.inverse(this) : options.fn(this) 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /docgen/helpers/if-show-page-title.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | import { PageEvent } from 'typedoc' 17 | import type { MarkdownTheme } from '../theme/index.js' 18 | 19 | export function ifShowPageTitleHelper(theme: MarkdownTheme) { 20 | Handlebars.registerHelper('ifShowPageTitle', function (this: PageEvent, options: Handlebars.HelperOptions) { 21 | return theme.hidePageTitle ? options.inverse(this) : options.fn(this) 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /docgen/helpers/if-show-named-anchors.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | import { PageEvent } from 'typedoc' 17 | import type { MarkdownTheme } from '../theme/index.js' 18 | 19 | export function ifShowNamedAnchorsHelper(theme: MarkdownTheme) { 20 | Handlebars.registerHelper('ifShowNamedAnchors', function (this: PageEvent, options: Handlebars.HelperOptions) { 21 | return theme.namedAnchors ? options.fn(this) : options.inverse(this) 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /docgen/helpers/if-is-reference.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import Handlebars from 'handlebars' 15 | import { DeclarationReflection, ReferenceReflection } from 'typedoc' 16 | 17 | export function ifIsReference() { 18 | Handlebars.registerHelper( 19 | 'ifIsReference', 20 | function (this: DeclarationReflection | ReferenceReflection, options: Handlebars.HelperOptions) { 21 | return this instanceof ReferenceReflection ? options.fn(this) : options.inverse(this) 22 | } 23 | ) 24 | } 25 | -------------------------------------------------------------------------------- /docs/examples/url-params.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: url-params 3 | title: Parsing URL Params 4 | sidebar_position: 3 5 | sidebar_label: Parsing URL Params 6 | --- 7 | 8 | ```tsx title="worker/routers/users.ts" showLineNumbers 9 | export const usersRouter = new RequestRouter({ 10 | displayName: 'Users Router', 11 | DocumentComponent: AppHTMLDocument, 12 | session: true, 13 | }) 14 | 15 | // highlight-start 16 | interface GetUserParams { 17 | username: string 18 | } 19 | // highlight-end 20 | 21 | // Declaring a route that returns a React element... 22 | // highlight-next-line 23 | users.get('/profile/:username', async ({ session, params }) => { 24 | const user = database.fetchBy({ username }) 25 | let isFriends: boolean 26 | 27 | if (!user) { 28 | return new KeyworkResourceError(`${username} not found`, 404) 29 | } 30 | 31 | if (session) { 32 | const currentUser = database.fetchBy({ sessionID: session.sessionID }) 33 | isFriends = currentUser && user.friendsList.includes(currentUser.id) 34 | } 35 | 36 | return 37 | }) 38 | ``` 39 | -------------------------------------------------------------------------------- /docgen/utils/runtime.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export const runtimePattern = /runtime="([\w]+)"/ 16 | 17 | export type Runtime = 'cloudflare' | 'deno' | 'browser' | 'node' 18 | 19 | const runtimeLabels = { 20 | cloudflare: 'Cloudflare Workers', 21 | deno: 'Deno', 22 | browser: 'Browser/ESM', 23 | node: 'Node', 24 | } as const 25 | 26 | /** 27 | * 28 | * @param {string} runtime 29 | */ 30 | export function runtimeToTabLabel(runtime: Runtime) { 31 | return runtimeLabels[runtime] || runtime 32 | } 33 | -------------------------------------------------------------------------------- /ssr/KeyworkProvidersComponent.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { FC, ReactNode } from 'react' 16 | 17 | export interface ProviderWrapperProps { 18 | children: ReactNode 19 | } 20 | 21 | /** 22 | * A component which wraps the current SSR routes. 23 | * Use this if you need to inject a provider into the SSR pipeline. 24 | */ 25 | export type KeyworkProvidersComponent = FC 26 | 27 | export const KeyworkProviders: KeyworkProvidersComponent = ({ children }) => { 28 | return <>{children} 29 | } 30 | -------------------------------------------------------------------------------- /router/MiddlewareDeclaration.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { Fetcher } from './Fetcher.js' 16 | 17 | /** 18 | * Middleware declaration in the convenient shape of `Map`'s constructor parameters. 19 | * 20 | * @category Options 21 | * @typeParam PathPatternPrefix A path prefix defining where the middleware should be mounted. Combines with the given router's routes. 22 | */ 23 | export type MiddlewareDeclaration = readonly [ 24 | PathPatternPrefix, 25 | Fetcher, 26 | ] 27 | -------------------------------------------------------------------------------- /router/isMiddlewareDeclarationOption.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { MiddlewareDeclaration } from './MiddlewareDeclaration.js' 16 | import type { MiddlewareDeclarationLike } from './MiddlewareDeclarationLike.js' 17 | 18 | /** 19 | * Utility function for parsing middleware options. 20 | * @ignore 21 | * @category Type Cast 22 | */ 23 | export function isMiddlewareDeclarationOption( 24 | optionValue: MiddlewareDeclarationLike 25 | ): optionValue is MiddlewareDeclaration { 26 | return Array.isArray(optionValue) 27 | } 28 | -------------------------------------------------------------------------------- /utils/datetime.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | * 14 | * @packageDocumentation 15 | * @module Keywork#DatetimeUtils 16 | */ 17 | /* eslint-disable header/header */ 18 | 19 | /** 5 minutes in milliseconds. */ 20 | export const DURATION_FIVE_MINUTES = 60 * 5 * 1000 21 | 22 | /** 1 hour in milliseconds. */ 23 | export const DURATION_ONE_HOUR = 60 * 60 * 1000 24 | 25 | /** 1 day in milliseconds. */ 26 | export const DURATION_ONE_DAY = 24 * 60 * 60 * 1000 27 | 28 | /** 1 week in milliseconds. */ 29 | export const DURATION_ONE_WEEK = DURATION_ONE_DAY * 7 30 | -------------------------------------------------------------------------------- /cloudflare/EnvironmentBindingKinds.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { DurableObjectNamespace, KVNamespace } from '@cloudflare/workers-types' 16 | import type { WorkerEnvFetchBinding } from '../router/index.js' 17 | 18 | /** 19 | * Either: 20 | * 21 | * - `WorkerEnvFetchBinding` A `fetch` binding, usually an asset KV or external Worker. 22 | * - `KVNamespace` A KV binding. 23 | * - `DurableObjectNamespace` A Durable Object. 24 | */ 25 | export type EnvironmentBindingKinds = WorkerEnvFetchBinding | KVNamespace | DurableObjectNamespace 26 | -------------------------------------------------------------------------------- /router/isFetcher.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { Fetcher } from './Fetcher.js' 16 | 17 | /** 18 | * Checks if a given object is shaped like a KeyworkFetcher 19 | * 20 | * This fixes some weirdness where `instanceof` may get clobbered 21 | * by a user's ESBuild configuration. 22 | * 23 | * @internal 24 | * @ignore 25 | */ 26 | export function isFetcher(fetcherLike: unknown): fetcherLike is Fetcher { 27 | return Boolean(fetcherLike && typeof fetcherLike === 'object' && 'fetch' in fetcherLike) 28 | } 29 | -------------------------------------------------------------------------------- /files/extensions/Images.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export const Ico = { 16 | extension: 'ico', 17 | mimeType: 'image/x-icon', 18 | } as const 19 | 20 | export const JPG = { 21 | extension: 'jpg', 22 | mimeType: 'image/jpeg', 23 | } as const 24 | 25 | export const JPEG = { 26 | extension: 'jpeg', 27 | mimeType: 'image/jpeg', 28 | } as const 29 | 30 | export const PNG = { 31 | extension: 'png', 32 | mimeType: 'image/png', 33 | } as const 34 | 35 | export const WEBP = { 36 | extension: 'webp', 37 | mimeType: 'image/webp', 38 | } as const 39 | -------------------------------------------------------------------------------- /http/isRequestLike.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * An object that has a `url` property. 17 | * 18 | * @category Type Cast 19 | * @ignore 20 | */ 21 | export type RequestLike = { url: string } 22 | 23 | /** 24 | * Checks if the given object is shaped like a `Request` 25 | * @param requestish An object that's possibly a `Request` 26 | * @category Type Cast 27 | */ 28 | export function isRequestLike(requestish: unknown): requestish is RequestLike { 29 | return Boolean(requestish && typeof requestish === 'object' && (requestish as any).url) 30 | } 31 | -------------------------------------------------------------------------------- /client/hooks.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import { useEffect, useState } from 'react' 15 | 16 | export function useLocation() { 17 | const [currentLocation, setCurrentLocation] = useState(location) 18 | 19 | useEffect(() => { 20 | const popStateHandler = (_event: PopStateEvent) => { 21 | setCurrentLocation(location) 22 | } 23 | 24 | window.addEventListener('popstate', popStateHandler) 25 | 26 | return () => { 27 | window.removeEventListener('popstate', popStateHandler) 28 | } 29 | }, []) 30 | 31 | return currentLocation 32 | } 33 | -------------------------------------------------------------------------------- /docgen/helpers/returns.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | import { Comment } from 'typedoc' 17 | 18 | export function returnsHelper() { 19 | Handlebars.registerHelper('returns', function (comment: Comment) { 20 | const md: string[] = [] 21 | 22 | if (comment.blockTags?.length) { 23 | const tags = comment.blockTags 24 | .filter((tag) => tag.tag === '@returns') 25 | .map((tag) => Handlebars.helpers.comment(tag.content)) 26 | md.push(tags.join('\n\n')) 27 | } 28 | 29 | return md.join('') 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /http/routerMethodToHTTPMethod.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { HTTPMethod } from './HTTPMethod.js' 16 | import type { RouterMethod } from './RouterMethod.js' 17 | import { methodVerbToRouterMethod } from './methodVerbToRouterMethod.js' 18 | 19 | /** 20 | * Given a standardized uppercase method verb such as `GET`, return the normalized form. 21 | */ 22 | export const routerMethodToHTTPMethod = new Map( 23 | Array.from(methodVerbToRouterMethod.entries(), ([httpMethod, routerMethod]) => { 24 | return [routerMethod, httpMethod] 25 | }) 26 | ) 27 | -------------------------------------------------------------------------------- /uri/query.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * A boolean-like query param that hints to the worker that client-side React 17 | * only needs the static props for an upcoming page transition. 18 | */ 19 | export const KEYWORK_STATIC_PROPS_QUERY_KEY = 'static-props' 20 | 21 | /** 22 | * Predicate to determine if a URL is a static props request. 23 | */ 24 | export function isStaticPropsRequestURL(url: URL | string): boolean { 25 | if (typeof url === 'string') { 26 | url = new URL(url) 27 | } 28 | 29 | return url.searchParams.has(KEYWORK_STATIC_PROPS_QUERY_KEY) 30 | } 31 | -------------------------------------------------------------------------------- /docgen/helpers/if-show-type-hierarchy.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import Handlebars from 'handlebars' 15 | import { DeclarationHierarchy, DeclarationReflection, PageEvent } from 'typedoc' 16 | 17 | export function ifShowTypeHierarchyHelper() { 18 | Handlebars.registerHelper( 19 | 'ifShowTypeHierarchy', 20 | function (this: PageEvent, options: Handlebars.HelperOptions) { 21 | const typeHierarchy = this.model?.typeHierarchy as DeclarationHierarchy 22 | return typeHierarchy && typeHierarchy.next ? options.fn(this) : options.inverse(this) 23 | } 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /uri/URLContext.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { createContext, useContext } from 'react' 16 | 17 | /** 18 | * Context for consuming the current location. 19 | * This is the URL of the current page and should be used 20 | * when hydrating the application. 21 | * 22 | * @see {KeyworkApp} 23 | * @internal 24 | */ 25 | export const URLContext = createContext(undefined as any) 26 | URLContext.displayName = 'URLContext' 27 | 28 | /** 29 | * Hook for consuming the current location during hydration. 30 | * @internal 31 | */ 32 | export function useURLContext() { 33 | return useContext(URLContext) 34 | } 35 | -------------------------------------------------------------------------------- /http/methodVerbToRouterMethod.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { ImmutableMap } from '../utils/index.js' 16 | import type { HTTPMethod } from './HTTPMethod.js' 17 | import type { RouterMethod } from './RouterMethod.js' 18 | 19 | /** 20 | * Given a standard uppercase HTTP method verb such as `GET`, return the router method name. 21 | */ 22 | export const methodVerbToRouterMethod = new ImmutableMap([ 23 | ['GET', 'get'], 24 | ['POST', 'post'], 25 | ['PUT', 'put'], 26 | ['PATCH', 'patch'], 27 | ['DELETE', 'delete'], 28 | ['HEAD', 'head'], 29 | ['OPTIONS', 'options'], 30 | ['*', 'all'], 31 | ]) 32 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/member.declaration.hbs: -------------------------------------------------------------------------------- 1 | {{{declarationTitle}}} 2 | 3 | {{> comment}} 4 | 5 | {{#if typeParameters}} 6 | 7 |
8 | 9 | #### Type parameters 10 | 11 | {{#with typeParameters}} 12 | 13 | {{{typeParameterTable}}} 14 | 15 | {{/with}} 16 | 17 |
18 | 19 | {{/if}} 20 | 21 | {{#if type.declaration}} 22 | 23 | {{#if type.declaration.indexSignature}} 24 | 25 | {{#with type.declaration.indexSignature}} 26 | 27 | 28 | #### Index signature 29 | 30 | {{{indexSignatureTitle}}} 31 | 32 | {{> comment}} 33 | 34 | {{/with}} 35 | 36 | {{/if}} 37 | 38 | {{#if type.declaration.signatures}} 39 | 40 | {{#if type.declaration.children}} 41 | 42 | 43 | #### Call signature 44 | 45 | {{else}} 46 | 47 | #### Type declaration 48 | 49 | {{/if}} 50 | 51 | {{#each type.declaration.signatures}} 52 | 53 | {{> member.signature showSources=false }} 54 | 55 | {{/each}} 56 | 57 | {{/if}} 58 | 59 | {{#if type.declaration.children}} 60 | 61 | {{#with type.declaration}} 62 | 63 | #### Type declaration 64 | 65 | {{/with}} 66 | 67 | {{#with type.declaration.children}} 68 | 69 | {{{propertyTable}}} 70 | 71 | {{/with}} 72 | 73 | {{/if}} 74 | 75 | {{/if}} 76 | 77 | {{> member.sources}} 78 | -------------------------------------------------------------------------------- /events/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Keywork uses the JavaScript [Events API](https://developer.mozilla.org/en-US/docs/Web/API/Event) 3 | * internally to handle HTTP requests. 4 | * 5 | * ## Related Entries 6 | * 7 | * - {@link Keywork#Router Router Module} 8 | * 9 | * @packageDocumentation 10 | * @module Keywork#Events 11 | * 12 | * @file This file is part of the Keywork project. 13 | * @copyright Nirrius, LLC. All rights reserved. 14 | * @author Teffen Ellis, et al. 15 | * @license AGPL-3.0 16 | * 17 | * @remarks Keywork is free software for non-commercial purposes. 18 | * You can be released from the requirements of the license by purchasing a commercial license. 19 | * Buying such a license is mandatory as soon as you develop commercial activities 20 | * involving the Keywork software without disclosing the source code of your own applications. 21 | * 22 | * @see LICENSE.md in the project root for further licensing information. 23 | */ 24 | /* eslint-disable header/header */ 25 | 26 | export * from './EnvironmentContext.js' 27 | export * from './FetchEventProvider.js' 28 | export * from './IsomorphicExtendableEvent.js' 29 | export * from './IsomorphicFetchEvent.js' 30 | export * from './IsomorphicFetchEventInit.js' 31 | export * from './SSRDocument.js' 32 | -------------------------------------------------------------------------------- /docgen/helpers/index-signature-title.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | import { SignatureReflection } from 'typedoc' 17 | 18 | export function indexSignatureTitleHelper() { 19 | Handlebars.registerHelper('indexSignatureTitle', function (this: SignatureReflection) { 20 | const md = ['▪'] 21 | const parameters = this.parameters 22 | ? this.parameters.map((parameter) => { 23 | return `${parameter.name}: ${Handlebars.helpers.type.call(parameter.type)}` 24 | }) 25 | : [] 26 | md.push(`[${parameters.join('')}]: ${Handlebars.helpers.type.call(this.type)}`) 27 | return md.join(' ') 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /http/responses/NotModifiedResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import { Status, STATUS_TEXT } from '../../errors/index.js' 15 | 16 | /** 17 | * Given that a request's etag header matches an server entity or resource, 18 | * a `NotModifiedResponse` should be sent to the requestor as an indication that the client's cache is still applicable. 19 | * 20 | * @category HTTP Response 21 | * @category Cache 22 | */ 23 | export class NotModifiedResponse extends Response { 24 | constructor(etag: string) { 25 | super(undefined, { 26 | status: Status.NotModified, 27 | statusText: STATUS_TEXT[Status.NotModified], 28 | headers: { ETag: etag }, 29 | }) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /utils/globals.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { KeyworkResourceError, Status } from '../errors/index.js' 16 | 17 | /** 18 | * @internal 19 | */ 20 | export function readGlobalScope(this: any): typeof globalThis { 21 | if (typeof globalThis !== 'undefined') return globalThis 22 | // @ts-ignore global 23 | if (typeof window !== 'undefined') return window 24 | // @ts-ignore global 25 | if (typeof self !== 'undefined') return self 26 | // @ts-ignore global 27 | if (typeof global !== 'undefined') return global 28 | if (typeof this !== 'undefined') return this 29 | 30 | throw new KeyworkResourceError('Could not identify global scope', Status.FailedDependency) 31 | } 32 | -------------------------------------------------------------------------------- /http/cloneAsMutableResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * HTTP Status codes associated with a `Response.body === null` 17 | * @see {@link https://fetch.spec.whatwg.org/#null-body-status WHATWG Spec} 18 | * 19 | */ 20 | const NULL_BODY_STATUSES = new Set([101, 204, 205, 304]) 21 | 22 | /** 23 | * Clones a given `Response` as a mutable instance. 24 | */ 25 | export function cloneAsMutableResponse(response: Response) { 26 | return new Response( 27 | // This shouldn't be confused with `response.bodyIsUsed` 28 | // https://fetch.spec.whatwg.org/#dom-body-bodyused 29 | NULL_BODY_STATUSES.has(response.status) ? null : response.body, 30 | response 31 | ) 32 | } 33 | -------------------------------------------------------------------------------- /site/src/theme/Tag/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Link from '@docusaurus/Link' 16 | import clsx from 'clsx' 17 | import React from 'react' 18 | import styles from './styles.module.css' 19 | 20 | interface TagProps { 21 | permalink: string 22 | label: string 23 | count?: number 24 | } 25 | 26 | const Tag: React.FC = ({ permalink, label, count }) => { 27 | return ( 28 | 33 | {label} 34 | {count && {count}} 35 | 36 | ) 37 | } 38 | 39 | export default Tag 40 | -------------------------------------------------------------------------------- /files/extensions/JavaScript.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export const JavaScript = { 16 | extension: 'js', 17 | mimeType: 'application/javascript; charset=utf-8', 18 | } as const 19 | 20 | export const JavaScriptModule = { 21 | extension: 'mjs', 22 | mimeType: 'application/javascript; charset=utf-8', 23 | } as const 24 | 25 | export const JSON = { 26 | extension: 'json', 27 | mimeType: 'application/json; charset=utf-8', 28 | } as const 29 | 30 | export const JSONLinkedData = { 31 | extension: 'jsonld', 32 | mimeType: 'application/json+ld; charset=utf-8', 33 | } as const 34 | 35 | export const JSONWebManifest = { 36 | extension: 'webmanifest', 37 | mimeType: 'application/manifest+json', 38 | } 39 | -------------------------------------------------------------------------------- /index.cli.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * @file This file is part of the Keywork project. 4 | * @copyright Nirrius, LLC. All rights reserved. 5 | * @author Teffen Ellis, et al. 6 | * @license AGPL-3.0 7 | * 8 | * @remarks Keywork is free software for non-commercial purposes. 9 | * You can be released from the requirements of the license by purchasing a commercial license. 10 | * Buying such a license is mandatory as soon as you develop commercial activities 11 | * involving the Keywork software without disclosing the source code of your own applications. 12 | * 13 | * @see LICENSE.md in the project root for further licensing information. 14 | */ 15 | 16 | import yargs from 'yargs' 17 | import { hideBin } from 'yargs/helpers' 18 | import { serveBuilder, serveCommand } from './cli/index.js' 19 | 20 | const cli = yargs(hideBin(process.argv), process.cwd()) 21 | // -- 22 | .scriptName('keywork') 23 | .config('keywork') 24 | .strict() 25 | .wrap(72) 26 | 27 | cli 28 | // -- 29 | .command('serve ', 'Serves a Keywork Router', serveCommand, serveBuilder) 30 | .alias('s', 'serve') 31 | 32 | cli.help() 33 | 34 | await cli 35 | .check((argv) => { 36 | if (argv._.length === 0) { 37 | throw new Error('No command specified') 38 | } 39 | return true 40 | }) 41 | .parse() 42 | -------------------------------------------------------------------------------- /docgen/helpers/usage-tabs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import Handlebars from 'handlebars' 15 | import { PageEvent, SignatureReflection } from 'typedoc' 16 | import { createUsageMap, parseModel, renderBrowserDemo, renderUsageTabs } from '../utils/index.js' 17 | 18 | export function usageTabsHelper() { 19 | Handlebars.registerHelper('usageTabs', function (this: PageEvent) { 20 | const parsedModel = parseModel(this.model) 21 | const usageByRuntime = createUsageMap(parsedModel) 22 | 23 | return [ 24 | '## Usage', 25 | renderUsageTabs(usageByRuntime), 26 | usageByRuntime.has('browser') ? renderBrowserDemo(usageByRuntime.get('browser')!) : '', 27 | ].join('\n\n') 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /docgen/helpers/humanizeReflectionName.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import dashify from 'dashify' 16 | import Handlebars from 'handlebars' 17 | import { ReferenceReflection, ReflectionKind } from 'typedoc' 18 | import { escapeChars } from '../utils/index.js' 19 | 20 | export function humanizeReflectionName() { 21 | Handlebars.registerHelper('humanizeReflectionName', function (this: ReferenceReflection) { 22 | const url = this.kindOf(ReflectionKind.Reference) ? this.getTargetReflectionDeep().url : null 23 | 24 | const name = `${escapeChars(this.name)}` 25 | const content = url ? `[${name}](${Handlebars.helpers.relativeURL(url)})` : name 26 | 27 | return `${content} {.kind-${dashify(this.kindString || 'unknown')}}` 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Security 3 | id: security 4 | sidebar_title: Security 5 | --- 6 | 7 | # Security Policy 8 | 9 | ## Supported Versions 10 | 11 | | Version | Supported | 12 | | -------- | ------------------ | 13 | | >= 3.3.x | :white_check_mark: | 14 | | < 3.3.x | :x: | 15 | 16 | ## Reporting a Vulnerability 17 | 18 | Please report suspected vulnerabilities via [Github Issues](https://github.com/sister-software/keywork/issues). 19 | 20 | If possible, please include... 21 | 22 | - Version of Keywork 23 | - The runtime you're using (Cloudflare Workers, Deno, Node, Browser) 24 | - Reproducible steps (1... 2... 3...) that cause the issue 25 | - What you expected to see, versus what you actually saw 26 | - Images, animations, or a link to a video showing the issue occurring 27 | - A code snippet that demonstrates the issue or a link to a code repository the developers can easily pull down to recreate the issue locally 28 | - **Note:** Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient. 29 | - Errors from either your server, or from the browser's Dev Tools Console (open from the menu: Help > Toggle Developer Tools) 30 | 31 | If the you believe the vulnerability is time-sensitive or requires additional support, please reach out to `support [at] keywork.app` 32 | -------------------------------------------------------------------------------- /node/files.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import * as fs from 'node:fs/promises' 16 | import * as path from 'node:path' 17 | 18 | /** 19 | * @internal 20 | */ 21 | export type FileExtensionLike = `.${string}` 22 | /** 23 | * @internal 24 | */ 25 | export function changeExtension( 26 | filePath: string, 27 | /** 28 | * File extension with dot prefix. 29 | */ 30 | extension: FileExtensionLike 31 | ) { 32 | const parsedPath = path.parse(filePath) 33 | 34 | return parsedPath.dir + path.sep + parsedPath.name + extension 35 | } 36 | 37 | /** 38 | * @returns whether the file exists. 39 | */ 40 | export function checkFileExists(filePath: string): Promise { 41 | return fs 42 | .stat(filePath) 43 | .then(() => true) 44 | .catch(() => false) 45 | } 46 | -------------------------------------------------------------------------------- /docgen/theme/groups.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import { ReflectionKind } from 'typedoc' 15 | 16 | const PLURALS = { 17 | [ReflectionKind.Class]: 'Classes', 18 | [ReflectionKind.Property]: 'Properties', 19 | [ReflectionKind.Enum]: 'Enumerations', 20 | [ReflectionKind.EnumMember]: 'Enumeration members', 21 | [ReflectionKind.TypeAlias]: 'Type aliases', 22 | } 23 | 24 | export function getKindPlural(kind: ReflectionKind): string { 25 | if (kind in PLURALS) { 26 | return PLURALS[kind as keyof typeof PLURALS] 27 | } else { 28 | return getKindString(kind) + 's' 29 | } 30 | } 31 | 32 | function getKindString(kind: ReflectionKind): string { 33 | let str = ReflectionKind[kind] 34 | str = str.replace(/(.)([A-Z])/g, (_m, a, b) => a + ' ' + b.toLowerCase()) 35 | return str 36 | } 37 | -------------------------------------------------------------------------------- /examples/simple/public/pages/Index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { useEffect, useState } from 'react' 16 | 17 | export interface AppProps { 18 | renderTimestamp: string 19 | } 20 | 21 | export const IndexPage: React.FC = ({ renderTimestamp }) => { 22 | const [timestamp, setTimestamp] = useState(() => new Date(renderTimestamp)) 23 | 24 | useEffect(() => { 25 | const interval = setInterval(() => { 26 | setTimestamp(new Date()) 27 | }, 1000) 28 | 29 | return () => { 30 | clearInterval(interval) 31 | } 32 | }, []) 33 | 34 | return ( 35 |
36 |

Hello from Keywork!

37 |

{timestamp.toISOString()}

38 |

And this is a JSX response!

39 | Todo 1 40 |
41 | ) 42 | } 43 | -------------------------------------------------------------------------------- /site/src/components/DocIssueURL.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import IconExternal from '@theme/Icon/ExternalLink' 16 | import React from 'react' 17 | 18 | interface DocIssueURLProps { 19 | source_url?: string 20 | } 21 | 22 | export const DocIssueURL: React.FC = ({ source_url, children }) => { 23 | const url = new URL('https://github.com/sister-software/keywork/issues/new?labels=documentation&template=doc.md') 24 | url.searchParams.set('title', `Doc: ${source_url || 'Needs improvement'}`) 25 | 26 | return ( 27 | 33 | {children} 34 | 35 | 36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /site/src/css/scrollbar.css: -------------------------------------------------------------------------------- 1 | @media (pointer: fine) { 2 | .thin-scrollbar { 3 | --ifm-scrollbar-thumb-background-color: var(--nirrius-teal-light) !important; 4 | --ifm-scrollbar-thumb-outline-color: var(--ifm-color-emphasis-500); 5 | } 6 | 7 | .thin-scrollbar::-webkit-scrollbar-thumb:hover { 8 | --ifm-scrollbar-thumb-outline-color: var(--ifm-color-emphasis-600); 9 | } 10 | 11 | 12 | .thin-scrollbar::-webkit-scrollbar { 13 | width: 0.5rem; 14 | } 15 | 16 | .thin-scrollbar::-webkit-scrollbar-track { 17 | background-color: transparent; 18 | background-image: url('/img/dotted.png') !important; 19 | background-size: 2px; 20 | opacity: 0.25; 21 | background-repeat: repeat; 22 | border-radius: 0; 23 | } 24 | 25 | .thin-scrollbar::-webkit-scrollbar-thumb { 26 | background-image: url('/img/dotted.png') !important; 27 | background-color: var(--ifm-scrollbar-thumb-background-color) !important; 28 | background-size: 2px !important; 29 | background-repeat: repeat; 30 | outline: 2px solid var(--ifm-scrollbar-thumb-outline-color) !important; 31 | border-radius: 0 !important; 32 | } 33 | 34 | .thin-scrollbar::-webkit-scrollbar-corner { 35 | background-image: url('/img/dotted.png') !important; 36 | background-color: var(--nirrius-teal-light); 37 | background-size: 2px; 38 | background-repeat: repeat; 39 | border-radius: 0; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /site/src/theme/DocSidebar/Desktop/styles.module.css: -------------------------------------------------------------------------------- 1 | @media (min-width: 997px) { 2 | .sidebar { 3 | display: flex; 4 | flex-direction: column; 5 | max-height: 100vh; 6 | height: 100%; 7 | position: sticky; 8 | top: 0; 9 | padding-top: var(--ifm-navbar-height) !important; 10 | transition: opacity 500ms ease; 11 | transition-property: width min-width; 12 | border-right: 5px solid var(--nirrius-red-base); 13 | padding-left: 0.5rem; 14 | width: unset !important; 15 | min-width: var(--doc-sidebar-width); 16 | flex: 0 0 auto; 17 | 18 | } 19 | 20 | .sidebarWithHideableNavbar { 21 | padding-top: 0; 22 | } 23 | 24 | .sidebarHidden { 25 | opacity: 0; 26 | height: 0; 27 | overflow: hidden; 28 | visibility: hidden; 29 | } 30 | 31 | .sidebarLogo { 32 | padding-block: var(--ifm-navbar-padding-vertical); 33 | align-items: center; 34 | place-content: center; 35 | font-size: 2rem; 36 | color: inherit !important; 37 | text-decoration: none !important; 38 | margin: 0 0.75rem; 39 | gap: 1rem; 40 | display: grid !important; 41 | grid-template-columns: auto auto; 42 | } 43 | 44 | .sidebarLogo img { 45 | width: 1.5rem; 46 | } 47 | 48 | /* .navbar__logo { 49 | height: auto; 50 | display: flex; 51 | margin: 0; 52 | } 53 | */ 54 | 55 | 56 | } 57 | 58 | .sidebarLogo { 59 | display: none; 60 | } 61 | -------------------------------------------------------------------------------- /docgen/mdx/relativeLinks.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { hasProperty } from 'hast-util-has-property' 16 | import { visit } from 'unist-util-visit' 17 | 18 | export function relativeLinks(options) { 19 | if (!options || !options.domainRegex) { 20 | throw Error('Missing required "domainRegex" option') 21 | } 22 | 23 | function visitor(node) { 24 | if (hasProperty(node, 'href') && options.domainRegex.test(node.properties.href)) { 25 | node.properties.href = node.properties.href.replace(options.domainRegex, '/') 26 | } else if (options.domainRegex.test(node.url)) { 27 | node.url = node.url.replace(options.domainRegex, '/') 28 | } 29 | } 30 | 31 | function transform(tree) { 32 | visit(tree, ['link', 'linkReference', 'element'], visitor) 33 | } 34 | 35 | return transform 36 | } 37 | -------------------------------------------------------------------------------- /site/static/scripts/main.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | const logo = ` 16 | 88 a8P 88 17 | 88 ,88' 88 18 | 88 ,88" 88 19 | 88,d88' ,adPPYba, 8b d8 8b db d8 ,adPPba, 8b,dPPY 88 ,d8 20 | 8888"88, a8P_____88 '8b d8' '8b d88b d8' a8" "8a 88P' 88 ,a8" 21 | 88P Y8b 8PP""""""" '8b d8' '8b d8''8b d8' 8b d8 88 8888[ 22 | 88 "88, "8b, ,aa '8b,d8' '8bd8' '8bd8' "8a, ,a8" 88 88'"Yba, 23 | 88 Y8b '"Ybbd8"' Y88' YP YP '"YbbP"' 88 88 'Y8a 24 | .d8' 25 | d8' 26 | ` 27 | console.log(logo) 28 | -------------------------------------------------------------------------------- /errors/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Keywork includes error utilities that pair nicely with HTTP request handlers. 3 | * 4 | * ```ts 5 | * import { KeyworkResourceError, StatusCodes } from 'keywork' 6 | * 7 | * if (isLoggedIn(someUser)) { 8 | * throw new KeyworkResourceError('You must be logged in to do that', StatusCodes.UNAUTHORIZED) 9 | * } 10 | * 11 | * if (someUser.role !== 'admin') { 12 | * throw new KeyworkResourceError('Only an admin can access that', StatusCodes.FORBIDDEN) 13 | * } 14 | * ``` 15 | * 16 | * ## Related Entries 17 | * 18 | * - {@link Keywork#HTTP#Response.ErrorResponse `ErrorResponse`} 19 | * 20 | * @packageDocumentation 21 | * @module Keywork#Errors 22 | * 23 | * @file This file is part of the Keywork project. 24 | * @copyright Nirrius, LLC. All rights reserved. 25 | * @author Teffen Ellis, et al. 26 | * @license AGPL-3.0 27 | * 28 | * @remarks Keywork is free software for non-commercial purposes. 29 | * You can be released from the requirements of the license by purchasing a commercial license. 30 | * Buying such a license is mandatory as soon as you develop commercial activities 31 | * involving the Keywork software without disclosing the source code of your own applications. 32 | * 33 | * @see LICENSE.md in the project root for further licensing information. 34 | */ 35 | /* eslint-disable header/header */ 36 | 37 | export * from './KeyworkResourceError.js' 38 | export * from './status.js' 39 | -------------------------------------------------------------------------------- /docgen/helpers/reference-member.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | import { ReferenceReflection } from 'typedoc' 17 | 18 | export function referenceMemberHelper() { 19 | Handlebars.registerHelper('referenceMember', function (this: ReferenceReflection) { 20 | const referenced = this.tryGetTargetReflectionDeep() 21 | 22 | if (this.hasComment()) { 23 | return Handlebars.helpers.comments(this.comment) 24 | } 25 | 26 | if (!referenced) { 27 | return `Re-exports ${this.name}` 28 | } 29 | 30 | if (this.name === referenced.name) { 31 | return `Re-exports [${referenced.name}](${Handlebars.helpers.relativeURL(referenced.url)})` 32 | } 33 | 34 | return `Renames and re-exports [${referenced.name}](${Handlebars.helpers.relativeURL(referenced.url)})` 35 | }) 36 | } 37 | -------------------------------------------------------------------------------- /ssr/stream.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /// 16 | 17 | import { renderToReadableStream } from 'react-dom/server.browser' 18 | import { KeyworkResourceError } from '../errors/index.js' 19 | import { IReactStreamRenderer } from './ReactRendererOptions.js' 20 | 21 | export const renderReactStream: IReactStreamRenderer = async (children, options) => { 22 | const controller = new AbortController() 23 | 24 | let error: null | KeyworkResourceError = null 25 | 26 | const stream = await renderToReadableStream(children as any, { 27 | ...options, 28 | signal: controller.signal, 29 | onError(_error: any) { 30 | error = new KeyworkResourceError(_error) 31 | console.error(error) 32 | }, 33 | }) 34 | 35 | return { 36 | stream, 37 | error, 38 | controller, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /client/SSRRoute.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import { normalizeURLPattern, useURLPatternResult } from '../uri/index.js' 15 | import { useSSRPropsByPath } from './SSRPropsProvider.js' 16 | 17 | interface RouteDataFetcherProps { 18 | component: React.ElementType 19 | pathname: string 20 | } 21 | 22 | export const RouteWithSSR: React.FC = ({ pathname, component: Component }) => { 23 | const propsByPath = useSSRPropsByPath() 24 | const initialPatternResult = useURLPatternResult() 25 | const currentPattern = normalizeURLPattern(initialPatternResult.inputs[0]) 26 | const currentMatch = currentPattern.exec(pathname) 27 | 28 | if (!currentMatch) return null 29 | const pageProps = propsByPath.get(currentMatch.pathname.input) 30 | 31 | if (pageProps) { 32 | return 33 | } 34 | 35 | return null 36 | } 37 | -------------------------------------------------------------------------------- /docgen/helpers/reflection-title.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import dashify from 'dashify' 15 | import Handlebars from 'handlebars' 16 | import { PageEvent, SignatureReflection } from 'typedoc' 17 | import type { MarkdownTheme } from '../theme/index.js' 18 | import { escapeChars, parseModel } from '../utils/index.js' 19 | 20 | export function reflectionTitleHelper(_theme: MarkdownTheme) { 21 | Handlebars.registerHelper('reflectionTitle', function < 22 | T extends SignatureReflection, 23 | >(this: PageEvent, shouldEscape = true) { 24 | const parsedModel = parseModel(this.model) 25 | 26 | return [ 27 | `# ${shouldEscape ? escapeChars(parsedModel.title) : parsedModel.title} {.kind-${dashify( 28 | parsedModel.kindString 29 | )}}`, 30 | parsedModel.isModule ? '## Module Overview' : '## Overview', 31 | ].join('\n\n') 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /.github/workflows/keywork-site.yml: -------------------------------------------------------------------------------- 1 | name: Site Deployment 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | 18 | - name: Setup Deno 19 | uses: denoland/setup-deno@v1 20 | with: 21 | deno-version: v1.x 22 | 23 | - name: Use Node.js 24 | uses: actions/setup-node@v1 25 | with: 26 | node-version: 17.4 27 | - run: yarn install --immutable --immutable-cache --check-cache 28 | 29 | - name: Build Modules 30 | run: | 31 | yarn build 32 | env: 33 | NODE_ENV: production 34 | CI: true 35 | 36 | - name: Build site 37 | run: | 38 | yarn site:build 39 | env: 40 | NODE_ENV: production 41 | CI: true 42 | 43 | - name: Archive doc site artifacts 44 | uses: actions/upload-artifact@v3 45 | with: 46 | name: keywork-site 47 | path: site/build 48 | retention-days: 5 49 | 50 | - name: Deploy Site 51 | run: | 52 | yarn site:deploy --project-name keywork --branch main site/build 53 | env: 54 | NODE_ENV: production 55 | CI: true 56 | CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} 57 | CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} 58 | -------------------------------------------------------------------------------- /http/shouldCompress.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { MimeDatabase } from '../files/index.js' 16 | import { ContentType, parse } from './headers/index.js' 17 | import { isCompressible } from './isCompressable.js' 18 | 19 | /** 20 | * Predicate function to determine if a given content type should be compressed. 21 | */ 22 | export function shouldCompress( 23 | contentTypeLike: ContentType | string | null, 24 | /** 25 | * An optional database of MIME type information, 26 | * such as the [`mime-db`](https://www.npmjs.com/package/mime-db) package 27 | */ 28 | db?: MimeDatabase 29 | ): boolean { 30 | if (!contentTypeLike) return false 31 | try { 32 | const contentType = typeof contentTypeLike === 'string' ? parse(contentTypeLike) : contentTypeLike 33 | return isCompressible(contentType.type, db) 34 | } catch (_error) { 35 | return false 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /http/headers/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Keywork includes utilities for working with common types HTTP headers, 3 | * including... 4 | * 5 | * - {@link Keywork#HTTP#Headers#Caching Caching and managing ETags} 6 | * - {@link Keywork#HTTP#Headers#ContentEncoding Content Encoding} 7 | * - {@link Keywork#HTTP#ContentType Content Type} 8 | * - Content Security Policy 9 | * - {@link Keywork#HTTP#Headers#CSP#Directives Directives} 10 | * - {@link Keywork#HTTP#Headers#CSP#Policies Policies} 11 | * 12 | * @packageDocumentation 13 | * @module Keywork#HTTP#Headers 14 | * 15 | * @file This file is part of the Keywork project. 16 | * @copyright Nirrius, LLC. All rights reserved. 17 | * @author Teffen Ellis, et al. 18 | * @license AGPL-3.0 19 | * 20 | * @remarks Keywork is free software for non-commercial purposes. 21 | * You can be released from the requirements of the license by purchasing a commercial license. 22 | * Buying such a license is mandatory as soon as you develop commercial activities 23 | * involving the Keywork software without disclosing the source code of your own applications. 24 | * 25 | * @see LICENSE.md in the project root for further licensing information. 26 | */ 27 | /* eslint-disable header/header */ 28 | 29 | export * from './caching.js' 30 | export * from './common.js' 31 | export * from './content-encoding.js' 32 | export * from './content-type-parser.js' 33 | export * from './content-type-utils.js' 34 | export * from './csp-directives.js' 35 | export * from './csp-policies.js' 36 | -------------------------------------------------------------------------------- /cloudflare/CloudflarePagesAssetRouter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { ServiceBindingRouter } from '../middleware/index.js' 16 | 17 | /** 18 | * An asset environment binding available within Cloudflare Pages. 19 | * 20 | * This binding only exists in Cloudflare __Pages__. 21 | * 22 | * @ignore 23 | */ 24 | export const CloudflarePagesBindingAlias = 'ASSETS' 25 | 26 | /** 27 | * Handles incoming requests for static assets uploaded to Cloudflare Pages. 28 | * 29 | * This binding only exists in Cloudflare __Pages__. 30 | * 31 | * @see {WorkerSitesAssetRouter} If you're using Worker Sites 32 | * 33 | * @category Cloudflare Middleware 34 | */ 35 | export class CloudflarePagesAssetRouter extends ServiceBindingRouter { 36 | constructor() { 37 | super(CloudflarePagesBindingAlias, { 38 | displayName: 'Cloudflare Pages Assets', 39 | }) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /events/IsomorphicFetchEventInit.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { IURLPattern, URLPatternResult } from '../uri/index.js' 16 | import type { SSRDocument } from './SSRDocument.js' 17 | 18 | /** 19 | * @internal 20 | */ 21 | export interface IsomorphicFetchEventInit { 22 | /** 23 | * The incoming request received by the Keywork router. 24 | * 25 | * Both the request's `url` property and the parent `IsomorphicFetchEvent` will reflect 26 | * the current parsed route handler of `RequestRouter`. 27 | * @see {IsomorphicFetchEvent#originalURL} 28 | */ 29 | request?: Request 30 | 31 | originalURL: string 32 | 33 | env?: BoundAliases 34 | data?: Data 35 | 36 | match?: URLPatternResult | null 37 | 38 | urlPattern?: IURLPattern 39 | 40 | waitUntil?(promise: Promise): void 41 | passThroughOnException?(): void 42 | document?: SSRDocument 43 | } 44 | -------------------------------------------------------------------------------- /files/mime.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for mime-db 1.43 2 | // Project: https://github.com/jshttp/mime-db 3 | // Definitions by: AJP 4 | // Linus Unnebäck 5 | // Piotr Błażejewicz 6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 7 | /* eslint-disable header/header */ 8 | 9 | /** 10 | * @see {@link https://github.com/jshttp/mime-db#data-structure} 11 | */ 12 | export interface MimeEntry { 13 | /** 14 | * Where the mime type is defined. 15 | * If not set, it's probably a custom media type. 16 | */ 17 | readonly source?: MimeSource | undefined 18 | /** Known extensions associated with this mime type. */ 19 | readonly extensions?: ReadonlyArray | undefined 20 | /** Whether a file of this type can be gzipped. */ 21 | readonly compressible?: boolean | undefined 22 | /** The default charset associated with this type, if any. */ 23 | readonly charset?: string | undefined 24 | } 25 | 26 | /** 27 | * @see {@link https://github.com/jshttp/mime-db#data-structure} 28 | */ 29 | export interface MimeDatabase { 30 | readonly [type: string]: MimeEntry 31 | } 32 | 33 | /** 34 | * Sources: 35 | * http://www.iana.org/assignments/media-types/media-types.xhtml 36 | * http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types 37 | * http://hg.nginx.org/nginx/raw-file/default/conf/mime.types 38 | */ 39 | export type MimeSource = 'iana' | 'apache' | 'nginx' 40 | -------------------------------------------------------------------------------- /router/ParsedRoute.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { IURLPattern } from '../uri/index.js' 16 | 17 | import type { Fetcher } from './Fetcher.js' 18 | import type { RouteRequestHandler } from './RouteRequestHandler.js' 19 | 20 | /** 21 | * @ignore 22 | */ 23 | export interface ParsedRouteBase { 24 | urlPattern: IURLPattern 25 | displayName?: string 26 | } 27 | 28 | /** 29 | * @ignore 30 | */ 31 | export interface ParsedRouteFromRouteHandler extends ParsedRouteBase { 32 | kind: 'routeHandler' 33 | fetch: RouteRequestHandler 34 | } 35 | 36 | /** 37 | * @ignore 38 | */ 39 | export interface ParsedRouteFromFetcher extends ParsedRouteBase { 40 | kind: 'fetcher' 41 | fetcher: Fetcher 42 | } 43 | 44 | export type ParsedRoute = 45 | | ParsedRouteFromRouteHandler 46 | | ParsedRouteFromFetcher 47 | -------------------------------------------------------------------------------- /docgen/theme/resources/partials/member.signature.hbs: -------------------------------------------------------------------------------- 1 | {{{signatureTitle accessor}}} 2 | 3 | {{> comment}} 4 | 5 | {{#if typeParameters}} 6 | 7 | {{#if showSources}} 8 | 9 | #### Type parameters 10 | 11 | {{else}} 12 | 13 | ##### Type parameters 14 | 15 | {{/if}} 16 | 17 | {{#with typeParameters}} 18 | 19 | {{{typeParameterTable}}} 20 | 21 | {{/with}} 22 | 23 | {{/if}} 24 | 25 | {{#if parameters}} 26 | 27 | {{#if showSources}} 28 | 29 | #### Parameters 30 | 31 | {{else}} 32 | 33 | ##### Parameters 34 | 35 | {{/if}} 36 | 37 | {{#with parameters}} 38 | 39 | {{{parameterTable}}} 40 | 41 | {{/with}} 42 | 43 | {{/if}} 44 | 45 | {{#ifShowReturns}} 46 | 47 | {{#if type}} 48 | 49 | {{#if showSources}} 50 | 51 | #### Returns 52 | 53 | {{else}} 54 | 55 | ##### Returns 56 | 57 | {{/if}} 58 | 59 | {{#with type}} 60 | 61 | {{{type 'all'}}} 62 | 63 | {{/with}} 64 | 65 | {{#with comment}} 66 | 67 | {{{returns this}}} 68 | 69 | {{/with}} 70 | 71 | {{#with type}} 72 | 73 | {{#if declaration.signatures}} 74 | 75 | {{#each declaration.signatures}} 76 | 77 | {{> member.signature showSources=false }} 78 | 79 | {{/each}} 80 | 81 | {{/if}} 82 | 83 | {{#if declaration.children}} 84 | 85 | {{#with declaration.children}} 86 | 87 | {{{propertyTable}}} 88 | 89 | {{/with}} 90 | 91 | {{/if}} 92 | 93 | {{/with}} 94 | 95 | {{/if}} 96 | 97 | {{/ifShowReturns}} 98 | 99 | {{#if showSources}} 100 | 101 | {{> member.sources}} 102 | 103 | {{/if}} 104 | -------------------------------------------------------------------------------- /docs/examples/parsing-requests.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: parsing-requests 3 | title: Parsing Requests Example 4 | sidebar_position: 2 5 | sidebar_label: Parsing Requests 6 | --- 7 | 8 | ## Parsing incoming request parameters 9 | 10 | Let's say you're building a Todo list app, and incoming requests include 11 | query params, such as a Todo's `ID`. Keywork's `parsePathname` function makes this task easy: 12 | 13 | ```ts title=./workers/TodoListHandler.ts 14 | import { parsePathname, KeyworkRequestHandler, KeyworkResourceError } from 'keywork' 15 | 16 | interface GetTodoParams { 17 | todoID: string 18 | } 19 | 20 | export class TodoListHandler extends KeyworkRequestHandler { 21 | // We use a static property to allow for complex, multi-worker routing in later examples. 22 | static pattern = '/todos/:todoID' 23 | 24 | onRequestGet: PagesFunction = async ({ request }) => { 25 | const url = new URL(request.url) 26 | 27 | // Don't worry if the url doesn't match the expected pattern 28 | // `RequestHandler` will gracefully handle runtime errors. 29 | const params = parsePathname(TodoListWorker.pattern, url) 30 | 31 | const todo = await fetchTodos(params.todoID) 32 | 33 | if (!todo) throw new KeyworkResourceError('TODO does not exist') 34 | 35 | return new JSONResponse(todo) 36 | } 37 | } 38 | ``` 39 | 40 | ```ts title=workers/_worker.ts 41 | import { TodoListHandler } from './TodoListHandler' 42 | 43 | const incomingRequestHandler = new TodoListHandler() 44 | 45 | export default incomingRequestHandler 46 | ``` 47 | -------------------------------------------------------------------------------- /site/src/css/backgrounds.css: -------------------------------------------------------------------------------- 1 | .background-container { 2 | position: absolute; 3 | top: 0; 4 | right: 0; 5 | bottom: 0; 6 | width: 100vmax; 7 | background: var(--sidebar-background-color); 8 | pointer-events: none; 9 | z-index: -1; 10 | overflow: hidden; 11 | } 12 | 13 | .background-container::before { 14 | display: block; 15 | content: ''; 16 | position: absolute; 17 | transform-origin: 0 0; 18 | width: calc(100vw * 4); 19 | height: calc(100vh * 4); 20 | top: calc(100vh / 2); 21 | left: calc(-100vw / 2); 22 | transform: rotate(-45deg); 23 | opacity: 0.75; 24 | background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTVweCIgaGVpZ2h0PSIzMHB4IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48ZGVmcz48cGF0aCBkPSJNMyAxMC41di0zaDEuNXYzSDN6TTAgMTVWM2gxLjV2MS41SDN2M0gxLjVWMTVIMHptNiAwdi0xLjVINC41di0zSDZWM2gxLjV2MTJINnptMyAwVjZoMS41djlIOXpNOSA0LjVWM2gxLjV2MS41SDl6TTEyIDE1VjZoMS41djEuNUgxNVY5aC0xLjV2NkgxMnptMy03LjVWNmgxLjV2MS41SDE1em0zIDcuNVY2aDEuNXYxLjVIMjFWOWgtMS41djZIMTh6bTMtNy41VjZoMS41djEuNUgyMXptMyA3LjVWNmgxLjV2OUgyNHptMC0xMC41VjNoMS41djEuNUgyNHptMyA5VjZoMS41djcuNUgyN3ptMS41IDEuNXYtMS41aDNWNkgzM3Y5aC00LjV6bTYgMHYtMS41SDM5VjE1aC00LjV6bTQuNS0xLjV2LTNoMS41djNIMzl6bS0zLTNWOWgzdjEuNWgtM3pNMzQuNSA5VjcuNUgzNlY5aC0xLjV6TTM2IDcuNVY2aDN2MS41aC0zeiIgaWQ9ImEiLz48L2RlZnM+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCAtMykiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PHVzZSBmaWxsPSIjRkFEM0QzIiB4bGluazpocmVmPSIjYSIvPjx1c2UgZmlsbD0iI0ZGREZERiIgeGxpbms6aHJlZj0iI2EiLz48L2c+PC9zdmc+Cg=="); 25 | } 26 | -------------------------------------------------------------------------------- /docgen/helpers/hierarchy.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | import { DeclarationHierarchy } from 'typedoc' 17 | import { spaces } from '../utils/index.js' 18 | 19 | export function hierarchyHelper() { 20 | Handlebars.registerHelper('hierarchy', function (this: DeclarationHierarchy, level: number) { 21 | const md: string[] = [] 22 | const symbol = level > 0 ? getSymbol(level) : '-' 23 | this.types.forEach((hierarchyType) => { 24 | if (this.isTarget) { 25 | md.push(`${symbol} **\`${hierarchyType}\`**`) 26 | } else { 27 | md.push(`${symbol} ${Handlebars.helpers.type.call(hierarchyType)}`) 28 | } 29 | }) 30 | if (this.next) { 31 | md.push(Handlebars.helpers.hierarchy.call(this.next, level + 1)) 32 | } 33 | return md.join('\n\n') 34 | }) 35 | } 36 | 37 | function getSymbol(level: number) { 38 | return spaces(2) + [...Array(level)].map(() => '↳').join('') 39 | } 40 | -------------------------------------------------------------------------------- /testing/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | export function assertEquals(actual: any, expected: any, message = 'Assertion failed') { 15 | if (actual !== expected) { 16 | throw new Error(message) 17 | } 18 | } 19 | 20 | export function assert(actual: any, message = 'Assertion failed') { 21 | if (!actual) { 22 | throw new Error(message) 23 | } 24 | } 25 | 26 | export function assertExists(actual: any, message = 'Value does not exist') { 27 | if (actual === undefined || actual === null) { 28 | throw new Error(message) 29 | } 30 | } 31 | 32 | export function assertObjectMatch(actual: any, expected: any, message = 'Objects do not match') { 33 | if (JSON.stringify(actual) !== JSON.stringify(expected)) { 34 | throw new Error(message) 35 | } 36 | } 37 | 38 | export function assertStringIncludes(actual: string, expected: string, message = 'String does not include') { 39 | if (!actual.includes(expected)) { 40 | throw new Error(message) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /site/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@keywork/site", 3 | "version": "0.0.0", 4 | "private": true, 5 | "engines": { 6 | "node": ">= 17.4" 7 | }, 8 | "scripts": { 9 | "docusaurus": "docusaurus", 10 | "dev": "docusaurus start", 11 | "build": "docusaurus build", 12 | "swizzle": "docusaurus swizzle", 13 | "deploy": "docusaurus deploy", 14 | "clear": "docusaurus clear", 15 | "serve": "docusaurus serve", 16 | "write-translations": "docusaurus write-translations", 17 | "write-heading-ids": "docusaurus write-heading-ids", 18 | "typecheck": "tsc" 19 | }, 20 | "dependencies": { 21 | "@algolia/client-search": "^4.14.2", 22 | "@docusaurus/core": "2.3.1", 23 | "@docusaurus/plugin-pwa": "^2.3.1", 24 | "@docusaurus/preset-classic": "2.3.1", 25 | "@mdx-js/react": "^1.6.22", 26 | "algoliasearch": "^4.14.3", 27 | "clsx": "^1.2.1", 28 | "hast-util-has-property": "^2.0.1", 29 | "prism-react-renderer": "^1.3.5", 30 | "react": "^17.0.2", 31 | "react-dom": "^17.0.2", 32 | "react-loadable": "^5.5.0", 33 | "unist-util-visit": "^4.1.0" 34 | }, 35 | "devDependencies": { 36 | "@docusaurus/module-type-aliases": "2.0.1", 37 | "@tsconfig/docusaurus": "^1.0.6", 38 | "@types/react": "^17.0.2", 39 | "@types/react-dom": "^17.0.2", 40 | "typescript": "~4.7.4" 41 | }, 42 | "browserslist": [ 43 | "last 2 Chrome versions", 44 | "last 2 Safari versions", 45 | "last 2 ChromeAndroid versions", 46 | "last 2 iOS versions", 47 | "not dead", 48 | "not IE 11" 49 | ] 50 | } 51 | -------------------------------------------------------------------------------- /docs/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | Please include a summary of the change and which issue is fixed. 6 | Please also include relevant motivation and context. 7 | 8 | Please link to the issue this PR solves. 9 | If there is no existing issue, please first create one unless the fix is minor. 10 | Fixes # (issue) 11 | 12 | ## Type of change 13 | 14 | (Please delete options that are not relevant.) 15 | 16 | - [ ] Bug fix (non-breaking change which fixes an issue) 17 | - [ ] New feature (non-breaking change which adds functionality) 18 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 19 | - [ ] This change requires a documentation update 20 | 21 | ## How Has This Been Tested? 22 | 23 | Please describe the tests that you ran to verify your changes. 24 | Provide instructions so we can reproduce. 25 | Please also list any relevant details for your test configuration: 26 | 27 | - [ ] Test A 28 | - [ ] Test B 29 | 30 | ## Checklist: 31 | 32 | - [ ] I have performed a self-review of my own code 33 | - [ ] I have added tests that prove my fix is effective or that my feature works 34 | - [ ] New and existing unit tests pass locally with my changes 35 | - [ ] My code follows the style guidelines of this project 36 | - [ ] I have commented my code, particularly in hard-to-understand areas 37 | - [ ] I have made corresponding changes to the documentation 38 | - [ ] My changes generate no new warnings 39 | - [ ] I have checked my code and corrected any misspellings 40 | -------------------------------------------------------------------------------- /site/src/theme/TOCCollapsible/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { Collapsible, useCollapsible } from '@docusaurus/theme-common' 16 | import CollapseButton from '@theme/TOCCollapsible/CollapseButton' 17 | import TOCItems from '@theme/TOCItems' 18 | import clsx from 'clsx' 19 | import React from 'react' 20 | import styles from './styles.module.css' 21 | export default function TOCCollapsible({ toc, className, minHeadingLevel, maxHeadingLevel }) { 22 | const { collapsed, toggleCollapsed } = useCollapsible({ 23 | initialState: true, 24 | }) 25 | return ( 26 |
27 | 28 | 29 | 30 | 31 |
32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /scripts/import-map/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * @file This file is part of the Keywork project. 4 | * @copyright Nirrius, LLC. All rights reserved. 5 | * @author Teffen Ellis, et al. 6 | * @license AGPL-3.0 7 | * 8 | * @remarks Keywork is free software for non-commercial purposes. 9 | * You can be released from the requirements of the license by purchasing a commercial license. 10 | * Buying such a license is mandatory as soon as you develop commercial activities 11 | * involving the Keywork software without disclosing the source code of your own applications. 12 | * 13 | * @see LICENSE.md in the project root for further licensing information. 14 | */ 15 | 16 | import { writeFileSync } from 'node:fs' 17 | import * as path from 'node:path' 18 | import { KEYWORK_IMPORT_MAP_FILE_NAME } from '../../files/index.js' 19 | import { KeyworkLogger } from '../../logging/index.js' 20 | import { 21 | KEYWORK_PROJECT_DIST, 22 | readKeyworkPackageJSON, 23 | readKeyworkTSConfig, 24 | transformTSConfigToImportMap, 25 | } from '../../node/index.js' 26 | import { prettyJSON } from '../../utils/index.js' 27 | 28 | const logger = new KeyworkLogger('Import Map') 29 | const packageJSON = readKeyworkPackageJSON() 30 | const tsConfig = readKeyworkTSConfig() 31 | 32 | try { 33 | const importMap = transformTSConfigToImportMap(tsConfig, packageJSON) 34 | const serializedImportMap = prettyJSON(importMap) 35 | console.log(serializedImportMap) 36 | 37 | writeFileSync(path.join(KEYWORK_PROJECT_DIST, KEYWORK_IMPORT_MAP_FILE_NAME), serializedImportMap) 38 | } catch (error) { 39 | logger.error(error) 40 | } 41 | -------------------------------------------------------------------------------- /http/RequestContext.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { createContext, useContext, useMemo } from 'react' 16 | 17 | /** 18 | * Context for consuming the current request. 19 | */ 20 | export const RequestContext = createContext(undefined as any) 21 | 22 | RequestContext.displayName = 'RequestContext' 23 | 24 | /** 25 | * Hook for consuming the current request. 26 | */ 27 | export function useRequest() { 28 | return useContext(RequestContext) 29 | } 30 | 31 | /** 32 | * Hook for consuming the current request URL. 33 | */ 34 | export function useRequestURL(): URL { 35 | const request = useContext(RequestContext) 36 | 37 | return useMemo(() => new URL(request.url), [request]) 38 | } 39 | 40 | /** 41 | * Hook for consuming the current request URL search parameters. 42 | * @returns The current request URL search parameters. 43 | */ 44 | export function useSearchParams(): URLSearchParams { 45 | const url = useRequestURL() 46 | 47 | return useMemo(() => new URLSearchParams(url.search), [url]) 48 | } 49 | -------------------------------------------------------------------------------- /examples/simple/api.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { KeyworkResourceError, RequestRouter } from 'keywork' 16 | import type { TodoItemPageProps } from './public/pages/TodoItem.js' 17 | 18 | const mockTodos = new Map([ 19 | [ 20 | '1', 21 | { 22 | id: '1', 23 | title: 'Todo 1', 24 | completed: false, 25 | }, 26 | ], 27 | [ 28 | '2', 29 | { 30 | id: '2', 31 | title: 'Todo 2', 32 | completed: false, 33 | }, 34 | ], 35 | [ 36 | '3', 37 | { 38 | id: '3', 39 | title: 'Todo 3', 40 | completed: true, 41 | }, 42 | ], 43 | ]) 44 | 45 | export const apiRouter = new RequestRouter() 46 | 47 | apiRouter.get('/todos', () => { 48 | return mockTodos 49 | }) 50 | 51 | apiRouter.get<{ id: string }>('/todo/:id', async ({ params }) => { 52 | const todo = mockTodos.get(params.id) 53 | 54 | if (!todo) { 55 | return new KeyworkResourceError(`Todo ${params.id} not found`, 404) 56 | } 57 | 58 | return todo 59 | }) 60 | -------------------------------------------------------------------------------- /.github/workflows/keywork-ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: ['main'] 6 | pull_request: 7 | branches: ['main'] 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | 19 | - name: Setup Deno 20 | uses: denoland/setup-deno@v1 21 | with: 22 | deno-version: v1.x 23 | 24 | - name: Use Node.js 25 | uses: actions/setup-node@v1 26 | with: 27 | node-version: 17.4 28 | - run: yarn install --immutable --immutable-cache --check-cache 29 | 30 | - name: Build Modules 31 | run: | 32 | yarn build 33 | env: 34 | NODE_ENV: production 35 | 36 | - name: Run tests 37 | run: yarn workspace keywork run test 38 | 39 | - name: Generate lcov 40 | run: yarn workspace keywork run test:coverage > cov.lcov 41 | 42 | - name: Upload coverage 43 | uses: codecov/codecov-action@v2 44 | with: 45 | files: cov.lcov 46 | 47 | - name: Build site 48 | run: | 49 | yarn site:build 50 | env: 51 | NODE_ENV: production 52 | 53 | - name: Archive Keywork artifacts 54 | uses: actions/upload-artifact@v3 55 | with: 56 | name: keywork-dist 57 | path: dist 58 | retention-days: 5 59 | 60 | - name: Archive doc site artifacts 61 | uses: actions/upload-artifact@v3 62 | with: 63 | name: keywork-site 64 | path: site/build 65 | retention-days: 5 66 | -------------------------------------------------------------------------------- /docgen/mdx/headingClasses.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { visit } from 'unist-util-visit' 16 | 17 | export function headingClasses() { 18 | function visitor(node) { 19 | const lastChild = node.children[node.children.length - 1] 20 | if (lastChild && lastChild.type === 'text') { 21 | let string = lastChild.value.replace(/ +$/, '') 22 | const matched = string.match(/ {\.([^]+?)}$/) 23 | 24 | if (matched) { 25 | const className = matched[1] 26 | if (className.length) { 27 | if (!node.data) { 28 | node.data = {} 29 | } 30 | if (!node.data.hProperties) { 31 | node.data.hProperties = {} 32 | } 33 | node.data.className = node.data.hProperties.className = className 34 | 35 | string = string.substring(0, matched.index) 36 | lastChild.value = string 37 | } 38 | } 39 | } 40 | } 41 | 42 | function transform(tree) { 43 | visit(tree, ['heading'], visitor) 44 | } 45 | 46 | return transform 47 | } 48 | -------------------------------------------------------------------------------- /logging/LoggerContext.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { createContext, useContext, useMemo } from 'react' 16 | 17 | import { DEFAULT_LOG_LEVEL, DEFAULT_LOG_PREFIX, KeyworkLogLevel, KeyworkLogger } from './KeyworkLogger.js' 18 | 19 | export const KeyworkLoggerContext = createContext(undefined as any) 20 | KeyworkLoggerContext.displayName = 'KeyworkLoggerContext' 21 | 22 | /** 23 | * Hook to get the nearest Keywork `Logger` instance. 24 | */ 25 | export const useKeyworkLogger = () => useContext(KeyworkLoggerContext) 26 | 27 | export interface KeyworkLoggerProviderProps { 28 | logPrefix?: string 29 | logLevel?: KeyworkLogLevel 30 | children: React.ReactNode 31 | } 32 | 33 | export const KeyworkLoggerProvider: React.FC = ({ 34 | logPrefix = DEFAULT_LOG_PREFIX, 35 | logLevel = DEFAULT_LOG_LEVEL, 36 | children, 37 | }) => { 38 | const logger = useMemo(() => new KeyworkLogger(logPrefix, logLevel), [logPrefix, logLevel]) 39 | 40 | return {children} 41 | } 42 | -------------------------------------------------------------------------------- /site/src/theme/DocSidebar/Desktop/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { useThemeConfig } from '@docusaurus/theme-common' 16 | import CollapseButton from '@theme/DocSidebar/Desktop/CollapseButton' 17 | import Content from '@theme/DocSidebar/Desktop/Content' 18 | import Logo from '@theme/Logo' 19 | import clsx from 'clsx' 20 | import React from 'react' 21 | import styles from './styles.module.css' 22 | function DocSidebarDesktop({ path, sidebar, onCollapse, isHidden }) { 23 | const { 24 | navbar: { hideOnScroll }, 25 | docs: { 26 | sidebar: { hideable }, 27 | }, 28 | } = useThemeConfig() 29 | return ( 30 |
37 | {hideOnScroll && } 38 | 39 | {hideable && } 40 |
41 | ) 42 | } 43 | export default React.memo(DocSidebarDesktop) 44 | -------------------------------------------------------------------------------- /docgen/helpers/reflection-path.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import Handlebars from 'handlebars' 15 | import { ContainerReflection, PageEvent, ReflectionKind } from 'typedoc' 16 | 17 | export function reflectionPathHelper() { 18 | Handlebars.registerHelper( 19 | 'reflectionPath', 20 | 21 | function (this: PageEvent) { 22 | if (this.model) { 23 | if (this.model.kind && this.model.kind !== ReflectionKind.Module) { 24 | const title: string[] = [] 25 | if (this.model.parent && this.model.parent.parent) { 26 | if (this.model.parent.parent.parent) { 27 | title.push( 28 | `[${this.model.parent.parent.name}](${Handlebars.helpers.relativeURL(this.model?.parent?.parent.url)})` 29 | ) 30 | } 31 | title.push(`[${this.model.parent.name}](${Handlebars.helpers.relativeURL(this.model.parent.url)})`) 32 | } 33 | title.push(this.model.name) 34 | return title.length > 1 ? `${title.join('.')}` : null 35 | } 36 | } 37 | return null 38 | } 39 | ) 40 | } 41 | -------------------------------------------------------------------------------- /node/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import type { Headers, Request, Response } from 'undici' 15 | import { polyfillWithModule, readGlobalScope } from '../utils/index.js' 16 | 17 | type HTTPModule = { 18 | Request: Request 19 | Headers: Headers 20 | Response: Response 21 | } 22 | 23 | type StreamExports = Pick 24 | 25 | let hasAppliedPolyfills = false 26 | 27 | /** 28 | * Applies polyfills for Node.js APIs that are not available in Cloudflare Workers. 29 | * @internal 30 | */ 31 | export async function applyNodeKeyworkPolyfills() { 32 | if (hasAppliedPolyfills) return 33 | const globalScope = readGlobalScope() 34 | 35 | await polyfillWithModule('urlpattern-polyfill', ['URLPattern']) 36 | await polyfillWithModule('undici', ['Request', 'Headers', 'Response']) 37 | await polyfillWithModule('node:stream/web', ['TransformStream', 'ReadableStream', 'WritableStream']) 38 | const crypto = await import('node:crypto') 39 | globalScope.crypto = crypto.webcrypto 40 | 41 | hasAppliedPolyfills = true 42 | } 43 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "javascript.preferences.importModuleSpecifierEnding": "auto", 3 | "typescript.preferences.importModuleSpecifierEnding": "auto", 4 | "typescript.preferences.importModuleSpecifier": "non-relative", 5 | "search.exclude": { 6 | "yarn.lock": true, 7 | ".yarn": true, 8 | "dist": true, 9 | "cov": true, 10 | "api-extractor": true, 11 | "site/etc": true, 12 | "site/temp": true, 13 | "site/docusaurus.config.js": true 14 | }, 15 | "explorer.fileNesting.patterns": { 16 | "*.ts": "${capture}.js, ${capture}.test.ts, ${capture}.test.tsx", 17 | "tsconfig.json": "tsconfig.*.json", 18 | "package.json": "package-lock.json, yarn.lock", 19 | "index.ts": "${capture}.js, _category_.json", 20 | "*.js": "${capture}.d.ts.map, ${capture}.map, ${capture}.d.ts, ${capture}.js.map" 21 | }, 22 | "files.exclude": { 23 | "**/.git": true, 24 | ".yarn": true, 25 | "**/.DS_Store": true, 26 | "**/Thumbs.db": true, 27 | "**/cov": true, 28 | "yarn.lock": true, 29 | ".yarnrc": true, 30 | ".eslintignore": true, 31 | ".eslintrc.cjs": true, 32 | "LICENSE.md": true, 33 | ".editorconfig": true, 34 | ".node-version": true, 35 | ".prettierrc": true, 36 | ".prettierignore": true, 37 | "tsdoc.json": true, 38 | "typedoc.json": true, 39 | }, 40 | "[markdown]": { 41 | "editor.defaultFormatter": "esbenp.prettier-vscode" 42 | }, 43 | "[typescript]": { 44 | "editor.defaultFormatter": "esbenp.prettier-vscode" 45 | }, 46 | "[javascript]": { 47 | "editor.defaultFormatter": "esbenp.prettier-vscode" 48 | }, 49 | "[typescriptreact]": { 50 | "editor.defaultFormatter": "esbenp.prettier-vscode", 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /client/hydrate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | import { hydrateRoot } from 'react-dom/client' 15 | import { KeyworkResourceError } from '../errors/index.js' 16 | import { KeyworkLogLevel, KeyworkLogger } from '../logging/index.js' 17 | import { isKeyworkClientModule } from '../uri/index.js' 18 | import { pluckKeyworkHydrationElement, waitUntilDOMReady } from './dom.js' 19 | 20 | export interface KeyworkHydrationOptions { 21 | logLevel?: KeyworkLogLevel 22 | logPrefix?: string 23 | scriptPath?: string 24 | } 25 | 26 | export async function hydrate({ 27 | logPrefix = 'Hydration', 28 | logLevel = KeyworkLogLevel.Log, 29 | scriptPath = '/main.js', 30 | }: KeyworkHydrationOptions = {}) { 31 | const logger = new KeyworkLogger(logPrefix, logLevel) 32 | await waitUntilDOMReady() 33 | const hydrationElement = pluckKeyworkHydrationElement() 34 | 35 | logger.info('DOM is ready!', hydrationElement) 36 | 37 | const mainModule = await import(scriptPath) 38 | 39 | if (!isKeyworkClientModule(mainModule)) { 40 | throw new KeyworkResourceError('Keywork client module is invalid.', mainModule) 41 | } 42 | 43 | hydrateRoot(hydrationElement, mainModule.default as any) 44 | } 45 | -------------------------------------------------------------------------------- /cli/yargs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { ArgumentsCamelCase, Argv } from 'yargs' 16 | 17 | /** 18 | * Yargs options included in every wrangler command. 19 | */ 20 | export interface CommonYargsOptions { 21 | v: boolean | undefined 22 | config: string | undefined 23 | } 24 | 25 | export type CommonYargsArgv = Argv 26 | 27 | export type YargvToInterface = T extends Argv ? ArgumentsCamelCase

: never 28 | 29 | // See http://stackoverflow.com/questions/51465182/how-to-remove-index-signature-using-mapped-types 30 | type RemoveIndex = { 31 | [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] 32 | } 33 | /** 34 | * Given some Yargs Options function factory, extract the interface 35 | * that corresponds to the yargs arguments, remove index types, and only allow camelCase 36 | */ 37 | export type StrictYargsOptionsToInterface Argv> = T extends ( 38 | yargs: CommonYargsArgv 39 | ) => Argv 40 | ? RemoveIndex> 41 | : never 42 | 43 | export interface CommandProps { 44 | yargs: Argv 45 | argv: string[] 46 | cwd: string 47 | } 48 | -------------------------------------------------------------------------------- /site/src/css/menu.css: -------------------------------------------------------------------------------- 1 | .menu__list-item .menu__link:not(.menu__link--sublist-caret) { 2 | text-overflow: ellipsis; 3 | white-space: nowrap; 4 | max-width: 100%; 5 | overflow: hidden; 6 | display: flex !important; 7 | } 8 | 9 | .menu__link, 10 | .menu__caret { 11 | border-radius: 0; 12 | } 13 | 14 | .menu__list-item:not(:first-child) { 15 | margin-top: 1rem; 16 | } 17 | 18 | .theme-doc-sidebar-item-category-level-1 > .menu__list, 19 | .theme-doc-sidebar-item-category-level-2 > .menu__list { 20 | margin-top: 0.5rem; 21 | } 22 | 23 | .theme-doc-sidebar-item-category-level-1 > .menu__list-item-collapsible .menu__link:hover, 24 | .theme-doc-sidebar-item-category-level-1 > .menu__list-item-collapsible .menu__link--active, 25 | .menu__link:not([href]) { 26 | color: var(--ifm-color-content-inverse); 27 | 28 | --ifm-menu-color-background: var(--nirrius-red-dark); 29 | --ifm-menu-color-background-hover: var(--nirrius-red-base) !important; 30 | --ifm-menu-border-color: var(--nirrius-green-light); 31 | --nirrius-shadow: var(--nirrius-red-dark); 32 | 33 | transform: none; 34 | opacity: 0.5; 35 | z-index: 1; 36 | } 37 | 38 | .menu__list-item-collapsible .menu__link:hover, 39 | .menu__link:not([href]):hover { 40 | background-color: var(--ifm-menu-color-background-hover) !important; 41 | opacity: 1; 42 | } 43 | 44 | .menu__link:not([href]):hover { 45 | --ifm-menu-color-background-hover: var(--nirrius-red-dark) !important; 46 | 47 | opacity: 0.5 !important; 48 | } 49 | 50 | .menu__list-item-collapsible--active { 51 | background-color: unset; 52 | } 53 | 54 | .menu__list-item--collapsed .menu__list { 55 | display: none !important; 56 | overflow: unset !important; 57 | } 58 | 59 | .menu__list { 60 | overflow: unset !important; 61 | height: auto !important; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /utils/constants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * The default ID assigned to the React root element. 17 | * 18 | * ```tsx 19 | *

{children}
20 | * ``` 21 | * @ignore 22 | */ 23 | export const KEYWORK_APP_ROOT = 'app-root' 24 | 25 | /** 26 | * The default ID assigned to the React root style element. 27 | * 28 | * ```tsx 29 | *
{children}
30 | * ``` 31 | * @ignore 32 | */ 33 | export const KEYWORK_STYLE_ROOT = 'style-root' 34 | 35 | export type KeyworkSSRPropsKey = ':KeyworkSSRProps:' 36 | 37 | /** 38 | * The global key where the SSR props are assigned. 39 | * This includes a ':' character to prevent `document.querySelector` from matching this key. 40 | * @internal 41 | */ 42 | export const KEYWORK_SSR_PROPS_KEY: KeyworkSSRPropsKey = ':KeyworkSSRProps:' 43 | 44 | export type KeyworkSSRInitKey = ':KeyworkSSREventInit:' 45 | 46 | /** 47 | * The global key where the SSR event init is assigned. 48 | * This includes a ':' character to prevent `document.querySelector` from matching this key. 49 | * @internal 50 | */ 51 | export const KEYWORK_SSR_INIT_KEY: KeyworkSSRInitKey = ':KeyworkSSREventInit:' 52 | -------------------------------------------------------------------------------- /http/responses/HTMLResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { CacheControlDirectives, fileExtensionToContentTypeHeader } from '../../http/headers/index.js' 16 | import { CachableResponse } from './CachableResponse.js' 17 | 18 | /** 19 | * A response that returns a full HTML document. 20 | * 21 | * `HTMLResponse` automatically handles several types of HTML response bodies. 22 | * 23 | * @see {JSXResponse} 24 | * @category HTTP Response 25 | * @public 26 | */ 27 | export class HTMLResponse extends CachableResponse { 28 | constructor( 29 | /** 30 | * A string containing a full HTML document, or a readable stream. 31 | */ 32 | htmlLike: BodyInit, 33 | /** An optional request to check for etag headers. */ 34 | request?: Request, 35 | /** An optional etag for the given `json` parameter. */ 36 | etag?: string, 37 | /** Options to generate a cache control header. */ 38 | cacheControlOptions?: CacheControlDirectives, 39 | /** Headers to add to the response. */ 40 | headersInit?: HeadersInit 41 | ) { 42 | super(htmlLike, request, etag, cacheControlOptions, { 43 | ...fileExtensionToContentTypeHeader('html'), 44 | ...headersInit, 45 | }) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /site/src/css/fonts.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: Go; 3 | font-style: normal; 4 | font-weight: normal; 5 | src: url('/fonts/go/Go-Regular.ttf') format('truetype'); 6 | } 7 | 8 | @font-face { 9 | font-family: Go; 10 | font-style: italic; 11 | font-weight: normal; 12 | src: url('/fonts/go/Go-Italic.ttf') format('truetype'); 13 | } 14 | 15 | @font-face { 16 | font-family: Go; 17 | font-style: normal; 18 | font-weight: bold; 19 | src: url('/fonts/go/Go-Bold.ttf') format('truetype'); 20 | } 21 | 22 | @font-face { 23 | font-family: Go; 24 | font-style: italic; 25 | font-weight: bold; 26 | src: url('/fonts/go/Go-Bold-Italic.ttf') format('truetype'); 27 | } 28 | 29 | @font-face { 30 | font-family: Go; 31 | font-style: normal; 32 | font-weight: medium; 33 | src: url('/fonts/go/Go-Medium.ttf') format('truetype'); 34 | } 35 | 36 | @font-face { 37 | font-family: Go; 38 | font-style: italic; 39 | font-weight: medium; 40 | src: url('/fonts/go/Go-Medium-Italic.ttf') format('truetype'); 41 | } 42 | 43 | /* 44 | @font-face { 45 | font-family: 'Go Mono'; 46 | font-style: normal; 47 | font-weight: normal; 48 | src: local('Go Mono'), url('/fonts/go/Go-Mono.ttf') format('truetype'); 49 | } 50 | 51 | @font-face { 52 | font-family: 'Go Mono'; 53 | font-style: italic; 54 | font-weight: normal; 55 | src: local('Go Mono'), url('/fonts/go/Go-Mono-Italic.ttf') format('truetype'); 56 | } 57 | 58 | @font-face { 59 | font-family: 'Go Mono'; 60 | font-style: normal; 61 | font-weight: bold; 62 | src: local('Go Mono'), url('/fonts/go/Go-Mono-Bold.ttf') format('truetype'); 63 | } 64 | 65 | @font-face { 66 | font-family: 'Go Mono'; 67 | font-style: italic; 68 | font-weight: bold; 69 | src: local('Go Mono'), url('/fonts/go/Go-Mono-Bold-Italic.ttf') format('truetype'); 70 | } */ 71 | -------------------------------------------------------------------------------- /client/animation.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { readGlobalScope } from '../utils/index.js' 16 | 17 | /** @internal */ 18 | type FrameRequestCallbackFn = (timestamp: number) => unknown 19 | 20 | /** @internal */ 21 | type RequestAnimationFrameFn = (callback: FrameRequestCallbackFn) => number 22 | 23 | /** @internal */ 24 | interface AnimationFramer { 25 | requestAnimationFrame: RequestAnimationFrameFn 26 | } 27 | 28 | /** 29 | * Predicate function to determine if the given object can invoke `requestAnimationFrame` 30 | * @internal 31 | */ 32 | export function isAnimationFramer(windowOrGlobal: any = readGlobalScope()): windowOrGlobal is AnimationFramer { 33 | return typeof windowOrGlobal.requestAnimationFrame === 'function' 34 | } 35 | 36 | /** 37 | * Promise wrapper around `requestAnimationFrame` 38 | */ 39 | export function requestAnimationFramePromise(windowOrGlobal: any = readGlobalScope()): Promise { 40 | return new Promise((resolve) => { 41 | if (!isAnimationFramer(windowOrGlobal)) { 42 | setTimeout(() => resolve(-1), 1) 43 | return 44 | } 45 | 46 | const frameNumber = windowOrGlobal.requestAnimationFrame(() => { 47 | resolve(frameNumber) 48 | }) 49 | }) 50 | } 51 | -------------------------------------------------------------------------------- /docs/getting-started/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: install 3 | title: Install 4 | sidebar_position: 0 5 | sidebar_label: Quick Start 6 | --- 7 | 8 | import Tabs from '@theme/Tabs' 9 | import TabItem from '@theme/TabItem' 10 | 11 | The Keywork library is framework agnostic, modular, 12 | and compatible with Cloudflare Workers, Deno, and Node.js. 13 | 14 | ## Creating a new app from scratch 15 | 16 | If you're using Cloudflare, or would like to start from a template, 17 | checkout the [Keywork Starter Kit](https://github.com/sister-software/keywork-starter-kit). 18 | The kit includes support for React, TypeScript, and ESBuild. 19 | 20 | ## Adding Keywork to your existing codebase 21 | 22 | Keywork is often added to an existing web app when a developer wants to migrate 23 | their deployment to a V8 Isolate runtime, such as Cloudflare Workers or Deno. 24 | 25 | 26 | 27 | 28 | Let's start by adding Keywork to your project via [Yarn](https://yarnpkg.com/): 29 | 30 | ```shell title="Run in the root of your project." 31 | $ yarn add keywork 32 | ``` 33 | 34 | 35 | 36 | 37 | 38 | Let's start by adding Keywork to your project via NPM: 39 | 40 | ```shell title="Run in the root of your project." 41 | $ npm install keywork 42 | ``` 43 | 44 | 45 | 46 | 47 | 48 | ### If your app uses React... 49 | 50 | You'll need additional peer dependencies: 51 | 52 | 53 | 54 | 55 | 56 | ```shell title="Run in the root of your project." 57 | $ npm install --save react react-dom 58 | ``` 59 | 60 | 61 | 62 | 63 | 64 | ```shell title="Run in the root of your project." 65 | $ yarn add react react-dom 66 | ``` 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /http/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Keywork includes utilities for working with incoming HTTP requests, 3 | * and extends the native [`Request` class](https://developer.mozilla.org/en-US/docs/Web/API/Request) 4 | * for use with [Cloudflare Workers](https://developers.cloudflare.com/workers/runtime-apis/request/#requestinitcfproperties) 5 | * 6 | * See each of HTTP's submodules for additional details. 7 | * 8 | * @packageDocumentation 9 | * @module Keywork#HTTP 10 | * 11 | * @file This file is part of the Keywork project. 12 | * @copyright Nirrius, LLC. All rights reserved. 13 | * @author Teffen Ellis, et al. 14 | * @license AGPL-3.0 15 | * 16 | * @remarks Keywork is free software for non-commercial purposes. 17 | * You can be released from the requirements of the license by purchasing a commercial license. 18 | * Buying such a license is mandatory as soon as you develop commercial activities 19 | * involving the Keywork software without disclosing the source code of your own applications. 20 | * 21 | * @see LICENSE.md in the project root for further licensing information. 22 | */ 23 | /* eslint-disable header/header */ 24 | 25 | export * from './HTTPMethod.js' 26 | export * from './IncomingRequestCfProperties.js' 27 | export * from './RequestContext.js' 28 | export * from './RouterMethod.js' 29 | export * from './accepts.js' 30 | export * from './castToResponse.js' 31 | export * from './cloneAsMutableResponse.js' 32 | export * from './cors.js' 33 | export * from './headers/index.js' 34 | export * from './isCompressable.js' 35 | export * from './isInstanceOfRequest.js' 36 | export * from './isInstanceOfResponse.js' 37 | export * from './isRequestLike.js' 38 | export * from './methodVerbToRouterMethod.js' 39 | export * from './responses/index.js' 40 | export * from './routerMethodToHTTPMethod.js' 41 | export * from './shouldCompress.js' 42 | -------------------------------------------------------------------------------- /site/src/theme/DocPage/Layout/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | // @ts-expect-error internal 16 | import { useDocsSidebar } from '@docusaurus/theme-common/internal' 17 | import BackToTopButton from '@theme/BackToTopButton' 18 | import DocPageLayoutMain from '@theme/DocPage/Layout/Main' 19 | import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar' 20 | import Layout from '@theme/Layout' 21 | import React, { useState } from 'react' 22 | import styles from './styles.module.css' 23 | 24 | export default function DocPageLayout({ children }) { 25 | const sidebar = useDocsSidebar() 26 | const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false) 27 | return ( 28 | 29 | 30 |
31 | {sidebar && ( 32 | 37 | )} 38 | {children} 39 |
40 |
41 | ) 42 | } 43 | -------------------------------------------------------------------------------- /site/src/theme/Heading/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { useThemeConfig } from '@docusaurus/theme-common' 16 | import { translate } from '@docusaurus/Translate' 17 | import clsx from 'clsx' 18 | import React from 'react' 19 | import styles from './styles.module.css' 20 | 21 | export default function Heading({ as: As, id, ...props }) { 22 | const { 23 | navbar: { hideOnScroll }, 24 | } = useThemeConfig() 25 | // H1 headings do not need an id because they don't appear in the TOC. 26 | if (As === 'h1' || !id) { 27 | return 28 | } 29 | return ( 30 | 39 | {props.children} 40 | 49 | ​ 50 | 51 | 52 | ) 53 | } 54 | -------------------------------------------------------------------------------- /node/createServerHandler.test.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import * as http from 'node:http' 16 | import { KeyworkLogLevel, KeyworkLogger } from '../logging/index.js' 17 | import { RequestRouter } from '../router/index.js' 18 | import { createNodeServerHandler } from './createServerHandler.js' 19 | import { applyNodeKeyworkPolyfills } from './polyfills.js' 20 | 21 | await applyNodeKeyworkPolyfills() 22 | 23 | const logger = new KeyworkLogger('Test Server') 24 | 25 | // Create a router as you usually do... 26 | const router = new RequestRouter({ 27 | logLevel: KeyworkLogLevel.Debug, 28 | }) 29 | router.get('/', () => 'Hello from Node') 30 | 31 | // And then wrap the router with `createServerHandler` 32 | const server = http.createServer(createNodeServerHandler(router)) 33 | 34 | const host = process.env.KEYWORK_HOST || 'localhost' 35 | const port = process.env.KEYWORK_PORT || '8080' 36 | 37 | const serverURL = new URL(`http://${host}:${port}`) 38 | 39 | logger.info('Starting server...') 40 | 41 | server.listen(parseInt(serverURL.port, 10), serverURL.hostname, () => { 42 | logger.info(`Listening on ${serverURL}`) 43 | }) 44 | 45 | process.on('SIGINT', () => { 46 | router.dispose('Server is shutting down...') 47 | server.close() 48 | }) 49 | -------------------------------------------------------------------------------- /docs/THIRD_PARTY_NOTICES.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Acknowledgements 3 | sidebar_label: Third Party Notices 4 | id: third-party-notices 5 | --- 6 | 7 | Keywork is distributed under the [AGPL-3.0 license](https://www.gnu.org/licenses/agpl-3.0.html), 8 | and is made possible through the countless contributions of the open-source community. 9 | 10 | ## Third Party Notices 11 | 12 | Keywork includes or partly uses code from the following open source software 13 | subject to the following open source licenses. 14 | 15 | ### MDN Web Docs 16 | 17 | Keywork includes documentation and examples from [MDN](https://developer.mozilla.org//en-US/docs/MDN/About) 18 | by [Mozilla Contributors](https://developer.mozilla.org//en-US/docs/MDN/About/contributors.txt), 19 | and is licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). 20 | 21 | ### TypeDoc 22 | 23 | Keywork uses [TypeDoc](https://typedoc.org) and the [TypeDoc Markdown Plugin](https://github.com/tgreyuk/typedoc-plugin-markdown) to generate documentation. 24 | 25 | ### Miniflare 26 | 27 | Keywork uses [Miniflare](https://miniflare.dev/), a simulator for developing and testing Cloudflare Workers. 28 | It's written in TypeScript, and runs your code in a sandbox implementing Workers' runtime APIs. 29 | Miniflare is licensed under [MIT](https://github.com/cloudflare/miniflare/blob/master/LICENSE) 30 | 31 | ## A special thanks to... 32 | 33 | - MrBBot and the developers of [Miniflare](https://miniflare.dev/) 34 | - The folks at [Cloudflare](https://cloudflare.com) and the Workers team 💞 35 | - The visionaries at [Deno](https://deno.land) for all their inspiration 36 | - The brilliant engineers and maintainers of [code-server](https://github.com/coder/code-server) 37 | - And [all the wonderful people](https://github.com/sister-software/keywork/graphs/contributors) who've contributed to Keywork 38 | -------------------------------------------------------------------------------- /middleware/SessionMiddleware.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { Deno } from '@deno/shim-deno' 16 | import { parse as parseCookies } from 'cookie' 17 | import { CookieHeaders } from '../http/index.js' 18 | import { RequestRouter } from '../router/index.js' 19 | import { assert, assertEquals } from '../testing/index.js' 20 | import { SessionMiddleware } from './SessionMiddleware.js' 21 | 22 | Deno.test('Session Middleware', async () => { 23 | const sessionMiddleware = new SessionMiddleware() 24 | const app = new RequestRouter({ 25 | displayName: 'Session Tester', 26 | middleware: [sessionMiddleware], 27 | }) 28 | 29 | app.get('/', (event) => { 30 | const url = new URL(event.request.url) 31 | 32 | return `Hello from ${url.pathname}` 33 | }) 34 | 35 | const rootResponse = await app.fetch(new Request('http://localhost/')) 36 | assertEquals(await rootResponse.text(), `Hello from /`, 'Response has body') 37 | 38 | // @ts-ignore Type annotation 39 | const cookieDough = rootResponse.headers.get('Set-Cookie')! 40 | 41 | assert(cookieDough, 'Request has cookie') 42 | const cookies = parseCookies(cookieDough) 43 | 44 | assert(cookies[sessionMiddleware.cookieKey], 'Cookies have session ID') 45 | }) 46 | -------------------------------------------------------------------------------- /examples/simple/_worker.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { KeyworkResourceError, RequestRouter } from 'keywork' 16 | import { TodoItemPageProps } from './public/pages/TodoItem.js' 17 | 18 | const router = new RequestRouter({ 19 | document: { 20 | title: 'Keywork example app', 21 | themeColor: '#65b9e2', 22 | }, 23 | }) 24 | 25 | router.get('/', ({ document }) => { 26 | document.author = 'Teffen Ellis' 27 | 28 | return { 29 | renderTimestamp: new Date().toISOString(), 30 | } 31 | }) 32 | 33 | const mockTodos = new Map([ 34 | [ 35 | '1', 36 | { 37 | id: '1', 38 | title: 'Todo 1', 39 | completed: false, 40 | }, 41 | ], 42 | [ 43 | '2', 44 | { 45 | id: '2', 46 | title: 'Todo 2', 47 | completed: false, 48 | }, 49 | ], 50 | [ 51 | '3', 52 | { 53 | id: '3', 54 | title: 'Todo 3', 55 | completed: true, 56 | }, 57 | ], 58 | ]) 59 | 60 | router.get<{ id: string }>('/todo/:id', ({ params }) => { 61 | const todo = mockTodos.get(params.id) 62 | 63 | if (!todo) { 64 | return new KeyworkResourceError(`Todo ${params.id} not found`, 404) 65 | } 66 | 67 | return todo 68 | }) 69 | 70 | export default router 71 | -------------------------------------------------------------------------------- /docgen/utils/front-matter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | import { PageEvent } from 'typedoc' 17 | 18 | export interface FrontMatterVars { 19 | [key: string]: string | number | boolean 20 | } 21 | 22 | /** 23 | * Prepends YAML block to a string 24 | * @param contents - the string to prepend 25 | * @param vars - object of required front matter variables 26 | */ 27 | export const prependYAML = (contents: string, vars: FrontMatterVars) => { 28 | return contents.replace(/^/, toYAML(vars) + '\n\n').replace(/[\r\n]{3,}/g, '\n\n') 29 | } 30 | 31 | /** 32 | * Returns the page title as rendered in the document h1(# title) 33 | * @param page 34 | */ 35 | export const getPageTitle = (page: PageEvent) => { 36 | return Handlebars.helpers.reflectionTitle.call(page, false) 37 | } 38 | 39 | /** 40 | * Converts YAML object to a YAML string 41 | * @param vars 42 | */ 43 | const toYAML = (vars: FrontMatterVars) => { 44 | const yaml = `--- 45 | ${Object.entries(vars) 46 | .map(([key, value]) => `${key}: ${typeof value === 'string' ? `"${escapeString(value)}"` : value}`) 47 | .join('\n')} 48 | ---` 49 | return yaml 50 | } 51 | 52 | // prettier-ignore 53 | const escapeString=(str: string) => str.replace(/"/g, '\\"'); 54 | -------------------------------------------------------------------------------- /site/algolia.json: -------------------------------------------------------------------------------- 1 | { 2 | "settings": { 3 | "advancedSyntax": true, 4 | "allowTyposOnNumericTokens": false, 5 | "attributeCriteriaComputedByMinProximity": true, 6 | "attributeForDistinct": "url", 7 | "attributesForFaceting": [ 8 | "type", 9 | "lang", 10 | "language", 11 | "version", 12 | "docusaurus_tag" 13 | ], 14 | "attributesToHighlight": [ 15 | "hierarchy", 16 | "content" 17 | ], 18 | "attributesToRetrieve": [ 19 | "hierarchy", 20 | "content", 21 | "anchor", 22 | "url", 23 | "url_without_anchor", 24 | "type" 25 | ], 26 | "attributesToSnippet": [ 27 | "content:10" 28 | ], 29 | "camelCaseAttributes": [ 30 | "hierarchy", 31 | "content" 32 | ], 33 | "customRanking": [ 34 | "desc(weight.pageRank)", 35 | "desc(weight.level)", 36 | "asc(weight.position)" 37 | ], 38 | "distinct": true, 39 | "highlightPostTag": "", 40 | "highlightPreTag": "", 41 | "ignorePlurals": true, 42 | "minProximity": 1, 43 | "minWordSizefor1Typo": 3, 44 | "minWordSizefor2Typos": 7, 45 | "ranking": [ 46 | "words", 47 | "filters", 48 | "typo", 49 | "attribute", 50 | "proximity", 51 | "exact", 52 | "custom" 53 | ], 54 | "removeWordsIfNoResults": "allOptional", 55 | "searchableAttributes": [ 56 | "unordered(hierarchy.lvl0)", 57 | "unordered(hierarchy.lvl1)", 58 | "unordered(hierarchy.lvl2)", 59 | "unordered(hierarchy.lvl3)", 60 | "unordered(hierarchy.lvl4)", 61 | "unordered(hierarchy.lvl5)", 62 | "unordered(hierarchy.lvl6)", 63 | "content" 64 | ], 65 | "separatorsToIndex": "_" 66 | }, 67 | "rules": [], 68 | "synonyms": [] 69 | } 70 | -------------------------------------------------------------------------------- /http/IncomingRequestCfProperties.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** @ignore */ 16 | export interface IncomingRequestCfProperties { 17 | asn: number 18 | botManagement?: IncomingRequestCfPropertiesBotManagement 19 | city?: string 20 | clientTcpRtt: number 21 | clientTrustScore?: number 22 | colo: string 23 | continent?: string 24 | country: string 25 | httpProtocol: string 26 | latitude?: string 27 | longitude?: string 28 | metroCode?: string 29 | postalCode?: string 30 | region?: string 31 | regionCode?: string 32 | requestPriority: string 33 | timezone?: string 34 | tlsVersion: string 35 | tlsCipher: string 36 | tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth 37 | } 38 | 39 | /** @ignore */ 40 | export interface IncomingRequestCfPropertiesBotManagement { 41 | score: number 42 | staticResource: boolean 43 | verifiedBot: boolean 44 | } 45 | 46 | /** @ignore */ 47 | export interface IncomingRequestCfPropertiesTLSClientAuth { 48 | certIssuerDNLegacy: string 49 | certIssuerDN: string 50 | certPresented: '0' | '1' 51 | certSubjectDNLegacy: string 52 | certSubjectDN: string 53 | certNotBefore: string 54 | certNotAfter: string 55 | certSerial: string 56 | certFingerprintSHA1: string 57 | certVerified: string 58 | } 59 | -------------------------------------------------------------------------------- /docgen/helpers/comments.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import Handlebars from 'handlebars' 16 | import { Comment } from 'typedoc' 17 | import { camelToTitleCase } from '../utils/index.js' 18 | 19 | export function commentsHelper() { 20 | Handlebars.registerHelper('comments', function (comment: Comment, includeHTMLWrappers = true) { 21 | const md: string[] = [] 22 | const blockTags = comment.blockTags?.filter((tag) => tag.tag !== '@returns') || [] 23 | 24 | if (comment.summary && includeHTMLWrappers) { 25 | md.push( 26 | // 27 | `
`, 28 | Handlebars.helpers.comment(comment.summary), 29 | '
' 30 | ) 31 | } 32 | 33 | for (const tag of blockTags) { 34 | const tagID = tag.tag.slice(1) 35 | const tagName = camelToTitleCase(tagID) 36 | 37 | if (includeHTMLWrappers) { 38 | md.push( 39 | `#### ${tagName}`, 40 | `
`, 41 | Handlebars.helpers.comment(tag.content), 42 | '
' 43 | ) 44 | } else { 45 | md.push(`**\`${tagName}\`**\n\n${Handlebars.helpers.comment(tag.content)}`) 46 | } 47 | } 48 | 49 | return md.join('\n\n') 50 | }) 51 | } 52 | -------------------------------------------------------------------------------- /docgen/helpers/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | export * from './attemptExternalResolution.js' 16 | export * from './breadcrumbs.js' 17 | export * from './comment.js' 18 | export * from './comments.js' 19 | export * from './declaration-title.js' 20 | export * from './escape.js' 21 | export * from './frontmatter.js' 22 | export * from './hierarchy.js' 23 | export * from './humanizeReflectionName.js' 24 | export * from './if-is-reference.js' 25 | export * from './if-named-anchors.js' 26 | export * from './if-show-breadcrumbs.js' 27 | export * from './if-show-named-anchors.js' 28 | export * from './if-show-page-title.js' 29 | export * from './if-show-returns.js' 30 | export * from './if-show-type-hierarchy.js' 31 | export * from './index-signature-title.js' 32 | export * from './index.js' 33 | export * from './parameter-table.js' 34 | export * from './property-table.js' 35 | export * from './reference-member.js' 36 | export * from './reflection-path.js' 37 | export * from './reflection-title.js' 38 | export * from './relative-url.js' 39 | export * from './returns.js' 40 | export * from './signature-title.js' 41 | export * from './toc.js' 42 | export * from './type-and-parent.js' 43 | export * from './type-parameter-table.js' 44 | export * from './type.js' 45 | export * from './usage-tabs.js' 46 | -------------------------------------------------------------------------------- /utils/map.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | /** 16 | * @see {@linkcode ImmutableMap} 17 | * 18 | * @internal 19 | */ 20 | export type ImmutableMapLike = Omit, 'set' | 'clear' | 'delete'> 21 | 22 | interface ImmutableMapConstructor { 23 | new (): ImmutableMapLike 24 | new (entries?: readonly (readonly [K, V])[] | null): ImmutableMapLike 25 | readonly prototype: ImmutableMapLike 26 | } 27 | 28 | const NativeMap = Map as ImmutableMapConstructor 29 | 30 | /** 31 | * A variant of the native Map class, constructed from an array of key-value pairs. 32 | * 33 | * This is useful when you want to create a map from a list of key-value pairs but 34 | * want to avoid type-checking when getting values from the map. 35 | */ 36 | export class ImmutableMap extends NativeMap { 37 | public override get = (key: K): V => { 38 | if (!super.has(key)) { 39 | throw new Error(`Key ${key} not found in readonly map.`) 40 | } 41 | 42 | return super.get(key)! 43 | } 44 | 45 | protected clear(): void { 46 | throw new Error('Attempted to invoke `clear` on readonly Map.') 47 | } 48 | 49 | protected delete(_key: K): boolean { 50 | throw new Error('Attempted to invoke `delete` on readonly Map.') 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /node/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The {@link Keywork#Router.RequestRouter `RequestRouter`} 3 | * can be made compatible with Node.js 4 | * via the {@link Keywork#Router#Node.createServerHandler `createServerHandler`} wrapper function: 5 | * 6 | * ```ts showLineNumbers 7 | * import * as http from 'node:http' 8 | * import { RequestRouter } from './router/index.js' 9 | * import { createServerHandler } from './router/node/index.js' 10 | * 11 | * // Create a router as you usually do... 12 | * // highlight-next-line 13 | * const router = new RequestRouter() 14 | * router.get('/', () => 'Hello from Node') 15 | * 16 | * // And then wrap the router with `createServerHandler` 17 | * // highlight-next-line 18 | * http.createServer(createServerHandler(router)) 19 | * ``` 20 | * 21 | * :::caution 22 | * Node support is currently experimental and may change in the near future. 23 | * ::: 24 | * 25 | * @packageDocumentation 26 | * @module Keywork#Router#Node 27 | * @tag Node 28 | * @tag Routing 29 | * @file This file is part of the Keywork project. 30 | * @copyright Nirrius, LLC. All rights reserved. 31 | * @author Teffen Ellis, et al. 32 | * @license AGPL-3.0 33 | * 34 | * @remarks Keywork is free software for non-commercial purposes. 35 | * You can be released from the requirements of the license by purchasing a commercial license. 36 | * Buying such a license is mandatory as soon as you develop commercial activities 37 | * involving the Keywork software without disclosing the source code of your own applications. 38 | * 39 | * @see LICENSE.md in the project root for further licensing information. 40 | */ 41 | /* eslint-disable header/header */ 42 | 43 | export * from './createServerHandler.js' 44 | export * from './files.js' 45 | export * from './import-map.js' 46 | export * from './paths.js' 47 | export * from './polyfills.js' 48 | export * from './respondWithRouter.js' 49 | export * from './static.js' 50 | -------------------------------------------------------------------------------- /docgen/theme/navigation-item.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { Reflection } from 'typedoc' 16 | 17 | export class NavigationItem { 18 | title: string 19 | url: string 20 | dedicatedUrls?: string[] 21 | parent?: NavigationItem 22 | children?: NavigationItem[] 23 | isLabel?: boolean 24 | isVisible?: boolean 25 | isCurrent?: boolean 26 | isModules?: boolean 27 | isInPath?: boolean 28 | reflection?: Reflection 29 | 30 | constructor(title?: string, url?: string, parent?: NavigationItem, reflection?: Reflection) { 31 | this.title = title || '' 32 | this.url = url || '' 33 | this.parent = parent 34 | this.reflection = reflection 35 | 36 | if (!url) { 37 | this.isLabel = true 38 | } 39 | 40 | if (this.parent) { 41 | if (!this.parent.children) { 42 | this.parent.children = [] 43 | } 44 | this.parent.children.push(this) 45 | } 46 | } 47 | 48 | static create(reflection: Reflection, parent?: NavigationItem, useShortNames?: boolean) { 49 | let name: string 50 | if (useShortNames || (parent && parent.parent)) { 51 | name = reflection.name 52 | } else { 53 | name = reflection.getFullName() 54 | } 55 | 56 | name = name.trim() 57 | 58 | return new NavigationItem(name, reflection.url, parent, reflection) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /router/createRouteRedirect.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import { KeyworkLogger } from '../logging/index.js' 16 | import type { RouteRequestHandler } from './RouteRequestHandler.js' 17 | 18 | /** @ignore */ 19 | export type ResponseRedirectStatus = 301 | 302 | 303 | 307 | 308 20 | /** 21 | * A route request handler for redirecting requests. 22 | * 23 | * @returns The incoming request handler. 24 | * 25 | * ### Creating a Worker that just redirects incoming requests. 26 | * 27 | * ```ts 28 | * const redirectToExample = new RedirectHandler('https://example.com') 29 | * 30 | * export default redirectToExample 31 | * ``` 32 | * 33 | * @category Request Handler 34 | * @public 35 | */ 36 | export function createRouteRedirect( 37 | /** URL A url-like string or URL object */ 38 | destinationURL: string | URL, 39 | /** 40 | * An optional status code. 41 | * @defaultValue `302` MOVED_TEMPORARILY 42 | */ 43 | statusCode: ResponseRedirectStatus = 302, 44 | logger?: KeyworkLogger 45 | ): RouteRequestHandler { 46 | const routeRequestHandler: RouteRequestHandler = ({ request }) => { 47 | logger?.info(`Redirecting from ${request.url} to ${destinationURL.toString()}`) 48 | 49 | return Response.redirect(destinationURL.toString(), statusCode) 50 | } 51 | 52 | return routeRequestHandler 53 | } 54 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "jsx": "react-jsx", 7 | "target": "ESNext", 8 | "module": "NodeNext", 9 | "resolveJsonModule": true, 10 | "moduleResolution": "NodeNext", 11 | "skipLibCheck": true, 12 | "sourceMap": true, 13 | "allowJs": false, 14 | "declarationMap": true, 15 | "allowSyntheticDefaultImports": true, 16 | "declaration": true, 17 | "strict": true, 18 | "isolatedModules": true, 19 | "paths": { 20 | "keywork": ["./index.ts"], 21 | "keywork/cli": ["./cli/index.ts"], 22 | "keywork/client": ["./client/index.ts"], 23 | "keywork/logging": ["./logging/index.ts"], 24 | "keywork/node": ["./node/index.ts"], 25 | "keywork/errors": ["./errors/index.ts"], 26 | "keywork/docgen": ["./docgen/index.ts"], 27 | "keywork/docgen/utils": ["./docgen/utils/index.ts"], 28 | "keywork/docgen/helpers": ["docgen/helpers/index.ts"], 29 | "keywork/docgen/theme": ["./docgen/theme/index.ts"], 30 | "keywork/events": ["./events/index.ts"], 31 | "keywork/files": ["./files/index.ts"], 32 | "keywork/files/extensions": ["./files/extensions/index.ts"], 33 | "keywork/http": ["./http/index.ts"], 34 | "keywork/http/headers": ["./http/headers/index.ts"], 35 | "keywork/http/responses": ["./http/responses/index.ts"], 36 | "keywork/lifecycle": ["./lifecycle/index.ts"], 37 | "keywork/middleware": ["./middleware/index.ts"], 38 | "keywork/router": ["./router/index.ts"], 39 | "keywork/ssr": ["./ssr/index.ts"], 40 | "keywork/cloudflare": ["./cloudflare/index.ts"], 41 | "keywork/testing": ["./testing/index.ts"], 42 | "keywork/utils": ["./utils/index.ts"], 43 | "keywork/uri": ["./uri/index.ts"] 44 | }, 45 | }, 46 | "exclude": [ 47 | "node_modules", 48 | "dist", 49 | "site" 50 | ] 51 | } 52 | 53 | -------------------------------------------------------------------------------- /router/RouteRequestHandler.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file This file is part of the Keywork project. 3 | * @copyright Nirrius, LLC. All rights reserved. 4 | * @author Teffen Ellis, et al. 5 | * @license AGPL-3.0 6 | * 7 | * @remarks Keywork is free software for non-commercial purposes. 8 | * You can be released from the requirements of the license by purchasing a commercial license. 9 | * Buying such a license is mandatory as soon as you develop commercial activities 10 | * involving the Keywork software without disclosing the source code of your own applications. 11 | * 12 | * @see LICENSE.md in the project root for further licensing information. 13 | */ 14 | 15 | import type { IsomorphicFetchEvent } from '../events/index.js' 16 | import type { ResponseLike } from '../http/index.js' 17 | import type { MiddlewareFetch, MiddlewareReturnTypes } from './MiddlewareFetch.js' 18 | 19 | /** 20 | * A function or method that handles incoming requests and replies with a `Response`. 21 | * 22 | * Generally, this is interface is assigned to a RequestRouter method, such as `onRequestGet` 23 | * The `IsomorphicFetchEvent` argument is provided by the router's `fetch` method. 24 | * 25 | * @typeParam BoundAliases The bound aliases, usually defined in your wrangler.toml file. 26 | * @typeParam ExpectedParams Optional string union of route path parameters. Only supported in Cloudflare Pages. 27 | * 28 | * @typeParam Data Optional extra data to be passed to a route handler, usually from {@link Keywork#Middleware middleware}. 29 | * 30 | * @category Request Handler 31 | */ 32 | export interface RouteRequestHandler< 33 | BoundAliases = {}, 34 | ExpectedParams = {}, 35 | Data = Record, 36 | ExpectedReturn extends ResponseLike = ResponseLike, 37 | > { 38 | ( 39 | event: IsomorphicFetchEvent, 40 | next: MiddlewareFetch 41 | ): Promise | ExpectedReturn 42 | } 43 | --------------------------------------------------------------------------------