@treeseed/core 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -0
- package/dist/agents/index.js +5 -0
- package/dist/agents/registry-helper.js +14 -0
- package/dist/agents/registry.js +88 -0
- package/dist/components/DevWatchReload.astro +45 -0
- package/dist/components/SiteTitle.astro +51 -0
- package/dist/components/content/ContentStatusLegend.astro +18 -0
- package/dist/components/content/StatusBadge.astro +11 -0
- package/dist/components/docs/BookFontControls.astro +180 -0
- package/dist/components/docs/DesktopSidebarToggle.astro +88 -0
- package/dist/components/docs/DownloadBook.astro +34 -0
- package/dist/components/docs/Footer.astro +196 -0
- package/dist/components/docs/Header.astro +150 -0
- package/dist/components/docs/PageFrame.astro +260 -0
- package/dist/components/docs/PageSidebar.astro +63 -0
- package/dist/components/docs/PageTitle.astro +39 -0
- package/dist/components/docs/Sidebar.astro +41 -0
- package/dist/components/docs/ThemeSelect.astro +3 -0
- package/dist/components/forms/ContactForm.astro +234 -0
- package/dist/components/forms/FooterSubscribeForm.astro +189 -0
- package/dist/components/site/BookList.astro +27 -0
- package/dist/components/site/CTASection.astro +24 -0
- package/dist/components/site/ChronicleList.astro +33 -0
- package/dist/components/site/Hero.astro +18 -0
- package/dist/components/site/NotesList.astro +18 -0
- package/dist/components/site/PathCard.astro +16 -0
- package/dist/components/site/ProfileList.astro +30 -0
- package/dist/components/site/SectionIntro.astro +9 -0
- package/dist/components/site/StageBanner.astro +8 -0
- package/dist/components/site/TrustCallout.astro +9 -0
- package/dist/components/starlight.js +6 -0
- package/dist/config.js +8 -0
- package/dist/content-config.js +9 -0
- package/dist/content.js +230 -0
- package/dist/contracts.d.ts +130 -0
- package/dist/contracts.js +0 -0
- package/dist/deploy/config.d.ts +4 -0
- package/dist/deploy/config.js +154 -0
- package/dist/deploy/runtime.js +77 -0
- package/dist/env.yaml +322 -0
- package/dist/environment.d.ts +130 -0
- package/dist/environment.js +324 -0
- package/dist/index.js +81 -0
- package/dist/layouts/AuthoredEntryLayout.astro +87 -0
- package/dist/layouts/BookLayout.astro +35 -0
- package/dist/layouts/BridgeLayout.astro +11 -0
- package/dist/layouts/ContentLayout.astro +24 -0
- package/dist/layouts/MainLayout.astro +203 -0
- package/dist/layouts/NoteLayout.astro +26 -0
- package/dist/layouts/ProfileLayout.astro +81 -0
- package/dist/middleware/starlightRouteData.js +45 -0
- package/dist/pages/404.astro +29 -0
- package/dist/pages/[slug].astro +30 -0
- package/dist/pages/agents/[slug].astro +29 -0
- package/dist/pages/agents/index.astro +27 -0
- package/dist/pages/api/form/submit.js +14 -0
- package/dist/pages/books/[slug].astro +19 -0
- package/dist/pages/books/index.astro +28 -0
- package/dist/pages/contact.astro +27 -0
- package/dist/pages/feed.xml.js +34 -0
- package/dist/pages/index.astro +290 -0
- package/dist/pages/notes/[slug].astro +19 -0
- package/dist/pages/notes/index.astro +21 -0
- package/dist/pages/objectives/[slug].astro +31 -0
- package/dist/pages/objectives/index.astro +30 -0
- package/dist/pages/people/[slug].astro +29 -0
- package/dist/pages/people/index.astro +28 -0
- package/dist/pages/questions/[slug].astro +31 -0
- package/dist/pages/questions/index.astro +30 -0
- package/dist/plugin-default.js +4 -0
- package/dist/plugins/builtin/default-plugin.d.ts +21 -0
- package/dist/plugins/builtin/default-plugin.js +32 -0
- package/dist/plugins/constants.d.ts +21 -0
- package/dist/plugins/constants.js +28 -0
- package/dist/plugins/plugin.d.ts +42 -0
- package/dist/plugins/plugin.js +6 -0
- package/dist/plugins/runtime.d.ts +31 -0
- package/dist/plugins/runtime.js +120 -0
- package/dist/scripts/aggregate-book.js +112 -0
- package/dist/scripts/assert-release-tag-version.js +21 -0
- package/dist/scripts/build-dist.js +384 -0
- package/dist/scripts/build-tenant-worker.js +36 -0
- package/dist/scripts/package-tools.js +88 -0
- package/dist/scripts/patch-starlight-content-path.js +172 -0
- package/dist/scripts/paths.js +11 -0
- package/dist/scripts/publish-package.js +20 -0
- package/dist/scripts/release-verify.js +52 -0
- package/dist/scripts/run-fixture-astro-command.js +21 -0
- package/dist/scripts/tenant-astro-command.js +3 -0
- package/dist/scripts/tenant-build.js +16 -0
- package/dist/scripts/tenant-check.js +7 -0
- package/dist/scripts/test-smoke.js +105 -0
- package/dist/server.js +53 -0
- package/dist/site-resources.d.ts +29 -0
- package/dist/site-resources.js +127 -0
- package/dist/site.js +313 -0
- package/dist/styles/global.css +683 -0
- package/dist/styles/prose.css +89 -0
- package/dist/styles/tokens.css +24 -0
- package/dist/tenant/bridge.js +5 -0
- package/dist/tenant/config.d.ts +9 -0
- package/dist/tenant/config.js +124 -0
- package/dist/tenant/runtime-config.js +20 -0
- package/dist/tsconfigs/strict.json +3 -0
- package/dist/types/agents.d.ts +1 -0
- package/dist/types/agents.js +1 -0
- package/dist/types/astro-build.d.js +0 -0
- package/dist/types/cloudflare-sockets.d.js +0 -0
- package/dist/types/cloudflare.d.ts +1 -0
- package/dist/types/cloudflare.js +1 -0
- package/dist/types/forms.js +4 -0
- package/dist/utils/agents/adapters/execution.js +90 -0
- package/dist/utils/agents/adapters/mutations.js +30 -0
- package/dist/utils/agents/adapters/notification.js +16 -0
- package/dist/utils/agents/adapters/repository.js +61 -0
- package/dist/utils/agents/adapters/research.js +25 -0
- package/dist/utils/agents/adapters/verification.js +62 -0
- package/dist/utils/agents/cli-tools.js +5 -0
- package/dist/utils/agents/contracts/messages.d.ts +88 -0
- package/dist/utils/agents/contracts/messages.js +138 -0
- package/dist/utils/agents/contracts/run.d.ts +20 -0
- package/dist/utils/agents/contracts/run.js +0 -0
- package/dist/utils/agents/runtime-types.d.ts +117 -0
- package/dist/utils/agents/runtime-types.js +4 -0
- package/dist/utils/books-data.js +82 -0
- package/dist/utils/content-status.js +38 -0
- package/dist/utils/forms/config.js +87 -0
- package/dist/utils/forms/constants.js +27 -0
- package/dist/utils/forms/contact-submissions-local.js +19 -0
- package/dist/utils/forms/contact-submissions.js +72 -0
- package/dist/utils/forms/crypto.js +64 -0
- package/dist/utils/forms/guard.js +76 -0
- package/dist/utils/forms/http.js +51 -0
- package/dist/utils/forms/provider-core.js +88 -0
- package/dist/utils/forms/routing-core.js +7 -0
- package/dist/utils/forms/routing.js +13 -0
- package/dist/utils/forms/runtime-core.js +17 -0
- package/dist/utils/forms/runtime.js +27 -0
- package/dist/utils/forms/service-core.js +256 -0
- package/dist/utils/forms/service.js +55 -0
- package/dist/utils/forms/session.js +57 -0
- package/dist/utils/forms/smtp-cloudflare.js +107 -0
- package/dist/utils/forms/smtp-node.js +27 -0
- package/dist/utils/forms/smtp.js +10 -0
- package/dist/utils/forms/subscribers-local.js +21 -0
- package/dist/utils/forms/subscribers.js +53 -0
- package/dist/utils/forms/turnstile.js +31 -0
- package/dist/utils/forms/validation.js +58 -0
- package/dist/utils/hub-content.js +28 -0
- package/dist/utils/plugin-runtime.js +158 -0
- package/dist/utils/routes.js +17 -0
- package/dist/utils/seo.js +4 -0
- package/dist/utils/site-config-schema.js +282 -0
- package/dist/utils/site-config.js +122 -0
- package/dist/utils/starlight-nav.js +62 -0
- package/dist/utils/theme.js +49 -0
- package/dist/vendor/starlight/components/AnchorHeading.astro +53 -0
- package/dist/vendor/starlight/components/Banner.astro +23 -0
- package/dist/vendor/starlight/components/ContentNotice.astro +33 -0
- package/dist/vendor/starlight/components/ContentPanel.astro +27 -0
- package/dist/vendor/starlight/components/DraftContentNotice.astro +5 -0
- package/dist/vendor/starlight/components/EditLink.astro +28 -0
- package/dist/vendor/starlight/components/FallbackContentNotice.astro +5 -0
- package/dist/vendor/starlight/components/Footer.astro +61 -0
- package/dist/vendor/starlight/components/Head.astro +5 -0
- package/dist/vendor/starlight/components/Header.astro +94 -0
- package/dist/vendor/starlight/components/Hero.astro +143 -0
- package/dist/vendor/starlight/components/Icons.js +121 -0
- package/dist/vendor/starlight/components/LanguageSelect.astro +57 -0
- package/dist/vendor/starlight/components/LastUpdated.astro +14 -0
- package/dist/vendor/starlight/components/MarkdownContent.astro +5 -0
- package/dist/vendor/starlight/components/MobileMenuFooter.astro +35 -0
- package/dist/vendor/starlight/components/MobileMenuToggle.astro +107 -0
- package/dist/vendor/starlight/components/MobileTableOfContents.astro +151 -0
- package/dist/vendor/starlight/components/Page.astro +126 -0
- package/dist/vendor/starlight/components/PageFrame.astro +97 -0
- package/dist/vendor/starlight/components/PageSidebar.astro +59 -0
- package/dist/vendor/starlight/components/PageTitle.astro +17 -0
- package/dist/vendor/starlight/components/Pagination.astro +79 -0
- package/dist/vendor/starlight/components/Search.astro +488 -0
- package/dist/vendor/starlight/components/Select.astro +99 -0
- package/dist/vendor/starlight/components/Sidebar.astro +15 -0
- package/dist/vendor/starlight/components/SidebarPersistState.js +43 -0
- package/dist/vendor/starlight/components/SidebarPersister.astro +78 -0
- package/dist/vendor/starlight/components/SidebarRestorePoint.astro +12 -0
- package/dist/vendor/starlight/components/SidebarSublist.astro +154 -0
- package/dist/vendor/starlight/components/SiteTitle.astro +59 -0
- package/dist/vendor/starlight/components/SkipLink.astro +26 -0
- package/dist/vendor/starlight/components/SocialIcons.astro +32 -0
- package/dist/vendor/starlight/components/StarlightPage.astro +17 -0
- package/dist/vendor/starlight/components/TableOfContents/TableOfContentsList.astro +79 -0
- package/dist/vendor/starlight/components/TableOfContents/starlight-toc.js +93 -0
- package/dist/vendor/starlight/components/TableOfContents.astro +18 -0
- package/dist/vendor/starlight/components/ThemeProvider.astro +38 -0
- package/dist/vendor/starlight/components/ThemeSelect.astro +73 -0
- package/dist/vendor/starlight/components/TwoColumnContent.astro +54 -0
- package/dist/vendor/starlight/components.js +26 -0
- package/dist/vendor/starlight/constants.js +4 -0
- package/dist/vendor/starlight/expressive-code.d.js +1 -0
- package/dist/vendor/starlight/global.d.js +0 -0
- package/dist/vendor/starlight/i18n.d.js +1 -0
- package/dist/vendor/starlight/index.js +119 -0
- package/dist/vendor/starlight/integrations/asides-error.js +12 -0
- package/dist/vendor/starlight/integrations/asides.js +179 -0
- package/dist/vendor/starlight/integrations/code-rtl-support.js +21 -0
- package/dist/vendor/starlight/integrations/expressive-code/hast.d.js +1 -0
- package/dist/vendor/starlight/integrations/expressive-code/index.js +63 -0
- package/dist/vendor/starlight/integrations/expressive-code/preprocessor.js +92 -0
- package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-dark.jsonc +1796 -0
- package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-dark.jsonc.js +1 -0
- package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-light.jsonc +1695 -0
- package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-light.jsonc.js +1 -0
- package/dist/vendor/starlight/integrations/expressive-code/theming.js +62 -0
- package/dist/vendor/starlight/integrations/expressive-code/translations.js +29 -0
- package/dist/vendor/starlight/integrations/heading-links.js +61 -0
- package/dist/vendor/starlight/integrations/pagefind.js +43 -0
- package/dist/vendor/starlight/integrations/remark-rehype.js +68 -0
- package/dist/vendor/starlight/integrations/shared/absolutePathToLang.js +15 -0
- package/dist/vendor/starlight/integrations/shared/localeToLang.js +9 -0
- package/dist/vendor/starlight/integrations/shared/slugToLocale.js +10 -0
- package/dist/vendor/starlight/integrations/sitemap.js +20 -0
- package/dist/vendor/starlight/integrations/virtual-user-config.js +110 -0
- package/dist/vendor/starlight/integrations/vite-layer-order.js +42 -0
- package/dist/vendor/starlight/internal.js +6 -0
- package/dist/vendor/starlight/loaders.js +36 -0
- package/dist/vendor/starlight/locals.d.js +0 -0
- package/dist/vendor/starlight/locals.js +30 -0
- package/dist/vendor/starlight/package.json +231 -0
- package/dist/vendor/starlight/package.json.js +248 -0
- package/dist/vendor/starlight/props.js +0 -0
- package/dist/vendor/starlight/route-data.js +6 -0
- package/dist/vendor/starlight/routes/common.astro +23 -0
- package/dist/vendor/starlight/routes/ssr/404.astro +7 -0
- package/dist/vendor/starlight/routes/ssr/index.astro +14 -0
- package/dist/vendor/starlight/routes/static/404.astro +7 -0
- package/dist/vendor/starlight/routes/static/index.astro +12 -0
- package/dist/vendor/starlight/schema.js +102 -0
- package/dist/vendor/starlight/schemas/badge.js +26 -0
- package/dist/vendor/starlight/schemas/components.js +235 -0
- package/dist/vendor/starlight/schemas/expressiveCode.js +12 -0
- package/dist/vendor/starlight/schemas/favicon.js +33 -0
- package/dist/vendor/starlight/schemas/head.js +32 -0
- package/dist/vendor/starlight/schemas/hero.js +57 -0
- package/dist/vendor/starlight/schemas/i18n.js +101 -0
- package/dist/vendor/starlight/schemas/icon.js +7 -0
- package/dist/vendor/starlight/schemas/logo.js +24 -0
- package/dist/vendor/starlight/schemas/pagefind.js +108 -0
- package/dist/vendor/starlight/schemas/prevNextLink.js +14 -0
- package/dist/vendor/starlight/schemas/sidebar.js +80 -0
- package/dist/vendor/starlight/schemas/site-title.js +19 -0
- package/dist/vendor/starlight/schemas/social.js +19 -0
- package/dist/vendor/starlight/schemas/tableOfContents.js +16 -0
- package/dist/vendor/starlight/style/anchor-links.css +131 -0
- package/dist/vendor/starlight/style/asides.css +51 -0
- package/dist/vendor/starlight/style/layers.css +1 -0
- package/dist/vendor/starlight/style/markdown.css +253 -0
- package/dist/vendor/starlight/style/print.css +175 -0
- package/dist/vendor/starlight/style/props.css +188 -0
- package/dist/vendor/starlight/style/reset.css +52 -0
- package/dist/vendor/starlight/style/util.css +63 -0
- package/dist/vendor/starlight/translations/ar.json +30 -0
- package/dist/vendor/starlight/translations/ar.json.js +32 -0
- package/dist/vendor/starlight/translations/ca.json +43 -0
- package/dist/vendor/starlight/translations/ca.json.js +45 -0
- package/dist/vendor/starlight/translations/cs.json +43 -0
- package/dist/vendor/starlight/translations/cs.json.js +45 -0
- package/dist/vendor/starlight/translations/da.json +30 -0
- package/dist/vendor/starlight/translations/da.json.js +32 -0
- package/dist/vendor/starlight/translations/de.json +30 -0
- package/dist/vendor/starlight/translations/de.json.js +32 -0
- package/dist/vendor/starlight/translations/el.json +30 -0
- package/dist/vendor/starlight/translations/el.json.js +32 -0
- package/dist/vendor/starlight/translations/en.json +30 -0
- package/dist/vendor/starlight/translations/en.json.js +32 -0
- package/dist/vendor/starlight/translations/es.json +43 -0
- package/dist/vendor/starlight/translations/es.json.js +45 -0
- package/dist/vendor/starlight/translations/fa.json +30 -0
- package/dist/vendor/starlight/translations/fa.json.js +32 -0
- package/dist/vendor/starlight/translations/fi.json +30 -0
- package/dist/vendor/starlight/translations/fi.json.js +32 -0
- package/dist/vendor/starlight/translations/fr.json +33 -0
- package/dist/vendor/starlight/translations/fr.json.js +35 -0
- package/dist/vendor/starlight/translations/gl.json +43 -0
- package/dist/vendor/starlight/translations/gl.json.js +45 -0
- package/dist/vendor/starlight/translations/he.json +30 -0
- package/dist/vendor/starlight/translations/he.json.js +32 -0
- package/dist/vendor/starlight/translations/hi.json +30 -0
- package/dist/vendor/starlight/translations/hi.json.js +32 -0
- package/dist/vendor/starlight/translations/hu.json +43 -0
- package/dist/vendor/starlight/translations/hu.json.js +45 -0
- package/dist/vendor/starlight/translations/id.json +30 -0
- package/dist/vendor/starlight/translations/id.json.js +32 -0
- package/dist/vendor/starlight/translations/index.js +77 -0
- package/dist/vendor/starlight/translations/it.json +30 -0
- package/dist/vendor/starlight/translations/it.json.js +32 -0
- package/dist/vendor/starlight/translations/ja.json +30 -0
- package/dist/vendor/starlight/translations/ja.json.js +32 -0
- package/dist/vendor/starlight/translations/ko.json +30 -0
- package/dist/vendor/starlight/translations/ko.json.js +32 -0
- package/dist/vendor/starlight/translations/lv.json +30 -0
- package/dist/vendor/starlight/translations/lv.json.js +32 -0
- package/dist/vendor/starlight/translations/nb.json +30 -0
- package/dist/vendor/starlight/translations/nb.json.js +32 -0
- package/dist/vendor/starlight/translations/nl.json +30 -0
- package/dist/vendor/starlight/translations/nl.json.js +32 -0
- package/dist/vendor/starlight/translations/pl.json +33 -0
- package/dist/vendor/starlight/translations/pl.json.js +35 -0
- package/dist/vendor/starlight/translations/pt.json +30 -0
- package/dist/vendor/starlight/translations/pt.json.js +32 -0
- package/dist/vendor/starlight/translations/ro.json +30 -0
- package/dist/vendor/starlight/translations/ro.json.js +32 -0
- package/dist/vendor/starlight/translations/ru.json +33 -0
- package/dist/vendor/starlight/translations/ru.json.js +35 -0
- package/dist/vendor/starlight/translations/sk.json +30 -0
- package/dist/vendor/starlight/translations/sk.json.js +32 -0
- package/dist/vendor/starlight/translations/sv.json +30 -0
- package/dist/vendor/starlight/translations/sv.json.js +32 -0
- package/dist/vendor/starlight/translations/th.json +30 -0
- package/dist/vendor/starlight/translations/th.json.js +32 -0
- package/dist/vendor/starlight/translations/tr.json +30 -0
- package/dist/vendor/starlight/translations/tr.json.js +32 -0
- package/dist/vendor/starlight/translations/uk.json +30 -0
- package/dist/vendor/starlight/translations/uk.json.js +32 -0
- package/dist/vendor/starlight/translations/vi.json +30 -0
- package/dist/vendor/starlight/translations/vi.json.js +32 -0
- package/dist/vendor/starlight/translations/zh-CN.json +30 -0
- package/dist/vendor/starlight/translations/zh-CN.json.js +32 -0
- package/dist/vendor/starlight/translations/zh-TW.json +30 -0
- package/dist/vendor/starlight/translations/zh-TW.json.js +32 -0
- package/dist/vendor/starlight/types.js +0 -0
- package/dist/vendor/starlight/user-components/Aside.astro +40 -0
- package/dist/vendor/starlight/user-components/Badge.astro +148 -0
- package/dist/vendor/starlight/user-components/Card.astro +68 -0
- package/dist/vendor/starlight/user-components/CardGrid.astro +38 -0
- package/dist/vendor/starlight/user-components/FileTree.astro +137 -0
- package/dist/vendor/starlight/user-components/Icon.astro +42 -0
- package/dist/vendor/starlight/user-components/LinkButton.astro +78 -0
- package/dist/vendor/starlight/user-components/LinkCard.astro +78 -0
- package/dist/vendor/starlight/user-components/Steps.astro +90 -0
- package/dist/vendor/starlight/user-components/TabItem.astro +19 -0
- package/dist/vendor/starlight/user-components/Tabs.astro +268 -0
- package/dist/vendor/starlight/user-components/file-tree-icons.js +608 -0
- package/dist/vendor/starlight/user-components/rehype-file-tree.js +160 -0
- package/dist/vendor/starlight/user-components/rehype-steps.js +53 -0
- package/dist/vendor/starlight/user-components/rehype-tabs.js +73 -0
- package/dist/vendor/starlight/utils/base.js +14 -0
- package/dist/vendor/starlight/utils/canonical.js +13 -0
- package/dist/vendor/starlight/utils/collection-fs.js +13 -0
- package/dist/vendor/starlight/utils/collection.js +16 -0
- package/dist/vendor/starlight/utils/createPathFormatter.js +39 -0
- package/dist/vendor/starlight/utils/createTranslationSystem.js +60 -0
- package/dist/vendor/starlight/utils/error-map.js +110 -0
- package/dist/vendor/starlight/utils/format-path.js +9 -0
- package/dist/vendor/starlight/utils/generateToC.js +18 -0
- package/dist/vendor/starlight/utils/git.js +92 -0
- package/dist/vendor/starlight/utils/gitInlined.js +13 -0
- package/dist/vendor/starlight/utils/head.js +156 -0
- package/dist/vendor/starlight/utils/i18n.js +121 -0
- package/dist/vendor/starlight/utils/localizedUrl.js +37 -0
- package/dist/vendor/starlight/utils/navigation.js +320 -0
- package/dist/vendor/starlight/utils/path.js +52 -0
- package/dist/vendor/starlight/utils/plugins.js +355 -0
- package/dist/vendor/starlight/utils/routing/data.js +116 -0
- package/dist/vendor/starlight/utils/routing/index.js +107 -0
- package/dist/vendor/starlight/utils/routing/middleware.js +40 -0
- package/dist/vendor/starlight/utils/routing/types.js +0 -0
- package/dist/vendor/starlight/utils/routing.js +1 -0
- package/dist/vendor/starlight/utils/slugs.js +70 -0
- package/dist/vendor/starlight/utils/starlight-page.js +123 -0
- package/dist/vendor/starlight/utils/translations-fs.js +31 -0
- package/dist/vendor/starlight/utils/translations.js +31 -0
- package/dist/vendor/starlight/utils/types.js +0 -0
- package/dist/vendor/starlight/utils/url.js +5 -0
- package/dist/vendor/starlight/utils/user-config.js +255 -0
- package/dist/vendor/starlight/utils/validateLogoImports.js +22 -0
- package/dist/vendor/starlight/virtual-internal.d.js +0 -0
- package/dist/vendor/starlight/virtual.d.js +0 -0
- package/dist/worker/forms-worker.js +141 -0
- package/package.json +156 -0
- package/style/anchor-links.css +131 -0
- package/templates/github/deploy.workflow.yml +47 -0
- package/tsconfigs/strict.json +3 -0
- package/utils/git.ts +121 -0
- package/utils/gitInlined.ts +20 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, extname, join, relative, resolve } from 'node:path';
|
|
4
|
+
import { build } from 'esbuild';
|
|
5
|
+
import ts from 'typescript';
|
|
6
|
+
import { packageRoot } from './package-tools.js';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const srcRoot = resolve(packageRoot, 'src');
|
|
9
|
+
const scriptsRoot = resolve(packageRoot, 'scripts');
|
|
10
|
+
const distRoot = resolve(packageRoot, 'dist');
|
|
11
|
+
const JS_SOURCE_EXTENSIONS = new Set(['.ts', '.ts']);
|
|
12
|
+
const COPY_EXTENSIONS = new Set(['.astro', '.css', '.d.js', '.js', '.json', '.jsonc', '.ts', '.yaml', '.yml']);
|
|
13
|
+
function walkFiles(root) {
|
|
14
|
+
const files = [];
|
|
15
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
16
|
+
const fullPath = join(root, entry.name);
|
|
17
|
+
if (entry.isDirectory()) {
|
|
18
|
+
files.push(...walkFiles(fullPath));
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
files.push(fullPath);
|
|
22
|
+
}
|
|
23
|
+
return files;
|
|
24
|
+
}
|
|
25
|
+
function ensureDir(filePath) {
|
|
26
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
function rewriteRuntimeSpecifiers(contents) {
|
|
29
|
+
return contents
|
|
30
|
+
.replace(/(['"`])(\.[^'"`\n]+)\.(mjs|ts)\1/g, '$1$2.js$1')
|
|
31
|
+
.replaceAll('@treeseed/sdk/sdk', '@treeseed/sdk/sdk')
|
|
32
|
+
.replaceAll('@treeseed/sdk/sdk', '@treeseed/sdk/sdk')
|
|
33
|
+
.replaceAll('@treeseed/sdk/types', '@treeseed/sdk/types')
|
|
34
|
+
.replaceAll('@treeseed/sdk/types', '@treeseed/sdk/types')
|
|
35
|
+
.replaceAll('@treeseed/sdk/models', '@treeseed/sdk/models')
|
|
36
|
+
.replaceAll('@treeseed/sdk/models', '@treeseed/sdk/models')
|
|
37
|
+
.replaceAll('@treeseed/sdk/d1-store', '@treeseed/sdk/d1-store')
|
|
38
|
+
.replaceAll('@treeseed/sdk/d1-store', '@treeseed/sdk/d1-store')
|
|
39
|
+
.replaceAll('@treeseed/sdk/content-store', '@treeseed/sdk/content-store')
|
|
40
|
+
.replaceAll('@treeseed/sdk/content-store', '@treeseed/sdk/content-store')
|
|
41
|
+
.replaceAll('@treeseed/sdk/frontmatter', '@treeseed/sdk/frontmatter')
|
|
42
|
+
.replaceAll('@treeseed/sdk/frontmatter', '@treeseed/sdk/frontmatter')
|
|
43
|
+
.replaceAll('@treeseed/sdk/git-runtime', '@treeseed/sdk/git-runtime')
|
|
44
|
+
.replaceAll('@treeseed/sdk/git-runtime', '@treeseed/sdk/git-runtime')
|
|
45
|
+
.replaceAll('@treeseed/sdk/sdk-filters', '@treeseed/sdk/sdk-filters')
|
|
46
|
+
.replaceAll('@treeseed/sdk/sdk-filters', '@treeseed/sdk/sdk-filters')
|
|
47
|
+
.replaceAll('@treeseed/sdk/wrangler-d1', '@treeseed/sdk/wrangler-d1')
|
|
48
|
+
.replaceAll('@treeseed/sdk/wrangler-d1', '@treeseed/sdk/wrangler-d1')
|
|
49
|
+
.replaceAll('@treeseed/sdk/stores/helpers', '@treeseed/sdk/stores/helpers')
|
|
50
|
+
.replaceAll('@treeseed/sdk/stores/helpers', '@treeseed/sdk/stores/helpers')
|
|
51
|
+
.replaceAll('@treeseed/sdk/stores/cursor-store', '@treeseed/sdk/stores/cursor-store')
|
|
52
|
+
.replaceAll('@treeseed/sdk/stores/cursor-store', '@treeseed/sdk/stores/cursor-store')
|
|
53
|
+
.replaceAll('@treeseed/sdk/stores/lease-store', '@treeseed/sdk/stores/lease-store')
|
|
54
|
+
.replaceAll('@treeseed/sdk/stores/lease-store', '@treeseed/sdk/stores/lease-store')
|
|
55
|
+
.replaceAll('@treeseed/sdk/stores/message-store', '@treeseed/sdk/stores/message-store')
|
|
56
|
+
.replaceAll('@treeseed/sdk/stores/message-store', '@treeseed/sdk/stores/message-store')
|
|
57
|
+
.replaceAll('@treeseed/sdk/stores/run-store', '@treeseed/sdk/stores/run-store')
|
|
58
|
+
.replaceAll('@treeseed/sdk/stores/run-store', '@treeseed/sdk/stores/run-store')
|
|
59
|
+
.replaceAll('@treeseed/sdk/stores/subscription-store', '@treeseed/sdk/stores/subscription-store')
|
|
60
|
+
.replaceAll('@treeseed/sdk/stores/subscription-store', '@treeseed/sdk/stores/subscription-store')
|
|
61
|
+
.replaceAll('@treeseed/sdk/types/agents', '@treeseed/sdk/types/agents')
|
|
62
|
+
.replaceAll('@treeseed/sdk/types/agents', '@treeseed/sdk/types/agents')
|
|
63
|
+
.replaceAll('@treeseed/sdk/types/agents', '@treeseed/sdk/types/agents')
|
|
64
|
+
.replaceAll('@treeseed/sdk/types/agents', '@treeseed/sdk/types/agents')
|
|
65
|
+
.replaceAll('@treeseed/sdk/types/cloudflare', '@treeseed/sdk/types/cloudflare')
|
|
66
|
+
.replaceAll('@treeseed/sdk/types/cloudflare', '@treeseed/sdk/types/cloudflare')
|
|
67
|
+
.replaceAll('@treeseed/sdk/types/cloudflare', '@treeseed/sdk/types/cloudflare')
|
|
68
|
+
.replaceAll('@treeseed/sdk/types/cloudflare', '@treeseed/sdk/types/cloudflare')
|
|
69
|
+
.replaceAll('@treeseed/sdk/types/cloudflare', '@treeseed/sdk/types/cloudflare')
|
|
70
|
+
.replaceAll('@treeseed/sdk/types/cloudflare', '@treeseed/sdk/types/cloudflare');
|
|
71
|
+
}
|
|
72
|
+
function rewriteVendorImportSpecifiers(contents, importerFile) {
|
|
73
|
+
return contents
|
|
74
|
+
.replace(/(from\s+['"`]|import\s*\(\s*['"`]|export\s+\*\s+from\s+['"`]|export\s+\{[^}]*\}\s+from\s+['"`])(\.{1,2}\/[^'"`\n]+\.(?:json|jsonc))\?raw(['"`])/g, (match, prefix, specifier, suffix) => `${prefix}${specifier}.js${suffix}`)
|
|
75
|
+
.replace(/(from\s+['"`]|import\s*\(\s*['"`]|export\s+\*\s+from\s+['"`]|export\s+\{[^}]*\}\s+from\s+['"`])(\.{1,2}\/[^'"`\n]+\.json)(['"`])/g, (match, prefix, specifier, suffix) => `${prefix}${specifier}.js${suffix}`)
|
|
76
|
+
.replace(/(from\s+['"`]|import\s*\(\s*['"`]|export\s+\*\s+from\s+['"`]|export\s+\{[^}]*\}\s+from\s+['"`])(\.{1,2}\/[^'"`\n]+)(['"`])/g, (match, prefix, specifier, suffix) => {
|
|
77
|
+
if (specifier.endsWith('/') ||
|
|
78
|
+
/\.(?:js|mjs|cjs|json|jsonc|css|astro|svg|png|jpg|jpeg|gif|webp|avif|woff2?|ttf|otf)$/.test(specifier)) {
|
|
79
|
+
return match;
|
|
80
|
+
}
|
|
81
|
+
const resolvedPath = resolve(dirname(importerFile), specifier);
|
|
82
|
+
if (existsSync(`${resolvedPath}.js`)) {
|
|
83
|
+
return `${prefix}${specifier}.js${suffix}`;
|
|
84
|
+
}
|
|
85
|
+
if (existsSync(resolve(resolvedPath, 'index.js'))) {
|
|
86
|
+
return `${prefix}${specifier}/index.js${suffix}`;
|
|
87
|
+
}
|
|
88
|
+
return `${prefix}${specifier}.js${suffix}`;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function rewriteAstroAssetSpecifiers(contents, importerFile) {
|
|
92
|
+
return contents.replace(/(<script[^>]+src=)(['"])(\.{1,2}\/[^'"`\n]+)(\2)/g, (match, prefix, quote, specifier, suffix) => {
|
|
93
|
+
if (specifier.endsWith('/') ||
|
|
94
|
+
/\.(?:js|mjs|cjs|json|jsonc|css|astro|svg|png|jpg|jpeg|gif|webp|avif|woff2?|ttf|otf)$/.test(specifier)) {
|
|
95
|
+
return match;
|
|
96
|
+
}
|
|
97
|
+
const resolvedPath = resolve(dirname(importerFile), specifier);
|
|
98
|
+
if (existsSync(`${resolvedPath}.js`)) {
|
|
99
|
+
return `${prefix}${quote}${specifier}.js${suffix}`;
|
|
100
|
+
}
|
|
101
|
+
if (existsSync(resolve(resolvedPath, 'index.js'))) {
|
|
102
|
+
return `${prefix}${quote}${specifier}/index.js${suffix}`;
|
|
103
|
+
}
|
|
104
|
+
return match;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function writeRawTextModule(sourceFile, sourceRoot, outputRoot) {
|
|
108
|
+
const relativePath = relative(sourceRoot, sourceFile);
|
|
109
|
+
const outputFile = resolve(outputRoot, `${relativePath}.js`);
|
|
110
|
+
ensureDir(outputFile);
|
|
111
|
+
const source = readFileSync(sourceFile, 'utf8');
|
|
112
|
+
writeFileSync(outputFile, `export default ${JSON.stringify(source)};\n`, 'utf8');
|
|
113
|
+
}
|
|
114
|
+
function writeJsonModule(sourceFile, sourceRoot, outputRoot) {
|
|
115
|
+
const relativePath = relative(sourceRoot, sourceFile);
|
|
116
|
+
const outputFile = resolve(outputRoot, `${relativePath}.js`);
|
|
117
|
+
ensureDir(outputFile);
|
|
118
|
+
const source = readFileSync(sourceFile, 'utf8');
|
|
119
|
+
const parsed = JSON.parse(source);
|
|
120
|
+
const namedExports = Object.keys(parsed)
|
|
121
|
+
.filter((key) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key))
|
|
122
|
+
.map((key) => `export const ${key} = __treeseedJson.${key};`)
|
|
123
|
+
.join('\n');
|
|
124
|
+
writeFileSync(outputFile, `const __treeseedJson = ${JSON.stringify(parsed, null, 2)};\nexport default __treeseedJson;\n${namedExports}\n`, 'utf8');
|
|
125
|
+
}
|
|
126
|
+
function rewriteScriptRuntimeSpecifiers(contents) {
|
|
127
|
+
return rewriteRuntimeSpecifiers(contents)
|
|
128
|
+
.replace(/(['"`])\.\.\/src\//g, '$1../')
|
|
129
|
+
.replace(/(['"`])\.\/src\//g, '$1./dist/')
|
|
130
|
+
.replaceAll("'dist/worker/forms-worker.js'", "'dist/worker/forms-worker.js'")
|
|
131
|
+
.replaceAll('"dist/worker/forms-worker.js"', '"dist/worker/forms-worker.js"')
|
|
132
|
+
.replaceAll("'../deploy/config.js'", "'../deploy/config.js'")
|
|
133
|
+
.replaceAll('"../deploy/config.js"', '"../deploy/config.js"')
|
|
134
|
+
.replaceAll("'../deploy/config.js'", "'../deploy/config.js'")
|
|
135
|
+
.replaceAll('"../deploy/config.js"', '"../deploy/config.js"');
|
|
136
|
+
}
|
|
137
|
+
async function compileModule(filePath, sourceRoot, outputRoot) {
|
|
138
|
+
const relativePath = relative(sourceRoot, filePath);
|
|
139
|
+
const outputFile = resolve(outputRoot, relativePath.replace(/\.(mjs|ts)$/u, '.js'));
|
|
140
|
+
ensureDir(outputFile);
|
|
141
|
+
await build({
|
|
142
|
+
entryPoints: [filePath],
|
|
143
|
+
outfile: outputFile,
|
|
144
|
+
platform: 'node',
|
|
145
|
+
format: 'esm',
|
|
146
|
+
bundle: false,
|
|
147
|
+
logLevel: 'silent',
|
|
148
|
+
loader: {
|
|
149
|
+
'.jsonc': 'text',
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
const builtSource = readFileSync(outputFile, 'utf8');
|
|
153
|
+
const rewritten = rewriteVendorImportSpecifiers(rewriteRuntimeSpecifiers(builtSource), outputFile);
|
|
154
|
+
writeFileSync(outputFile, rewritten, 'utf8');
|
|
155
|
+
}
|
|
156
|
+
function copyAsset(filePath, sourceRoot, outputRoot) {
|
|
157
|
+
const outputFile = resolve(outputRoot, relative(sourceRoot, filePath));
|
|
158
|
+
ensureDir(outputFile);
|
|
159
|
+
copyFileSync(filePath, outputFile);
|
|
160
|
+
if (outputFile.endsWith('.astro') || outputFile.endsWith('.d.js') || outputFile.endsWith('.js')) {
|
|
161
|
+
const contents = readFileSync(outputFile, 'utf8');
|
|
162
|
+
const rewritten = outputFile.endsWith('.js')
|
|
163
|
+
? rewriteVendorImportSpecifiers(rewriteRuntimeSpecifiers(contents), outputFile)
|
|
164
|
+
: rewriteRuntimeSpecifiers(contents);
|
|
165
|
+
writeFileSync(outputFile, rewritten, 'utf8');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function copyPackageAsset(packageName, relativePath, outputRelativePath) {
|
|
169
|
+
let packageRootPath;
|
|
170
|
+
try {
|
|
171
|
+
packageRootPath = dirname(require.resolve(`${packageName}/package.json`));
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
packageRootPath = dirname(require.resolve(packageName));
|
|
175
|
+
}
|
|
176
|
+
const sourceFile = resolve(packageRootPath, relativePath);
|
|
177
|
+
const outputFile = resolve(packageRoot, outputRelativePath);
|
|
178
|
+
ensureDir(outputFile);
|
|
179
|
+
copyFileSync(sourceFile, outputFile);
|
|
180
|
+
}
|
|
181
|
+
function transpileScript(filePath) {
|
|
182
|
+
const source = readFileSync(filePath, 'utf8');
|
|
183
|
+
const relativePath = relative(scriptsRoot, filePath);
|
|
184
|
+
if (relativePath === 'fixture-tools.ts') {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const outputFile = resolve(distRoot, 'scripts', relativePath.replace(/\.(mjs|ts)$/u, '.js'));
|
|
188
|
+
const transformed = extname(filePath) === '.ts'
|
|
189
|
+
? ts.transpileModule(source, {
|
|
190
|
+
compilerOptions: {
|
|
191
|
+
module: ts.ModuleKind.ESNext,
|
|
192
|
+
target: ts.ScriptTarget.ES2022,
|
|
193
|
+
},
|
|
194
|
+
}).outputText
|
|
195
|
+
: source;
|
|
196
|
+
ensureDir(outputFile);
|
|
197
|
+
const rewritten = rewriteVendorImportSpecifiers(rewriteScriptRuntimeSpecifiers(transformed), outputFile);
|
|
198
|
+
writeFileSync(outputFile, rewritten, 'utf8');
|
|
199
|
+
chmodSync(outputFile, 0o755);
|
|
200
|
+
}
|
|
201
|
+
function rewriteDeclarations() {
|
|
202
|
+
for (const filePath of walkFiles(distRoot)) {
|
|
203
|
+
if (!filePath.endsWith('.d.js'))
|
|
204
|
+
continue;
|
|
205
|
+
const contents = readFileSync(filePath, 'utf8');
|
|
206
|
+
writeFileSync(filePath, rewriteRuntimeSpecifiers(contents), 'utf8');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function emitTypeDeclarations() {
|
|
210
|
+
const sourceFiles = [
|
|
211
|
+
resolve(srcRoot, 'contracts.ts'),
|
|
212
|
+
resolve(srcRoot, 'environment.ts'),
|
|
213
|
+
resolve(srcRoot, 'types/agents.ts'),
|
|
214
|
+
resolve(srcRoot, 'types/cloudflare.ts'),
|
|
215
|
+
resolve(srcRoot, 'plugins/plugin.ts'),
|
|
216
|
+
resolve(srcRoot, 'site-resources.ts'),
|
|
217
|
+
resolve(srcRoot, 'utils/agents/runtime-types.ts'),
|
|
218
|
+
resolve(srcRoot, 'utils/agents/contracts/messages.ts'),
|
|
219
|
+
resolve(srcRoot, 'utils/agents/contracts/run.ts'),
|
|
220
|
+
].filter((filePath) => existsSync(filePath));
|
|
221
|
+
if (sourceFiles.length === 0) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const compilerOptions = {
|
|
225
|
+
allowImportingTsExtensions: true,
|
|
226
|
+
declaration: true,
|
|
227
|
+
emitDeclarationOnly: true,
|
|
228
|
+
module: ts.ModuleKind.ESNext,
|
|
229
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
230
|
+
outDir: distRoot,
|
|
231
|
+
rootDir: srcRoot,
|
|
232
|
+
skipLibCheck: true,
|
|
233
|
+
target: ts.ScriptTarget.ES2022,
|
|
234
|
+
};
|
|
235
|
+
const program = ts.createProgram(sourceFiles, compilerOptions);
|
|
236
|
+
const emitResult = program.emit();
|
|
237
|
+
const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics ?? []);
|
|
238
|
+
if (diagnostics.length > 0) {
|
|
239
|
+
const message = diagnostics
|
|
240
|
+
.map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'))
|
|
241
|
+
.join('\n');
|
|
242
|
+
throw new Error(`Failed to emit Treeseed core declarations:\n${message}`);
|
|
243
|
+
}
|
|
244
|
+
if (emitResult.emitSkipped) {
|
|
245
|
+
throw new Error('Failed to emit Treeseed core declarations.');
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function toPosixRelative(fromFile, toFile) {
|
|
249
|
+
return relative(dirname(fromFile), toFile).replaceAll('\\', '/');
|
|
250
|
+
}
|
|
251
|
+
function rewriteTreeseedStarlightSpecifiers(contents, filePath) {
|
|
252
|
+
const componentsIndex = toPosixRelative(filePath, resolve(distRoot, 'vendor', 'starlight', 'components.js'));
|
|
253
|
+
const routeData = toPosixRelative(filePath, resolve(distRoot, 'vendor', 'starlight', 'route-data.js'));
|
|
254
|
+
return contents
|
|
255
|
+
.replaceAll("'../vendor/starlight/components.js'", `'${componentsIndex}'`)
|
|
256
|
+
.replaceAll('"../vendor/starlight/components.js"', `"${componentsIndex}"`)
|
|
257
|
+
.replaceAll("'../vendor/starlight/route-data.js'", `'${routeData}'`)
|
|
258
|
+
.replaceAll('"../vendor/starlight/route-data.js"', `"${routeData}"`)
|
|
259
|
+
.replace(/(['"])@astrojs\/starlight\/components\/([^'"\n]+)\1/g, (match, quote, subpath) => {
|
|
260
|
+
const target = toPosixRelative(filePath, resolve(distRoot, 'vendor', 'starlight', 'components', subpath));
|
|
261
|
+
return `${quote}${target}${quote}`;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
async function compileVendorPackage(sourceRoot, outputRoot) {
|
|
265
|
+
for (const filePath of walkFiles(sourceRoot)) {
|
|
266
|
+
if (filePath.endsWith('.d.js')) {
|
|
267
|
+
copyAsset(filePath, sourceRoot, outputRoot);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
const extension = extname(filePath);
|
|
271
|
+
if (extension === '.ts') {
|
|
272
|
+
await compileModule(filePath, sourceRoot, outputRoot);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (COPY_EXTENSIONS.has(extension)) {
|
|
276
|
+
copyAsset(filePath, sourceRoot, outputRoot);
|
|
277
|
+
if (extension === '.jsonc') {
|
|
278
|
+
writeRawTextModule(filePath, sourceRoot, outputRoot);
|
|
279
|
+
}
|
|
280
|
+
if (extension === '.json') {
|
|
281
|
+
writeJsonModule(filePath, sourceRoot, outputRoot);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
for (const filePath of walkFiles(outputRoot)) {
|
|
286
|
+
if (filePath.endsWith('.astro')) {
|
|
287
|
+
const contents = readFileSync(filePath, 'utf8');
|
|
288
|
+
writeFileSync(filePath, rewriteAstroAssetSpecifiers(contents, filePath), 'utf8');
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (!filePath.endsWith('.js'))
|
|
292
|
+
continue;
|
|
293
|
+
const contents = readFileSync(filePath, 'utf8');
|
|
294
|
+
writeFileSync(filePath, rewriteVendorImportSpecifiers(contents, filePath), 'utf8');
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function writeCompatibilityEntrypoint(outputFile, contents) {
|
|
298
|
+
ensureDir(outputFile);
|
|
299
|
+
writeFileSync(outputFile, `${contents}
|
|
300
|
+
`, 'utf8');
|
|
301
|
+
}
|
|
302
|
+
function patchVendoredStarlight(distVendorRoot) {
|
|
303
|
+
const indexFile = resolve(distVendorRoot, 'index.js');
|
|
304
|
+
if (readdirSync(dirname(indexFile)).includes('index.js')) {
|
|
305
|
+
let source = readFileSync(indexFile, 'utf8')
|
|
306
|
+
.replaceAll('@astrojs/starlight/locals', './locals.js')
|
|
307
|
+
.replaceAll('@astrojs/starlight/routes/static/404.astro', './routes/static/404.astro')
|
|
308
|
+
.replaceAll('@astrojs/starlight/routes/ssr/404.astro', './routes/ssr/404.astro')
|
|
309
|
+
.replaceAll('@astrojs/starlight/routes/static/index.astro', './routes/static/index.astro')
|
|
310
|
+
.replaceAll('@astrojs/starlight/routes/ssr/index.astro', './routes/ssr/index.astro');
|
|
311
|
+
if (!source.includes('from "node:url"')) {
|
|
312
|
+
source = `import { fileURLToPath } from "node:url";\n${source}`;
|
|
313
|
+
}
|
|
314
|
+
source = source
|
|
315
|
+
.replace('addMiddleware({ entrypoint: "./locals.js", order: "pre" });', 'addMiddleware({ entrypoint: fileURLToPath(new URL("./locals.js", import.meta.url)), order: "pre" });')
|
|
316
|
+
.replaceAll('"./routes/static/404.astro"', 'fileURLToPath(new URL("./routes/static/404.astro", import.meta.url))')
|
|
317
|
+
.replaceAll('"./routes/ssr/404.astro"', 'fileURLToPath(new URL("./routes/ssr/404.astro", import.meta.url))')
|
|
318
|
+
.replaceAll('"./routes/static/index.astro"', 'fileURLToPath(new URL("./routes/static/index.astro", import.meta.url))')
|
|
319
|
+
.replaceAll('"./routes/ssr/index.astro"', 'fileURLToPath(new URL("./routes/ssr/index.astro", import.meta.url))');
|
|
320
|
+
source = source
|
|
321
|
+
.replaceAll('name: "@astrojs/starlight"', 'name: "@treeseed/core-vendored-starlight"')
|
|
322
|
+
.replaceAll('i.name === "@astrojs/starlight"', 'i.name === "@treeseed/core-vendored-starlight"');
|
|
323
|
+
writeFileSync(indexFile, source, 'utf8');
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function patchTreeseedRuntime(distRuntimeRoot) {
|
|
327
|
+
const middlewareFile = resolve(distRuntimeRoot, 'middleware', 'starlightRouteData.js');
|
|
328
|
+
if (existsSync(middlewareFile)) {
|
|
329
|
+
const source = readFileSync(middlewareFile, 'utf8').replaceAll('"../vendor/starlight/route-data.js"', '"../vendor/starlight/route-data.js"');
|
|
330
|
+
writeFileSync(middlewareFile, source, 'utf8');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
async function main() {
|
|
334
|
+
rmSync(distRoot, { recursive: true, force: true });
|
|
335
|
+
mkdirSync(distRoot, { recursive: true });
|
|
336
|
+
for (const filePath of walkFiles(srcRoot)) {
|
|
337
|
+
if (filePath.endsWith('.d.js')) {
|
|
338
|
+
copyAsset(filePath, srcRoot, distRoot);
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
const extension = extname(filePath);
|
|
342
|
+
if (JS_SOURCE_EXTENSIONS.has(extension)) {
|
|
343
|
+
await compileModule(filePath, srcRoot, distRoot);
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (COPY_EXTENSIONS.has(extension) || filePath.endsWith('.d.js')) {
|
|
347
|
+
copyAsset(filePath, srcRoot, distRoot);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
for (const filePath of walkFiles(scriptsRoot)) {
|
|
351
|
+
const extension = extname(filePath);
|
|
352
|
+
if (JS_SOURCE_EXTENSIONS.has(extension)) {
|
|
353
|
+
transpileScript(filePath);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
emitTypeDeclarations();
|
|
357
|
+
const starlightPackageRoot = dirname(require.resolve('@astrojs/starlight'));
|
|
358
|
+
const vendoredStarlightRoot = resolve(distRoot, 'vendor', 'starlight');
|
|
359
|
+
await compileVendorPackage(starlightPackageRoot, vendoredStarlightRoot);
|
|
360
|
+
patchVendoredStarlight(vendoredStarlightRoot);
|
|
361
|
+
patchTreeseedRuntime(distRoot);
|
|
362
|
+
for (const filePath of walkFiles(distRoot)) {
|
|
363
|
+
if (filePath.startsWith(`${vendoredStarlightRoot}/`) || filePath === vendoredStarlightRoot)
|
|
364
|
+
continue;
|
|
365
|
+
if (!(filePath.endsWith('.astro') || filePath.endsWith('.js')))
|
|
366
|
+
continue;
|
|
367
|
+
const contents = readFileSync(filePath, 'utf8');
|
|
368
|
+
writeFileSync(filePath, rewriteTreeseedStarlightSpecifiers(contents, filePath), 'utf8');
|
|
369
|
+
}
|
|
370
|
+
writeCompatibilityEntrypoint(resolve(distRoot, 'config.js'), "import starlight from './vendor/starlight/index.js';\nimport { createTreeseedSite } from './site.js';\nimport { loadTreeseedManifest } from './tenant/config.js';\n\nexport function createTreeseedTenantSite(manifestPath) {\n\tconst tenant = loadTreeseedManifest(manifestPath);\n\treturn createTreeseedSite(tenant, { starlight });\n}");
|
|
371
|
+
writeCompatibilityEntrypoint(resolve(distRoot, 'content-config.js'), "import { docsLoader } from './vendor/starlight/loaders.js';\nimport { docsSchema } from './vendor/starlight/schema.js';\nimport { createTreeseedCollections } from './content.js';\nimport { loadTreeseedManifest } from './tenant/config.js';\n\nexport function createTreeseedTenantCollections(manifestPath) {\n\tconst tenant = loadTreeseedManifest(manifestPath);\n\treturn createTreeseedCollections(tenant, { docsLoader, docsSchema });\n}");
|
|
372
|
+
writeCompatibilityEntrypoint(resolve(vendoredStarlightRoot, 'utils', 'routing.js'), "export * from './routing/index.js';");
|
|
373
|
+
copyAsset(resolve(packageRoot, 'tsconfigs/strict.json'), packageRoot, distRoot);
|
|
374
|
+
copyPackageAsset('@astrojs/mdx', 'template/content-module-types.d.ts', 'template/content-module-types.d.ts');
|
|
375
|
+
copyPackageAsset('@astrojs/mdx', 'dist/server.js', 'dist/server.js');
|
|
376
|
+
copyPackageAsset('@astrojs/starlight', 'style/anchor-links.css', 'style/anchor-links.css');
|
|
377
|
+
copyPackageAsset('@astrojs/starlight', 'utils/git.ts', 'utils/git.ts');
|
|
378
|
+
copyPackageAsset('@astrojs/starlight', 'utils/gitInlined.ts', 'utils/gitInlined.ts');
|
|
379
|
+
rewriteDeclarations();
|
|
380
|
+
}
|
|
381
|
+
main().catch((error) => {
|
|
382
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
383
|
+
process.exit(1);
|
|
384
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { build } from 'esbuild';
|
|
4
|
+
import { loadTreeseedDeployConfig } from '../deploy/config.js';
|
|
5
|
+
import { loadTreeseedManifest } from '../tenant/config.js';
|
|
6
|
+
import { parseSiteConfig } from '../utils/site-config-schema.js';
|
|
7
|
+
import { packageRoot } from './package-tools.js';
|
|
8
|
+
const tenantRoot = process.cwd();
|
|
9
|
+
const workerEntry = resolve(packageRoot, 'dist/worker/forms-worker.js');
|
|
10
|
+
const outFile = resolve(tenantRoot, '.treeseed/generated/worker/index.js');
|
|
11
|
+
function ensureDir(filePath) {
|
|
12
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
function loadSiteConfig(tenantConfig) {
|
|
15
|
+
const siteConfigPath = resolve(tenantRoot, tenantConfig.siteConfigPath);
|
|
16
|
+
return parseSiteConfig(readFileSync(siteConfigPath, 'utf8'));
|
|
17
|
+
}
|
|
18
|
+
const tenantConfig = loadTreeseedManifest();
|
|
19
|
+
const siteConfig = loadSiteConfig(tenantConfig);
|
|
20
|
+
const deployConfig = loadTreeseedDeployConfig();
|
|
21
|
+
ensureDir(outFile);
|
|
22
|
+
await build({
|
|
23
|
+
entryPoints: [workerEntry],
|
|
24
|
+
outfile: outFile,
|
|
25
|
+
bundle: true,
|
|
26
|
+
format: 'esm',
|
|
27
|
+
platform: 'browser',
|
|
28
|
+
target: 'es2022',
|
|
29
|
+
logLevel: 'silent',
|
|
30
|
+
external: ['cloudflare:sockets'],
|
|
31
|
+
define: {
|
|
32
|
+
__TREESEED_SITE_CONFIG__: JSON.stringify(siteConfig),
|
|
33
|
+
__TREESEED_DEPLOY_CONFIG__: JSON.stringify(deployConfig),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
writeFileSync(resolve(tenantRoot, '.treeseed/generated/worker/package.json'), '{\n "type": "module"\n}\n', 'utf8');
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { dirname, extname, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const scriptRoot = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const packageCandidate = resolve(scriptRoot, '..');
|
|
10
|
+
export const packageRoot = packageCandidate.endsWith('/dist')
|
|
11
|
+
? resolve(packageCandidate, '..')
|
|
12
|
+
: packageCandidate;
|
|
13
|
+
export const packageScriptRoot = packageCandidate.endsWith('/dist')
|
|
14
|
+
? resolve(packageCandidate, 'scripts')
|
|
15
|
+
: resolve(packageRoot, 'scripts');
|
|
16
|
+
function resolvePackageBinary(packageName, binName = packageName) {
|
|
17
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
18
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
19
|
+
const binField = packageJson.bin;
|
|
20
|
+
const relativePath = typeof binField === 'string'
|
|
21
|
+
? binField
|
|
22
|
+
: binField?.[binName];
|
|
23
|
+
if (!relativePath) {
|
|
24
|
+
throw new Error(`Unable to resolve binary "${binName}" from package "${packageName}".`);
|
|
25
|
+
}
|
|
26
|
+
return resolve(dirname(packageJsonPath), relativePath);
|
|
27
|
+
}
|
|
28
|
+
export const astroBin = resolvePackageBinary('astro', 'astro');
|
|
29
|
+
export const wranglerBin = resolvePackageBinary('wrangler', 'wrangler');
|
|
30
|
+
export function loadPackageJson(root = process.cwd()) {
|
|
31
|
+
const packageJsonPath = resolve(root, 'package.json');
|
|
32
|
+
if (!existsSync(packageJsonPath)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
36
|
+
}
|
|
37
|
+
export function isWorkspaceRoot(root = process.cwd()) {
|
|
38
|
+
const packageJson = loadPackageJson(root);
|
|
39
|
+
const workspaces = Array.isArray(packageJson?.workspaces)
|
|
40
|
+
? packageJson.workspaces
|
|
41
|
+
: Array.isArray(packageJson?.workspaces?.packages)
|
|
42
|
+
? packageJson.workspaces.packages
|
|
43
|
+
: [];
|
|
44
|
+
return workspaces.length > 0;
|
|
45
|
+
}
|
|
46
|
+
export function createProductionBuildEnv(extraEnv = {}) {
|
|
47
|
+
return {
|
|
48
|
+
TREESEED_LOCAL_DEV_MODE: 'cloudflare',
|
|
49
|
+
TREESEED_PUBLIC_FORMS_LOCAL_BYPASS_TURNSTILE: '',
|
|
50
|
+
TREESEED_FORMS_LOCAL_BYPASS_TURNSTILE: '',
|
|
51
|
+
TREESEED_FORMS_LOCAL_BYPASS_CLOUDFLARE_GUARDS: '',
|
|
52
|
+
TREESEED_PUBLIC_DEV_WATCH_RELOAD: '',
|
|
53
|
+
...extraEnv,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function packageScriptPath(scriptName) {
|
|
57
|
+
if (extname(scriptName)) {
|
|
58
|
+
return resolve(packageScriptRoot, scriptName);
|
|
59
|
+
}
|
|
60
|
+
for (const extension of ['.js', '.ts', '.ts']) {
|
|
61
|
+
const candidate = resolve(packageScriptRoot, `${scriptName}${extension}`);
|
|
62
|
+
if (existsSync(candidate)) {
|
|
63
|
+
return candidate;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`Unable to resolve package script "${scriptName}".`);
|
|
67
|
+
}
|
|
68
|
+
export function runNodeBinary(binPath, args, options = {}) {
|
|
69
|
+
const result = spawnSync(process.execPath, [binPath, ...args], {
|
|
70
|
+
stdio: options.stdio ?? 'inherit',
|
|
71
|
+
cwd: options.cwd ?? process.cwd(),
|
|
72
|
+
env: { ...process.env, ...(options.env ?? {}) },
|
|
73
|
+
});
|
|
74
|
+
if (result.status !== 0) {
|
|
75
|
+
process.exit(result.status ?? 1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function runNodeScript(scriptPath, args = [], options = {}) {
|
|
79
|
+
return runNodeBinary(scriptPath, args, options);
|
|
80
|
+
}
|
|
81
|
+
export function spawnNodeBinary(binPath, args, options = {}) {
|
|
82
|
+
return spawn(process.execPath, [binPath, ...args], {
|
|
83
|
+
stdio: options.stdio ?? 'inherit',
|
|
84
|
+
cwd: options.cwd ?? process.cwd(),
|
|
85
|
+
env: { ...process.env, ...(options.env ?? {}) },
|
|
86
|
+
detached: options.detached ?? false,
|
|
87
|
+
});
|
|
88
|
+
}
|