@asymmetric-effort/specifyjs 0.2.137 → 0.2.140
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/dist/esm/chunks/{chunk-BGPJRIMR.js → chunk-45EBJMQH.js} +6 -7
- package/dist/esm/chunks/{chunk-4IF6GADP.js → chunk-4TF5WXQG.js} +0 -1
- package/dist/esm/chunks/{chunk-CWCWXKVV.js → chunk-4V37N6QN.js} +0 -1
- package/dist/esm/chunks/{chunk-5OX5JKEY.js → chunk-7OC7LXZ7.js} +1 -2
- package/dist/esm/chunks/{chunk-T7EHIXSF.js → chunk-AE2JTY3A.js} +1 -2
- package/dist/esm/chunks/{chunk-MKUA6QTB.js → chunk-FDNBPWUH.js} +0 -1
- package/dist/esm/chunks/{chunk-LSU3FWKI.js → chunk-H7ZJ2I3D.js} +1 -2
- package/dist/esm/chunks/{chunk-NF4555DU.js → chunk-NKW7RJR3.js} +1 -2
- package/dist/esm/chunks/{chunk-RSL3RU56.js → chunk-SRUWIDIG.js} +1 -2
- package/dist/esm/chunks/{chunk-HINJXYXY.js → chunk-UJTLBTMV.js} +0 -1
- package/dist/esm/chunks/{metrics-AGFZKFUK.js → metrics-ELQJ4BZ7.js} +3 -4
- package/dist/esm/client/index.js +3 -4
- package/dist/esm/components-barrel.js +8 -9
- package/dist/esm/dom/index.js +9 -7
- package/dist/esm/index.js +8 -9
- package/dist/esm/jsx-dev-runtime.js +4 -5
- package/dist/esm/jsx-runtime.js +4 -5
- package/dist/esm/server/index.js +3 -4
- package/dist/esm/telemetry/index.js +5 -6
- package/dist/specifyjs-build.cjs.js +0 -1
- package/dist/specifyjs-build.esm.js +0 -1
- package/dist/specifyjs-client.cjs.js +0 -1
- package/dist/specifyjs-client.esm.js +3 -4
- package/dist/specifyjs-components.cjs.js +0 -1
- package/dist/specifyjs-components.esm.js +8 -9
- package/dist/specifyjs-dom.cjs.js +1 -2
- package/dist/specifyjs-dom.esm.js +9 -7
- package/dist/specifyjs-jsx-dev-runtime.cjs.js +0 -1
- package/dist/specifyjs-jsx-dev-runtime.esm.js +4 -5
- package/dist/specifyjs-jsx-runtime.cjs.js +0 -1
- package/dist/specifyjs-jsx-runtime.esm.js +4 -5
- package/dist/specifyjs-server.cjs.js +0 -1
- package/dist/specifyjs-server.esm.js +3 -4
- package/dist/specifyjs-telemetry.cjs.js +0 -1
- package/dist/specifyjs-telemetry.esm.js +5 -6
- package/dist/specifyjs.cjs.js +0 -1
- package/dist/specifyjs.esm.js +8 -9
- package/dist/types/build/index.d.ts +0 -1
- package/dist/types/build/noscript-plugin.d.ts +0 -1
- package/dist/types/build/seo-plugin.d.ts +0 -1
- package/dist/types/client/graphql.d.ts +0 -1
- package/dist/types/client/index.d.ts +0 -1
- package/dist/types/client/protobuf.d.ts +0 -1
- package/dist/types/client/rest.d.ts +0 -1
- package/dist/types/components/component.d.ts +0 -1
- package/dist/types/components/error-boundary.d.ts +0 -1
- package/dist/types/components/feedback/banner/src/Banner.d.ts +14 -0
- package/dist/types/components/feedback/banner/src/index.d.ts +2 -0
- package/dist/types/components/profiler.d.ts +0 -1
- package/dist/types/components/strict-mode.d.ts +0 -1
- package/dist/types/components/suspense.d.ts +0 -1
- package/dist/types/compute/context.d.ts +0 -1
- package/dist/types/compute/cpu-backend.d.ts +0 -1
- package/dist/types/compute/index.d.ts +0 -1
- package/dist/types/compute/types.d.ts +0 -1
- package/dist/types/compute/webgl-backend.d.ts +0 -1
- package/dist/types/compute/webgpu-backend.d.ts +0 -1
- package/dist/types/context/create-context.d.ts +0 -1
- package/dist/types/core/children.d.ts +0 -1
- package/dist/types/core/clone-element.d.ts +0 -1
- package/dist/types/core/create-element.d.ts +0 -1
- package/dist/types/core/create-ref.d.ts +0 -1
- package/dist/types/core/fiber.d.ts +0 -1
- package/dist/types/core/forward-ref.d.ts +0 -1
- package/dist/types/core/fragment.d.ts +0 -1
- package/dist/types/core/is-valid-element.d.ts +0 -1
- package/dist/types/core/lanes.d.ts +0 -1
- package/dist/types/core/lazy.d.ts +0 -1
- package/dist/types/core/memo.d.ts +0 -1
- package/dist/types/core/reconciler.d.ts +0 -1
- package/dist/types/core/scheduler-host-config.d.ts +0 -1
- package/dist/types/core/scheduler.d.ts +0 -1
- package/dist/types/core/src/shared/warnings.d.ts +2 -0
- package/dist/types/core/transitions.d.ts +0 -1
- package/dist/types/devtools/index.d.ts +0 -1
- package/dist/types/dom/create-portal.d.ts +0 -1
- package/dist/types/dom/create-root.d.ts +0 -1
- package/dist/types/dom/flush-sync.d.ts +0 -1
- package/dist/types/dom/index.d.ts +0 -1
- package/dist/types/dom/legacy.d.ts +0 -1
- package/dist/types/dom/synthetic-event.d.ts +0 -1
- package/dist/types/dom/work-loop.d.ts +0 -1
- package/dist/types/features/feature-flags.d.ts +0 -1
- package/dist/types/features/index.d.ts +0 -1
- package/dist/types/hooks/dispatcher.d.ts +0 -1
- package/dist/types/hooks/hook-state.d.ts +0 -1
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/hooks/install-dispatcher.d.ts +0 -1
- package/dist/types/hooks/use-head.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/jsx-dev-runtime.d.ts +0 -1
- package/dist/types/jsx-runtime.d.ts +0 -1
- package/dist/types/router/index.d.ts +0 -1
- package/dist/types/router/link-component.d.ts +0 -1
- package/dist/types/router/match-path.d.ts +0 -1
- package/dist/types/router/route-component.d.ts +0 -1
- package/dist/types/router/router-component.d.ts +0 -1
- package/dist/types/router/router-context.d.ts +0 -1
- package/dist/types/router/router-store.d.ts +0 -1
- package/dist/types/router/use-navigate.d.ts +0 -1
- package/dist/types/router/use-params.d.ts +0 -1
- package/dist/types/router/use-router.d.ts +0 -1
- package/dist/types/server/index.d.ts +0 -1
- package/dist/types/server/render-to-pipeable-stream.d.ts +0 -1
- package/dist/types/server/render-to-readable-stream.d.ts +0 -1
- package/dist/types/server/render-to-string.d.ts +0 -1
- package/dist/types/shared/act.d.ts +0 -1
- package/dist/types/shared/aria-warnings.d.ts +0 -1
- package/dist/types/shared/async-compute.d.ts +0 -1
- package/dist/types/shared/component-registry.d.ts +0 -1
- package/dist/types/shared/render-guard.d.ts +0 -1
- package/dist/types/shared/secure-fetch.d.ts +0 -1
- package/dist/types/shared/types.d.ts +0 -1
- package/dist/types/shared/warnings.d.ts +2 -1
- package/dist/types/telemetry/index.d.ts +0 -1
- package/dist/types/telemetry/metrics.d.ts +0 -1
- package/dist/types/telemetry/tracing.d.ts +0 -1
- package/package.json +1 -1
- package/dist/esm/chunks/chunk-4IF6GADP.js.map +0 -7
- package/dist/esm/chunks/chunk-5OX5JKEY.js.map +0 -7
- package/dist/esm/chunks/chunk-BGPJRIMR.js.map +0 -7
- package/dist/esm/chunks/chunk-CWCWXKVV.js.map +0 -7
- package/dist/esm/chunks/chunk-HINJXYXY.js.map +0 -7
- package/dist/esm/chunks/chunk-LSU3FWKI.js.map +0 -7
- package/dist/esm/chunks/chunk-MKUA6QTB.js.map +0 -7
- package/dist/esm/chunks/chunk-NF4555DU.js.map +0 -7
- package/dist/esm/chunks/chunk-RSL3RU56.js.map +0 -7
- package/dist/esm/chunks/chunk-T7EHIXSF.js.map +0 -7
- package/dist/esm/chunks/metrics-AGFZKFUK.js.map +0 -7
- package/dist/specifyjs-build.cjs.js.map +0 -7
- package/dist/specifyjs-build.esm.js.map +0 -7
- package/dist/specifyjs-client.cjs.js.map +0 -7
- package/dist/specifyjs-client.esm.js.map +0 -7
- package/dist/specifyjs-components.cjs.js.map +0 -7
- package/dist/specifyjs-components.esm.js.map +0 -7
- package/dist/specifyjs-dom.cjs.js.map +0 -7
- package/dist/specifyjs-dom.esm.js.map +0 -7
- package/dist/specifyjs-jsx-dev-runtime.cjs.js.map +0 -7
- package/dist/specifyjs-jsx-dev-runtime.esm.js.map +0 -7
- package/dist/specifyjs-jsx-runtime.cjs.js.map +0 -7
- package/dist/specifyjs-jsx-runtime.esm.js.map +0 -7
- package/dist/specifyjs-server.cjs.js.map +0 -7
- package/dist/specifyjs-server.esm.js.map +0 -7
- package/dist/specifyjs-telemetry.cjs.js.map +0 -7
- package/dist/specifyjs-telemetry.esm.js.map +0 -7
- package/dist/specifyjs.cjs.js.map +0 -7
- package/dist/specifyjs.esm.js.map +0 -7
- package/dist/types/build/index.d.ts.map +0 -1
- package/dist/types/build/noscript-plugin.d.ts.map +0 -1
- package/dist/types/build/seo-plugin.d.ts.map +0 -1
- package/dist/types/client/graphql.d.ts.map +0 -1
- package/dist/types/client/index.d.ts.map +0 -1
- package/dist/types/client/protobuf.d.ts.map +0 -1
- package/dist/types/client/rest.d.ts.map +0 -1
- package/dist/types/components/component.d.ts.map +0 -1
- package/dist/types/components/error-boundary.d.ts.map +0 -1
- package/dist/types/components/profiler.d.ts.map +0 -1
- package/dist/types/components/strict-mode.d.ts.map +0 -1
- package/dist/types/components/suspense.d.ts.map +0 -1
- package/dist/types/compute/context.d.ts.map +0 -1
- package/dist/types/compute/cpu-backend.d.ts.map +0 -1
- package/dist/types/compute/index.d.ts.map +0 -1
- package/dist/types/compute/types.d.ts.map +0 -1
- package/dist/types/compute/webgl-backend.d.ts.map +0 -1
- package/dist/types/compute/webgpu-backend.d.ts.map +0 -1
- package/dist/types/context/create-context.d.ts.map +0 -1
- package/dist/types/core/children.d.ts.map +0 -1
- package/dist/types/core/clone-element.d.ts.map +0 -1
- package/dist/types/core/create-element.d.ts.map +0 -1
- package/dist/types/core/create-ref.d.ts.map +0 -1
- package/dist/types/core/fiber.d.ts.map +0 -1
- package/dist/types/core/forward-ref.d.ts.map +0 -1
- package/dist/types/core/fragment.d.ts.map +0 -1
- package/dist/types/core/is-valid-element.d.ts.map +0 -1
- package/dist/types/core/lanes.d.ts.map +0 -1
- package/dist/types/core/lazy.d.ts.map +0 -1
- package/dist/types/core/memo.d.ts.map +0 -1
- package/dist/types/core/reconciler.d.ts.map +0 -1
- package/dist/types/core/scheduler-host-config.d.ts.map +0 -1
- package/dist/types/core/scheduler.d.ts.map +0 -1
- package/dist/types/core/transitions.d.ts.map +0 -1
- package/dist/types/devtools/index.d.ts.map +0 -1
- package/dist/types/dom/create-portal.d.ts.map +0 -1
- package/dist/types/dom/create-root.d.ts.map +0 -1
- package/dist/types/dom/flush-sync.d.ts.map +0 -1
- package/dist/types/dom/index.d.ts.map +0 -1
- package/dist/types/dom/legacy.d.ts.map +0 -1
- package/dist/types/dom/synthetic-event.d.ts.map +0 -1
- package/dist/types/dom/work-loop.d.ts.map +0 -1
- package/dist/types/features/feature-flags.d.ts.map +0 -1
- package/dist/types/features/index.d.ts.map +0 -1
- package/dist/types/hooks/dispatcher.d.ts.map +0 -1
- package/dist/types/hooks/hook-state.d.ts.map +0 -1
- package/dist/types/hooks/index.d.ts.map +0 -1
- package/dist/types/hooks/install-dispatcher.d.ts.map +0 -1
- package/dist/types/hooks/use-head.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/jsx-dev-runtime.d.ts.map +0 -1
- package/dist/types/jsx-runtime.d.ts.map +0 -1
- package/dist/types/router/index.d.ts.map +0 -1
- package/dist/types/router/link-component.d.ts.map +0 -1
- package/dist/types/router/match-path.d.ts.map +0 -1
- package/dist/types/router/route-component.d.ts.map +0 -1
- package/dist/types/router/router-component.d.ts.map +0 -1
- package/dist/types/router/router-context.d.ts.map +0 -1
- package/dist/types/router/router-store.d.ts.map +0 -1
- package/dist/types/router/use-navigate.d.ts.map +0 -1
- package/dist/types/router/use-params.d.ts.map +0 -1
- package/dist/types/router/use-router.d.ts.map +0 -1
- package/dist/types/server/index.d.ts.map +0 -1
- package/dist/types/server/render-to-pipeable-stream.d.ts.map +0 -1
- package/dist/types/server/render-to-readable-stream.d.ts.map +0 -1
- package/dist/types/server/render-to-string.d.ts.map +0 -1
- package/dist/types/shared/act.d.ts.map +0 -1
- package/dist/types/shared/aria-warnings.d.ts.map +0 -1
- package/dist/types/shared/async-compute.d.ts.map +0 -1
- package/dist/types/shared/component-registry.d.ts.map +0 -1
- package/dist/types/shared/render-guard.d.ts.map +0 -1
- package/dist/types/shared/secure-fetch.d.ts.map +0 -1
- package/dist/types/shared/types.d.ts.map +0 -1
- package/dist/types/shared/warnings.d.ts.map +0 -1
- package/dist/types/telemetry/index.d.ts.map +0 -1
- package/dist/types/telemetry/metrics.d.ts.map +0 -1
- package/dist/types/telemetry/tracing.d.ts.map +0 -1
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/index.ts", "../../../src/hooks/use-head.ts"],
|
|
4
|
-
"sourcesContent": ["// ============================================================================\n// SpecifyJS Hooks\n// ============================================================================\n// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport type { SpecContext } from '../shared/types';\n\n// Internal: the currently rendering fiber sets these\ntype Dispatcher = {\n useState: typeof useState;\n useEffect: typeof useEffect;\n useContext: typeof useContext;\n useReducer: typeof useReducer;\n useCallback: typeof useCallback;\n useMemo: typeof useMemo;\n useRef: typeof useRef;\n useImperativeHandle: typeof useImperativeHandle;\n useLayoutEffect: typeof useLayoutEffect;\n useDebugValue: typeof useDebugValue;\n useId: typeof useId;\n useDeferredValue: typeof useDeferredValue;\n useTransition: typeof useTransition;\n useSyncExternalStore: typeof useSyncExternalStore;\n useInsertionEffect: typeof useInsertionEffect;\n};\n\nlet currentDispatcher: Dispatcher | null = null;\n\nexport function __setDispatcher(dispatcher: Dispatcher | null): void {\n currentDispatcher = dispatcher;\n}\n\nexport function __getDispatcher(): Dispatcher | null {\n return currentDispatcher;\n}\n\nfunction resolveDispatcher(): Dispatcher {\n if (currentDispatcher === null) {\n throw new Error(\n 'Invalid hook call. Hooks can only be called inside the body of a function component.',\n );\n }\n return currentDispatcher;\n}\n\nexport function useState<T>(\n initialState: T | (() => T),\n): [T, (action: T | ((prev: T) => T)) => void] {\n return resolveDispatcher().useState(initialState);\n}\n\nexport function useEffect(create: () => void | (() => void), deps?: readonly unknown[]): void {\n return resolveDispatcher().useEffect(create, deps);\n}\n\nexport function useContext<T>(context: SpecContext<T>): T {\n return resolveDispatcher().useContext(context);\n}\n\nexport function useReducer<S, A>(\n reducer: (state: S, action: A) => S,\n initialArg: S,\n init?: (arg: S) => S,\n): [S, (action: A) => void] {\n return resolveDispatcher().useReducer(reducer, initialArg, init);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useCallback<T extends (...args: any[]) => any>(\n callback: T,\n deps: readonly unknown[],\n): T {\n return resolveDispatcher().useCallback(callback, deps);\n}\n\nexport function useMemo<T>(factory: () => T, deps: readonly unknown[]): T {\n return resolveDispatcher().useMemo(factory, deps);\n}\n\nexport function useRef<T>(initialValue: T): { current: T };\nexport function useRef<T>(initialValue: T | null): { current: T | null };\nexport function useRef<T>(): { current: T | undefined };\nexport function useRef<T>(initialValue?: T): { current: T | undefined } {\n return resolveDispatcher().useRef(initialValue);\n}\n\nexport function useImperativeHandle<T>(\n ref: { current: T | null } | ((instance: T | null) => void) | null,\n createHandle: () => T,\n deps?: readonly unknown[],\n): void {\n return resolveDispatcher().useImperativeHandle(ref, createHandle, deps);\n}\n\nexport function useLayoutEffect(\n create: () => void | (() => void),\n deps?: readonly unknown[],\n): void {\n return resolveDispatcher().useLayoutEffect(create, deps);\n}\n\nexport function useDebugValue<T>(value: T, format?: (value: T) => unknown): void {\n return resolveDispatcher().useDebugValue(value, format);\n}\n\nexport function useId(): string {\n return resolveDispatcher().useId();\n}\n\nexport function useDeferredValue<T>(value: T): T {\n return resolveDispatcher().useDeferredValue(value);\n}\n\nexport function useTransition(): [boolean, (callback: () => void) => void] {\n return resolveDispatcher().useTransition();\n}\n\nexport function useSyncExternalStore<T>(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n): T {\n return resolveDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n\nexport function useInsertionEffect(\n create: () => void | (() => void),\n deps?: readonly unknown[],\n): void {\n return resolveDispatcher().useInsertionEffect(create, deps);\n}\n\n// Custom hooks (not dispatcher-based)\nexport { useHead } from './use-head';\nexport type { HeadMeta, HeadHttpEquiv } from './use-head';\n", "// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\n/**\n * useHead \u2014 Manages document <head> meta tags from within components.\n *\n * Allows components to declaratively set page title, meta description,\n * keywords, author, Open Graph tags, and arbitrary meta elements.\n * Tags are applied on mount and cleaned up on unmount.\n */\n\nimport { useEffect, useRef } from './index';\n\nexport interface HeadHttpEquiv {\n /** Content-Security-Policy */\n csp?: string;\n /** Referrer-Policy */\n referrer?: string;\n /** X-Content-Type-Options */\n contentType?: string;\n /** X-Frame-Options (via Content-Security-Policy frame-ancestors) */\n frameOptions?: string;\n /** Cache-Control */\n cacheControl?: string;\n /** Arbitrary http-equiv tags */\n [key: string]: string | undefined;\n}\n\nexport interface HeadMeta {\n /** Document title */\n title?: string;\n /** Meta description */\n description?: string;\n /** Meta keywords (comma-separated) */\n keywords?: string;\n /** Meta author */\n author?: string;\n /** Canonical URL */\n canonical?: string;\n /** Open Graph tags */\n og?: Record<string, string>;\n /** Twitter card tags */\n twitter?: Record<string, string>;\n /** HTTP-equiv meta tags (security headers, caching, etc.) */\n httpEquiv?: HeadHttpEquiv;\n /** Arbitrary meta tags: [{ name, content }] or [{ property, content }] */\n meta?: Array<{ name?: string; property?: string; content: string }>;\n}\n\n/**\n * Sets document head meta tags. Tags are applied when the component\n * mounts and removed when it unmounts, preventing stale meta from\n * persisting across route changes.\n *\n * ```typescript\n * useHead({\n * title: 'My Page',\n * description: 'Page description for SEO',\n * keywords: 'specifyjs, framework, spa',\n * author: 'Your Name',\n * og: { title: 'My Page', image: '/og-image.png' },\n * });\n * ```\n */\nexport function useHead(head: HeadMeta): void {\n // Store head config in a ref to avoid unstable object deps\n const headRef = useRef(head);\n headRef.current = head;\n\n // Serialize scalar deps for stable comparison; objects use JSON\n const depsKey = JSON.stringify([\n head.title,\n head.description,\n head.keywords,\n head.author,\n head.canonical,\n head.og,\n head.twitter,\n head.httpEquiv,\n head.meta,\n ]);\n\n useEffect(() => {\n const head = headRef.current;\n const cleanup: (() => void)[] = [];\n\n // Title\n const prevTitle = document.title;\n if (head.title) {\n document.title = head.title;\n cleanup.push(() => {\n document.title = prevTitle;\n });\n }\n\n // Standard meta tags\n if (head.description) {\n cleanup.push(setMeta('name', 'description', head.description));\n }\n if (head.keywords) {\n cleanup.push(setMeta('name', 'keywords', head.keywords));\n }\n if (head.author) {\n cleanup.push(setMeta('name', 'author', head.author));\n }\n\n // Canonical link\n if (head.canonical) {\n const link = document.createElement('link');\n link.rel = 'canonical';\n link.href = head.canonical;\n document.head.appendChild(link);\n cleanup.push(() => link.remove());\n }\n\n // Open Graph\n if (head.og) {\n for (const [key, value] of Object.entries(head.og)) {\n cleanup.push(setMeta('property', `og:${key}`, value));\n }\n }\n\n // Twitter Card\n if (head.twitter) {\n for (const [key, value] of Object.entries(head.twitter)) {\n cleanup.push(setMeta('name', `twitter:${key}`, value));\n }\n }\n\n // HTTP-equiv meta tags (security headers)\n if (head.httpEquiv) {\n const httpEquivMap: Record<string, string> = {\n csp: 'Content-Security-Policy',\n referrer: 'Referrer-Policy',\n contentType: 'X-Content-Type-Options',\n frameOptions: 'X-Frame-Options',\n cacheControl: 'Cache-Control',\n };\n for (const [key, value] of Object.entries(head.httpEquiv)) {\n if (value === undefined) continue;\n const httpEquivName = httpEquivMap[key] ?? key;\n cleanup.push(setHttpEquivMeta(httpEquivName, value));\n }\n }\n\n // Arbitrary meta tags\n if (head.meta) {\n for (const tag of head.meta) {\n if (tag.name) {\n cleanup.push(setMeta('name', tag.name, tag.content));\n } else if (tag.property) {\n cleanup.push(setMeta('property', tag.property, tag.content));\n }\n }\n }\n\n return () => {\n for (const fn of cleanup) fn();\n };\n }, [depsKey]);\n}\n\n/**\n * Set or update a meta tag and return a cleanup function that removes it.\n */\nfunction escapeCssAttr(s: string): string {\n return s.replace(/[\"\\\\]/g, '\\\\$&');\n}\n\nfunction setMeta(attr: 'name' | 'property', key: string, content: string): () => void {\n const selector = `meta[${attr}=\"${escapeCssAttr(key)}\"]`;\n let el = document.querySelector(selector) as HTMLMetaElement | null;\n const existed = el !== null;\n const prevContent = el?.content;\n\n if (!el) {\n el = document.createElement('meta');\n el.setAttribute(attr, key);\n document.head.appendChild(el);\n }\n el.content = content;\n\n return () => {\n if (existed && prevContent !== undefined) {\n el!.content = prevContent;\n } else if (!existed) {\n el!.remove();\n }\n };\n}\n\n/**\n * Set or update an http-equiv meta tag and return a cleanup function.\n */\nfunction setHttpEquivMeta(httpEquiv: string, content: string): () => void {\n const selector = `meta[http-equiv=\"${escapeCssAttr(httpEquiv)}\"]`;\n let el = document.querySelector(selector) as HTMLMetaElement | null;\n const existed = el !== null;\n const prevContent = el?.content;\n\n if (!el) {\n el = document.createElement('meta');\n el.setAttribute('http-equiv', httpEquiv);\n document.head.appendChild(el);\n }\n el.content = content;\n\n return () => {\n if (existed && prevContent !== undefined) {\n el!.content = prevContent;\n } else if (!existed) {\n el!.remove();\n }\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;AA2BA,IAAI,oBAAuC;AAEpC,SAAS,gBAAgB,YAAqC;AACnE,sBAAoB;AACtB;AAMA,SAAS,oBAAgC;AACvC,MAAI,sBAAsB,MAAM;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,SACd,cAC6C;AAC7C,SAAO,kBAAkB,EAAE,SAAS,YAAY;AAClD;AAEO,SAAS,UAAU,QAAmC,MAAiC;AAC5F,SAAO,kBAAkB,EAAE,UAAU,QAAQ,IAAI;AACnD;AAEO,SAAS,WAAc,SAA4B;AACxD,SAAO,kBAAkB,EAAE,WAAW,OAAO;AAC/C;AAEO,SAAS,WACd,SACA,YACA,MAC0B;AAC1B,SAAO,kBAAkB,EAAE,WAAW,SAAS,YAAY,IAAI;AACjE;AAGO,SAA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C,aAAS,KAAK,YAAY,EAAE;AAAA,EAC9B;AACA,KAAG,UAAU;AAEb,SAAO,MAAM;AACX,QAAI,WAAW,gBAAgB,QAAW;AACxC,SAAI,UAAU;AAAA,IAChB,WAAW,CAAC,SAAS;AACnB,SAAI,OAAO;AAAA,IACb;AAAA,EACF;AACF;",
|
|
6
|
-
"names": ["head"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/shared/types.ts"],
|
|
4
|
-
"sourcesContent": ["// ============================================================================\n// SpecifyJS Core Types\n// ============================================================================\n// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\n/** Unique symbol to identify SpecifyJS elements */\nexport const SPEC_ELEMENT_TYPE = Symbol.for('spec.element');\nexport const SPEC_FRAGMENT_TYPE = Symbol.for('spec.fragment');\nexport const SPEC_PORTAL_TYPE = Symbol.for('spec.portal');\nexport const SPEC_PROVIDER_TYPE = Symbol.for('spec.provider');\nexport const SPEC_CONSUMER_TYPE = Symbol.for('spec.consumer');\nexport const SPEC_FORWARD_REF_TYPE = Symbol.for('spec.forward_ref');\nexport const SPEC_MEMO_TYPE = Symbol.for('spec.memo');\nexport const SPEC_LAZY_TYPE = Symbol.for('spec.lazy');\nexport const SPEC_SUSPENSE_TYPE = Symbol.for('spec.suspense');\nexport const SPEC_STRICT_MODE_TYPE = Symbol.for('spec.strict_mode');\nexport const SPEC_PROFILER_TYPE = Symbol.for('spec.profiler');\n\n/** A key used for reconciliation */\nexport type Key = string | number | null;\n\n/** A ref can be a callback, an object, or null */\nexport type Ref<T = unknown> = RefCallback<T> | RefObject<T> | null;\nexport type RefCallback<T> = (instance: T | null) => void;\nexport interface RefObject<T> {\n current: T | null;\n}\n\n/** Props are an arbitrary key-value map */\nexport type Props = Record<string, unknown> & {\n children?: SpecNode;\n key?: Key;\n ref?: Ref;\n};\n\n/** Valid child types in a SpecifyJS tree */\nexport type SpecChild = SpecElement | string | number | boolean | null | undefined;\nexport type SpecNode = SpecChild | SpecNode[];\n\n/** A functional component */\nexport type FunctionComponent<P extends Props = Props> = (props: P) => SpecNode;\n\n/** A class component constructor */\nexport interface ClassComponentConstructor<P extends Props = Props, S = unknown> {\n new (props: P): ClassComponentInstance<P, S>;\n getDerivedStateFromProps?(props: P, state: S): Partial<S> | null;\n getDerivedStateFromError?(error: unknown): Partial<S> | null;\n}\n\n/** Instance of a class component */\nexport interface ClassComponentInstance<P extends Props = Props, S = unknown> {\n props: P;\n state: S;\n setState(updater: Partial<S> | ((prevState: S, props: P) => Partial<S> | null)): void;\n forceUpdate(callback?: () => void): void;\n render(): SpecNode;\n componentDidMount?(): void;\n componentDidUpdate?(prevProps: P, prevState: S, snapshot?: unknown): void;\n componentWillUnmount?(): void;\n shouldComponentUpdate?(nextProps: P, nextState: S): boolean;\n getSnapshotBeforeUpdate?(prevProps: P, prevState: S): unknown;\n componentDidCatch?(error: unknown, info: ErrorInfo): void;\n // Internal: set by the reconciler for setState/forceUpdate wiring\n _fiber: unknown;\n _pendingState: Array<Partial<S> | ((prevState: S, props: P) => Partial<S> | null)>;\n _forceUpdate: boolean;\n _enqueueUpdate(callback?: () => void): void;\n}\n\nexport interface ErrorInfo {\n componentStack: string;\n}\n\n/** A component type can be a function, a class, or a special symbol type */\nexport type ComponentType<P extends Props = Props> =\n | FunctionComponent<P>\n | ClassComponentConstructor<P>\n | string\n | symbol;\n\n/** The core element structure \u2014 equivalent to React.Element */\nexport interface SpecElement<P extends Props = Props> {\n $$typeof: typeof SPEC_ELEMENT_TYPE;\n type: ComponentType<P>;\n props: P;\n key: Key;\n ref: Ref;\n}\n\n/** Fiber node types for the reconciler */\nexport const enum FiberTag {\n FunctionComponent = 0,\n ClassComponent = 1,\n HostRoot = 2,\n HostComponent = 3,\n HostText = 4,\n Fragment = 5,\n ContextProvider = 6,\n ContextConsumer = 7,\n ForwardRef = 8,\n MemoComponent = 9,\n LazyComponent = 10,\n SuspenseComponent = 11,\n Profiler = 12,\n Portal = 13,\n}\n\n/** Effect flags for fiber work */\nexport const enum EffectTag {\n NoEffect = 0,\n Placement = 1,\n Update = 2,\n Deletion = 4,\n ChildDeletion = 8,\n Snapshot = 16,\n Passive = 32,\n Layout = 64,\n Ref = 128,\n}\n\n/** Fiber node \u2014 the internal work unit */\nexport interface Fiber<P extends Props = Props> {\n tag: FiberTag;\n type: ComponentType<P> | null;\n key: Key;\n ref: Ref;\n\n stateNode: unknown;\n pendingProps: P;\n memoizedProps: P | null;\n memoizedState: unknown;\n\n return: Fiber | null;\n child: Fiber | null;\n sibling: Fiber | null;\n index: number;\n\n alternate: Fiber | null;\n effectTag: EffectTag;\n\n updateQueue: unknown;\n dependencies: unknown;\n\n lanes: number;\n childLanes: number;\n}\n\n/** Context type */\nexport interface SpecContext<T> {\n $$typeof: symbol;\n Provider: ComponentType;\n Consumer: ComponentType;\n _currentValue: T;\n _defaultValue: T;\n displayName?: string;\n}\n"],
|
|
5
|
-
"mappings": ";;;AAOO,IAAM,oBAAoB,OAAO,IAAI,cAAc;AACnD,IAAM,qBAAqB,OAAO,IAAI,eAAe;AACrD,IAAM,mBAAmB,OAAO,IAAI,aAAa;AACjD,IAAM,qBAAqB,OAAO,IAAI,eAAe;AACrD,IAAM,qBAAqB,OAAO,IAAI,eAAe;AACrD,IAAM,wBAAwB,OAAO,IAAI,kBAAkB;AAC3D,IAAM,iBAAiB,OAAO,IAAI,WAAW;AAC7C,IAAM,iBAAiB,OAAO,IAAI,WAAW;AAC7C,IAAM,qBAAqB,OAAO,IAAI,eAAe;AACrD,IAAM,wBAAwB,OAAO,IAAI,kBAAkB;AAC3D,IAAM,qBAAqB,OAAO,IAAI,eAAe;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/telemetry/metrics.ts"],
|
|
4
|
-
"sourcesContent": ["// ============================================================================\n// SpecifyJS Telemetry \u2014 Metrics (OpenTelemetry-compatible)\n// Zero third-party dependencies \u2014 OTEL protocols implemented from scratch.\n// ============================================================================\n// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport type { Span } from './tracing';\nimport { assertSecureUrl } from '../shared/secure-fetch';\n\n// ---------------------------------------------------------------------------\n// Metric data points\n// ---------------------------------------------------------------------------\n\nexport interface DataPoint {\n value: number;\n attributes: Record<string, string | number | boolean>;\n timestamp: number;\n}\n\n// ---------------------------------------------------------------------------\n// Instruments\n// ---------------------------------------------------------------------------\n\nexport interface Counter {\n readonly name: string;\n readonly description: string;\n /** Monotonically increment the counter. */\n add(value: number, attributes?: Record<string, string | number | boolean>): void;\n /** Read-only snapshot of data points. */\n readonly dataPoints: ReadonlyArray<DataPoint>;\n}\n\nexport interface Histogram {\n readonly name: string;\n readonly description: string;\n /** Record a measurement. */\n record(value: number, attributes?: Record<string, string | number | boolean>): void;\n /** Read-only snapshot of data points. */\n readonly dataPoints: ReadonlyArray<DataPoint>;\n}\n\nexport interface Gauge {\n readonly name: string;\n readonly description: string;\n /** Set the current value. */\n set(value: number, attributes?: Record<string, string | number | boolean>): void;\n /** Read-only snapshot of data points. */\n readonly dataPoints: ReadonlyArray<DataPoint>;\n}\n\nexport type Instrument = Counter | Histogram | Gauge;\n\nexport interface InstrumentOptions {\n description?: string;\n unit?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Instrument factories (internal)\n// ---------------------------------------------------------------------------\n\nconst MAX_DATA_POINTS = 10000;\n\nfunction addDataPoint(\n points: DataPoint[],\n value: number,\n attributes?: Record<string, string | number | boolean>,\n): void {\n if (points.length >= MAX_DATA_POINTS) {\n points.splice(0, Math.floor(MAX_DATA_POINTS / 2));\n }\n points.push({\n value,\n attributes: attributes ? { ...attributes } : {},\n timestamp: performance.now(),\n });\n}\n\nfunction createCounter(name: string, opts?: InstrumentOptions): Counter {\n const points: DataPoint[] = [];\n return {\n name,\n description: opts?.description ?? '',\n add(value: number, attributes?: Record<string, string | number | boolean>): void {\n if (value < 0) return; // counters are monotonic\n addDataPoint(points, value, attributes);\n },\n get dataPoints(): ReadonlyArray<DataPoint> {\n return points;\n },\n };\n}\n\nfunction createHistogram(name: string, opts?: InstrumentOptions): Histogram {\n const points: DataPoint[] = [];\n return {\n name,\n description: opts?.description ?? '',\n record(value: number, attributes?: Record<string, string | number | boolean>): void {\n addDataPoint(points, value, attributes);\n },\n get dataPoints(): ReadonlyArray<DataPoint> {\n return points;\n },\n };\n}\n\nfunction createGauge(name: string, opts?: InstrumentOptions): Gauge {\n const points: DataPoint[] = [];\n return {\n name,\n description: opts?.description ?? '',\n set(value: number, attributes?: Record<string, string | number | boolean>): void {\n addDataPoint(points, value, attributes);\n },\n get dataPoints(): ReadonlyArray<DataPoint> {\n return points;\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// MeterProvider\n// ---------------------------------------------------------------------------\n\nexport interface MeterProviderConfig {\n serviceName: string;\n endpoint?: string;\n headers?: Record<string, string>;\n exportInterval?: number;\n}\n\nexport interface MeterProvider {\n counter(name: string, opts?: InstrumentOptions): Counter;\n histogram(name: string, opts?: InstrumentOptions): Histogram;\n gauge(name: string, opts?: InstrumentOptions): Gauge;\n /** Export all instrument data to the configured endpoint. */\n flush(): Promise<void>;\n /** Read-only access to all registered instruments. */\n readonly instruments: ReadonlyArray<Instrument>;\n readonly config: Readonly<MeterProviderConfig>;\n}\n\nexport function createMeterProvider(config: MeterProviderConfig): MeterProvider {\n const instruments: Instrument[] = [];\n\n let exportTimer: ReturnType<typeof setInterval> | undefined;\n /* v8 ignore start -- timer setup requires real interval environment */\n if (config.exportInterval && config.exportInterval > 0) {\n exportTimer = setInterval(() => {\n void provider.flush();\n }, config.exportInterval);\n if (typeof exportTimer === 'object' && 'unref' in exportTimer) {\n (exportTimer as { unref: () => void }).unref();\n }\n }\n /* v8 ignore stop */\n\n const provider: MeterProvider = {\n config,\n\n get instruments(): ReadonlyArray<Instrument> {\n return instruments;\n },\n\n counter(name: string, opts?: InstrumentOptions): Counter {\n const c = createCounter(name, opts);\n instruments.push(c);\n return c;\n },\n\n histogram(name: string, opts?: InstrumentOptions): Histogram {\n const h = createHistogram(name, opts);\n instruments.push(h);\n return h;\n },\n\n gauge(name: string, opts?: InstrumentOptions): Gauge {\n const g = createGauge(name, opts);\n instruments.push(g);\n return g;\n },\n\n async flush(): Promise<void> {\n if (!config.endpoint) return;\n\n const body = formatOtlpMetrics(instruments, config.serviceName);\n await exportToEndpoint(config.endpoint, config.headers ?? {}, body);\n },\n };\n\n return provider;\n}\n\n// ---------------------------------------------------------------------------\n// OTLP JSON export helpers\n// ---------------------------------------------------------------------------\n\n/** Attributes to the OTLP key-value array format. */\nfunction toOtlpAttributes(\n attrs: Record<string, string | number | boolean>,\n): Array<{ key: string; value: { stringValue?: string; intValue?: number; boolValue?: boolean } }> {\n return Object.entries(attrs).map(([key, val]) => {\n if (typeof val === 'string') return { key, value: { stringValue: val } };\n if (typeof val === 'boolean') return { key, value: { boolValue: val } };\n return { key, value: { intValue: val } };\n });\n}\n\n/** Convert a `performance.now()` timestamp to nanoseconds (OTLP convention). */\nfunction toNanos(ms: number): string {\n return String(Math.round(ms * 1_000_000));\n}\n\n/**\n * Build an OTLP-compatible JSON payload for metrics.\n *\n * Structure follows the OTLP/HTTP JSON proto mapping:\n * https://opentelemetry.io/docs/specs/otlp/#otlphttp\n */\nexport function formatOtlpMetrics(\n instruments: ReadonlyArray<Instrument>,\n serviceName?: string,\n): Record<string, unknown> {\n const metrics = instruments.map((inst) => {\n const dataPoints = inst.dataPoints.map((dp) => ({\n attributes: toOtlpAttributes(dp.attributes),\n timeUnixNano: toNanos(dp.timestamp),\n asDouble: dp.value,\n }));\n\n // Determine metric type heuristic: counters have `add`, histograms have\n // `record`, gauges have `set`.\n let metricData: Record<string, unknown>;\n if ('add' in inst) {\n metricData = { sum: { dataPoints, isMonotonic: true, aggregationTemporality: 2 } };\n } else if ('record' in inst) {\n metricData = { histogram: { dataPoints, aggregationTemporality: 2 } };\n } else {\n metricData = { gauge: { dataPoints } };\n }\n\n return {\n name: inst.name,\n description: inst.description,\n ...metricData,\n };\n });\n\n return {\n resourceMetrics: [\n {\n resource: {\n attributes: toOtlpAttributes({\n 'service.name': serviceName ?? 'unknown',\n }),\n },\n scopeMetrics: [\n {\n scope: { name: 'specifyjs-telemetry', version: '1.0.0' },\n metrics,\n },\n ],\n },\n ],\n };\n}\n\n/**\n * Build an OTLP-compatible JSON payload for traces/spans.\n */\nexport function formatOtlpTraces(\n spans: ReadonlyArray<Span>,\n serviceName?: string,\n serviceVersion?: string,\n): Record<string, unknown> {\n const resourceAttrs: Record<string, string> = {\n 'service.name': serviceName ?? 'unknown',\n };\n if (serviceVersion) {\n resourceAttrs['service.version'] = serviceVersion;\n }\n\n const SPAN_KIND_MAP: Record<string, number> = {\n internal: 1,\n server: 2,\n client: 3,\n producer: 4,\n consumer: 5,\n };\n\n const STATUS_CODE_MAP: Record<string, number> = {\n unset: 0,\n ok: 1,\n error: 2,\n };\n\n const otlpSpans = spans.map((s) => ({\n traceId: s.traceId,\n spanId: s.spanId,\n parentSpanId: s.parentSpanId ?? '',\n name: s.name,\n kind: SPAN_KIND_MAP[s.kind] ?? 1,\n startTimeUnixNano: toNanos(s.startTime),\n endTimeUnixNano: s.endTime !== undefined ? toNanos(s.endTime) : '0',\n attributes: toOtlpAttributes(s.attributes),\n status: {\n code: STATUS_CODE_MAP[s.status.code] ?? 0,\n message: s.status.message ?? '',\n },\n events: s.events.map((e) => ({\n name: e.name,\n timeUnixNano: toNanos(e.timestamp),\n attributes: e.attributes ? toOtlpAttributes(e.attributes) : [],\n })),\n }));\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: toOtlpAttributes(resourceAttrs),\n },\n scopeSpans: [\n {\n scope: { name: 'specifyjs-telemetry', version: '1.0.0' },\n spans: otlpSpans,\n },\n ],\n },\n ],\n };\n}\n\n/**\n * Send a JSON payload to an OTLP-compatible endpoint via `fetch`.\n */\nexport async function exportToEndpoint(\n url: string,\n headers: Record<string, string>,\n body: Record<string, unknown>,\n): Promise<void> {\n try {\n assertSecureUrl(url);\n await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n body: JSON.stringify(body),\n });\n } catch {\n // Telemetry export failures are silently ignored so they never break\n // application code.\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;AA8DA,IAAM,kBAAkB;AAExB,SAAS,aACP,QACA,OACA,YACM;AACN,MAAI,OAAO,UAAU,iBAAiB;AACpC,WAAO,OAAO,GAAG,KAAK,MAAM,kBAAkB,CAAC,CAAC;AAAA,EAClD;AACA,SAAO,KAAK;AAAA,IACV;AAAA,IACA,YAAY,aAAa,EAAE,GAAG,WAAW,IAAI,CAAC;AAAA,IAC9C,WAAW,YAAY,IAAI;AAAA,EAC7B,CAAC;AACH;AAEA,SAAS,cAAc,MAAc,MAAmC;AACtE,QAAM,SAAsB,CAAC;AAC7B,SAAO;AAAA,IACL;AAAA,IACA,aAAa,MAAM,eAAe;AAAA,IAClC,IAAI,OAAe,YAA8D;AAC/E,UAAI,QAAQ,EAAG;AACf,mBAAa,QAAQ,OAAO,UAAU;AAAA,IACxC;AAAA,IACA,IAAI,aAAuC;AACzC,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,SAAS,gBAAgB,MAAc,MAAqC;AAC1E,QAAM,SAAsB,CAAC;AAC7B,SAAO;AAAA,IACL;AAAA,IACA,aAAa,MAAM,eAAe;AAAA,IAClC,OAAO,OAAe,YAA8D;AAClF,mBAAa,QAAQ,OAAO,UAAU;AAAA,IACxC;AAAA,IACA,IAAI,aAAuC;AACzC,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,SAAS,YAAY,MAAc,MAAiC;AAClE,QAAM,SAAsB,CAAC;AAC7B,SAAO;AAAA,IACL;AAAA,IACA,aAAa,MAAM,eAAe;AAA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,MAAI;AACF,oBAAgB,GAAG;AACnB,UAAM,MAAM,KAAK;AAAA,MACf,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,GAAG;AAAA,MACL;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAAA,EACH,QAAQ;AAAA,EAGR;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/core/create-element.ts", "../../../src/core/fragment.ts"],
|
|
4
|
-
"sourcesContent": ["// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport {\n SPEC_ELEMENT_TYPE,\n type SpecElement,\n type ComponentType,\n type Props,\n type Key,\n type Ref,\n} from '../shared/types';\n\n/**\n * Creates a SpecifyJS element (virtual DOM node).\n * Equivalent to React.createElement.\n */\nexport function createElement<P extends Props>(\n type: ComponentType<P>,\n config: (Omit<P, 'children'> & { key?: Key; ref?: Ref }) | null,\n ...children: unknown[]\n): SpecElement<P> {\n let key: Key = null;\n let ref: Ref = null;\n const props: Record<string, unknown> = {};\n\n if (config != null) {\n if (config.key !== undefined) {\n key = '' + config.key;\n }\n if (config.ref !== undefined) {\n ref = config.ref as Ref;\n }\n\n for (const propName in config) {\n if (\n Object.prototype.hasOwnProperty.call(config, propName) &&\n propName !== 'key' &&\n propName !== 'ref' &&\n propName !== '__proto__' &&\n propName !== 'constructor' &&\n propName !== 'prototype'\n ) {\n props[propName] = (config as Record<string, unknown>)[propName];\n }\n }\n }\n\n if (children.length === 1) {\n props.children = children[0];\n } else if (children.length > 1) {\n props.children = children;\n }\n\n // Apply default props for component types\n if (\n typeof type === 'function' &&\n (type as unknown as { defaultProps?: Partial<P> }).defaultProps\n ) {\n const defaultProps = (type as unknown as { defaultProps: Partial<P> }).defaultProps;\n for (const propName of Object.keys(defaultProps)) {\n if (propName !== '__proto__' && propName !== 'constructor' && props[propName] === undefined) {\n props[propName] = defaultProps[propName as keyof typeof defaultProps];\n }\n }\n }\n\n return {\n $$typeof: SPEC_ELEMENT_TYPE,\n type,\n props: props as P,\n key,\n ref,\n };\n}\n\n/**\n * Creates a factory function for producing elements of a given type.\n * Legacy API \u2014 equivalent to React.createFactory.\n *\n * @deprecated Use createElement directly or JSX instead.\n */\nexport function createFactory<P extends Props>(\n type: ComponentType<P>,\n): (\n config?: (Omit<P, 'children'> & { key?: Key; ref?: Ref }) | null,\n ...children: unknown[]\n) => SpecElement<P> {\n return (config, ...children) => createElement(type, config ?? null, ...children);\n}\n", "// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport { SPEC_FRAGMENT_TYPE } from '../shared/types';\n\n/**\n * Fragment allows grouping children without adding extra DOM nodes.\n * Usage: <Fragment>...</Fragment> or <>...</>\n */\nexport const Fragment: symbol = SPEC_FRAGMENT_TYPE;\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAgBO,SAAS,cACd,MACA,WACG,UACa;AAChB,MAAI,MAAW;AACf,MAAI,MAAW;AACf,QAAM,QAAiC,CAAC;AAExC,MAAI,UAAU,MAAM;AAClB,QAAI,OAAO,QAAQ,QAAW;AAC5B,YAAM,KAAK,OAAO;AAAA,IACpB;AACA,QAAI,OAAO,QAAQ,QAAW;AAC5B,YAAM,OAAO;AAAA,IACf;AAEA,eAAW,YAAY,QAAQ;AAC7B,UACE,OAAO,UAAU,eAAe,KAAK,QAAQ,QAAQ,KACrD,aAAa,SACb,aAAa,SACb,aAAa,eACb,aAAa,iBACb,aAAa,aACb;AACA,cAAM,QAAQ,IAAK,OAAmC,QAAQ;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AAEA,MAAI,SAAS,WAAW,GAAG;AACzB,UAAM,WAAW,SAAS,CAAC;AAAA,EAC7B,WAAW,SAAS,SAAS,GAAG;AAC9B,UAAM,WAAW;AAAA,EACnB;AAGA,MACE,OAAO,SAAS,cACf,KAAkD,cACnD;AACA,UAAM,eAAgB,KAAiD;AACvE,eAAW,YAAY,OAAO,KAAK,YAAY,GAAG;AAChD,UAAI,aAAa,eAAe,aAAa,iBAAiB,MAAM,QAAQ,MAAM,QAAW;AAC3F,cAAM,QAAQ,IAAI,aAAa,QAAqC;AAAA,MACtE;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAQO,SAAS,cACd,MAIkB;AAClB,SAAO,CAAC,WAAW,aAAa,cAAc,MAAM,UAAU,MAAM,GAAG,QAAQ;AACjF;;;AC/EO,IAAM,WAAmB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/core/is-valid-element.ts"],
|
|
4
|
-
"sourcesContent": ["// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport { SPEC_ELEMENT_TYPE, type SpecElement } from '../shared/types';\n\n/**\n * Checks if a value is a valid SpecifyJS element.\n * Equivalent to React.isValidElement.\n */\nexport function isValidElement(object: unknown): object is SpecElement {\n return (\n typeof object === 'object' &&\n object !== null &&\n (object as SpecElement).$$typeof === SPEC_ELEMENT_TYPE\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;AASO,SAAS,eAAe,QAAwC;AACrE,SACE,OAAO,WAAW,YAClB,WAAW,QACV,OAAuB,aAAa;AAEzC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/jsx-runtime.ts"],
|
|
4
|
-
"sourcesContent": ["// ============================================================================\n// SpecifyJS JSX Runtime (automatic transform)\n// ============================================================================\n// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport { createElement } from './core/create-element';\nimport { Fragment } from './core/fragment';\nimport type { Props, Key, ComponentType, SpecElement } from './shared/types';\n\nexport { Fragment };\n\nexport function jsx<P extends Props>(\n type: ComponentType<P>,\n config: P & { key?: Key },\n maybeKey?: Key,\n): SpecElement<P> {\n const key = maybeKey !== undefined ? maybeKey : config.key !== undefined ? config.key : null;\n const { key: _key, ...props } = config;\n const configWithKey = key !== null ? { ...props, key } : props;\n return createElement(type, configWithKey as unknown as P);\n}\n\nexport { jsx as jsxs };\n"],
|
|
5
|
-
"mappings": ";;;;;;AAYO,SAAS,IACd,MACA,QACA,UACgB;AAChB,QAAM,MAAM,aAAa,SAAY,WAAW,OAAO,QAAQ,SAAY,OAAO,MAAM;AACxF,QAAM,EAAE,KAAK,MAAM,GAAG,MAAM,IAAI;AAChC,QAAM,gBAAgB,QAAQ,OAAO,EAAE,GAAG,OAAO,IAAI,IAAI;AACzD,SAAO,cAAc,MAAM,aAA6B;AAC1D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/build/index.ts", "../src/build/seo-plugin.ts", "../src/build/noscript-plugin.ts"],
|
|
4
|
-
"sourcesContent": ["// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nexport { specifyJsSeoPlugin } from './seo-plugin';\nexport type { SeoPluginConfig } from './seo-plugin';\nexport {\n specifyJsNoscriptPlugin,\n generateNoscriptHtml,\n stripInteractiveElements,\n} from './noscript-plugin';\nexport type { NoscriptPluginConfig, NoscriptSection } from './noscript-plugin';\n", "// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\n/**\n * SpecifyJS SEO Plugin for Vite\n * Auto-generates sitemap.xml, robots.txt, and llms.txt at build time.\n *\n * Usage in vite.config.ts:\n * import { specifyJsSeoPlugin } from '@asymmetric-effort/specifyjs/build';\n * export default defineConfig({ plugins: [specifyJsSeoPlugin({ ... })] });\n */\n\nimport type { Plugin } from 'vite';\nimport fs from 'fs';\nimport path from 'path';\n\nexport interface SeoPluginConfig {\n /** Base URL of the site (e.g., 'https://example.com') */\n siteUrl: string;\n /** Site title for llms.txt */\n title?: string;\n /** Site description for llms.txt */\n description?: string;\n /** Hash-based routes to include in sitemap */\n routes?: string[];\n /** Path to docs directory (generates doc routes in sitemap) */\n docsDir?: string;\n /** npm package name for llms.txt install instructions */\n npmPackage?: string;\n /** Author name for llms.txt */\n author?: string;\n /** License for llms.txt */\n license?: string;\n /** Additional robots.txt rules */\n robotsRules?: string[];\n /** Repository URL for llms.txt */\n repository?: string;\n /** Schema.org structured data (JSON-LD). When provided, a\n * `<script type=\"application/ld+json\">` block is injected into index.html.\n * Can be a plain object or an array of objects for multiple schemas. */\n jsonLd?: Record<string, unknown> | Record<string, unknown>[];\n}\n\n/**\n * Iteratively walk a directory and collect markdown file paths (without .md extension).\n * Uses an explicit stack instead of recursion per project coding standards.\n */\nfunction walkDocs(rootDir: string, results: string[]): void {\n const stack: Array<{ dir: string; prefix: string }> = [{ dir: rootDir, prefix: '' }];\n while (stack.length > 0) {\n const { dir, prefix } = stack.pop()!;\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n stack.push({ dir: path.join(dir, entry.name), prefix: prefix + entry.name + '/' });\n } else if (entry.name.endsWith('.md')) {\n results.push(prefix + entry.name.replace('.md', ''));\n }\n }\n }\n}\n\n/**\n * Generate sitemap.xml content from a list of routes.\n */\nfunction generateSitemap(siteUrl: string, routes: string[], today: string): string {\n const sitemapEntries = routes.map(\n (r) => ` <url><loc>${siteUrl}${r}</loc><lastmod>${today}</lastmod></url>`,\n );\n return [\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">',\n ...sitemapEntries,\n '</urlset>',\n ].join('\\n');\n}\n\n/**\n * Generate robots.txt content.\n */\nfunction generateRobots(siteUrl: string, extraRules?: string[]): string {\n const lines = ['User-agent: *', 'Allow: /'];\n if (extraRules) {\n lines.push(...extraRules);\n }\n lines.push('', `Sitemap: ${siteUrl}/sitemap.xml`);\n return lines.join('\\n');\n}\n\n/**\n * Generate llms.txt content with project metadata and doc links.\n */\nfunction generateLlmsTxt(config: SeoPluginConfig, docPaths: string[]): string {\n const title = config.title ?? 'Site';\n const lines: string[] = [`# ${title}`];\n\n if (config.description) {\n lines.push('');\n const descLines = config.description.split('\\n');\n for (const dl of descLines) {\n lines.push(`> ${dl}`);\n }\n }\n\n lines.push('');\n lines.push(`## Website: ${config.siteUrl}`);\n if (config.repository) {\n lines.push(`## Repository: ${config.repository}`);\n }\n if (config.npmPackage) {\n lines.push(`## npm: https://www.npmjs.com/package/${config.npmPackage}`);\n }\n\n // Documentation section\n const guideNames = docPaths\n .filter((p) => p.startsWith('guides/'))\n .map((p) => p.replace('guides/', ''));\n const apiNames = docPaths.filter((p) => p.startsWith('api/')).map((p) => p.replace('api/', ''));\n\n if (guideNames.length > 0) {\n lines.push('', '## Documentation', '');\n for (const g of guideNames) {\n lines.push(`- ${g}: ${config.siteUrl}/#/docs/guides/${g}`);\n }\n }\n\n if (apiNames.length > 0) {\n lines.push('', '## API Reference', '');\n for (const a of apiNames) {\n lines.push(`- ${a}: ${config.siteUrl}/#/docs/api/${a}`);\n }\n }\n\n if (config.npmPackage) {\n lines.push('', '## Install', '', '```', `npm install ${config.npmPackage}`, '```');\n }\n\n if (config.license) {\n lines.push('', `## License: ${config.license}`);\n }\n if (config.author) {\n lines.push(`## Author: ${config.author}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Create the SpecifyJS SEO Vite plugin.\n *\n * Generates sitemap.xml, robots.txt, and llms.txt in the build output directory\n * during the closeBundle hook.\n */\nexport function specifyJsSeoPlugin(config: SeoPluginConfig): Plugin {\n return {\n name: 'specifyjs-seo',\n closeBundle() {\n const distDir = path.resolve(process.cwd(), 'dist');\n const today = new Date().toISOString().split('T')[0] ?? '';\n\n // Collect routes\n const routes = [...(config.routes ?? ['/'])];\n\n // Collect doc routes from docsDir\n const docPaths: string[] = [];\n if (config.docsDir && fs.existsSync(config.docsDir)) {\n walkDocs(config.docsDir, docPaths);\n for (const dp of docPaths) {\n routes.push(`/#/docs/${dp}`);\n }\n }\n\n // Generate and write sitemap.xml\n const sitemap = generateSitemap(config.siteUrl, routes, today);\n fs.writeFileSync(path.join(distDir, 'sitemap.xml'), sitemap);\n\n // Generate and write robots.txt\n const robots = generateRobots(config.siteUrl, config.robotsRules);\n fs.writeFileSync(path.join(distDir, 'robots.txt'), robots);\n\n // Generate and write llms.txt\n const llmsTxt = generateLlmsTxt(config, docPaths);\n fs.writeFileSync(path.join(distDir, 'llms.txt'), llmsTxt);\n\n /* v8 ignore start -- JSON-LD injection uses fs in Vite closeBundle */\n // Inject JSON-LD structured data into index.html\n if (config.jsonLd) {\n const indexPath = path.join(distDir, 'index.html');\n if (fs.existsSync(indexPath)) {\n let html = fs.readFileSync(indexPath, 'utf-8');\n const schemas = Array.isArray(config.jsonLd) ? config.jsonLd : [config.jsonLd];\n const ldBlocks = schemas\n .map((s) => `<script type=\"application/ld+json\">${JSON.stringify(s)}</script>`)\n .join('\\n ');\n html = html.replace('</head>', ` ${ldBlocks}\\n </head>`);\n fs.writeFileSync(indexPath, html, 'utf-8');\n }\n }\n\n /* v8 ignore stop */\n const extras = config.jsonLd ? ', JSON-LD' : '';\n console.log(`Generated: sitemap.xml (${routes.length} URLs), robots.txt, llms.txt${extras}`);\n },\n };\n}\n", "// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\n/**\n * SpecifyJS Noscript Plugin for Vite\n *\n * Generates a `<noscript>` fallback block inside the built index.html,\n * providing a fully navigable static HTML document for environments\n * where JavaScript is disabled (accessibility) or not executed\n * (search engine crawlers).\n *\n * The noscript content is a single long-form document with:\n * - A navigation bar with anchor links to each section\n * - Each section rendered as semantic HTML (headings, paragraphs, lists)\n * - Internal links mapped to `#section-id` anchors\n *\n * Usage in vite.config.ts:\n * import { specifyJsNoscriptPlugin } from 'specifyjs/build';\n * export default defineConfig({\n * plugins: [\n * specifyJsNoscriptPlugin({\n * title: 'My App',\n * sections: [\n * { id: 'home', title: 'Home', html: '<h1>Welcome</h1><p>...</p>' },\n * { id: 'docs', title: 'Docs', html: '<h2>Getting Started</h2>...' },\n * ],\n * }),\n * ],\n * });\n */\n\nimport type { Plugin } from 'vite';\nimport fs from 'fs';\nimport path from 'path';\n\n// ---------------------------------------------------------------------------\n// Configuration\n// ---------------------------------------------------------------------------\n\nexport interface NoscriptSection {\n /** Anchor ID (used in href=\"#id\" links) */\n id: string;\n /** Display title in the navigation bar */\n title: string;\n /** Static HTML content for this section.\n * Can include headings, paragraphs, lists, tables, code blocks, images.\n * Interactive elements (buttons, inputs) are stripped automatically. */\n html: string;\n}\n\nexport interface NoscriptPluginConfig {\n /** Page title shown at the top of the noscript document */\n title?: string;\n /** Subtitle / description shown below the title */\n description?: string;\n /** Sections to render in the noscript block */\n sections: NoscriptSection[];\n /** Copyright notice shown at the bottom */\n copyright?: string;\n /** CSS class prefix for noscript elements (default: 'ns') */\n classPrefix?: string;\n /** Maximum content length in bytes before truncation warning (default: 512KB) */\n maxContentSize?: number;\n}\n\n// ---------------------------------------------------------------------------\n// HTML sanitization\n// ---------------------------------------------------------------------------\n\n/**\n * Allowed HTML tags for noscript content.\n * Only these tags are preserved \u2014 everything else is stripped.\n * This whitelist approach avoids the inherent insecurity of\n * regex-based blocklist sanitization (no bypasses possible).\n */\nconst ALLOWED_TAGS = new Set([\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'p',\n 'br',\n 'hr',\n 'blockquote',\n 'ul',\n 'ol',\n 'li',\n 'dl',\n 'dt',\n 'dd',\n 'table',\n 'thead',\n 'tbody',\n 'tfoot',\n 'tr',\n 'th',\n 'td',\n 'caption',\n 'a',\n 'strong',\n 'em',\n 'b',\n 'i',\n 'u',\n 's',\n 'code',\n 'pre',\n 'kbd',\n 'samp',\n 'span',\n 'div',\n 'section',\n 'article',\n 'aside',\n 'header',\n 'footer',\n 'nav',\n 'img',\n 'figure',\n 'figcaption',\n 'picture',\n 'source',\n 'details',\n 'summary',\n 'mark',\n 'small',\n 'sub',\n 'sup',\n 'abbr',\n 'time',\n]);\n\n/** Tags whose content is removed entirely (not just the tag itself) */\nconst CONTENT_BLOCK_TAGS = new Set([\n 'script',\n 'style',\n 'textarea',\n 'select',\n 'noscript',\n 'iframe',\n 'object',\n 'embed',\n 'applet',\n]);\n\n/** Allowed attributes (no event handlers, no javascript: URIs) */\nconst ALLOWED_ATTRS = new Set([\n 'href',\n 'src',\n 'alt',\n 'title',\n 'width',\n 'height',\n 'class',\n 'id',\n 'name',\n 'colspan',\n 'rowspan',\n 'scope',\n 'rel',\n 'target',\n 'lang',\n 'dir',\n 'role',\n 'aria-label',\n 'aria-describedby',\n 'aria-hidden',\n 'style', // style is allowed but javascript: URIs within it are stripped\n]);\n\n/**\n * Strip interactive elements from HTML using a whitelist approach.\n * Only allowed tags with allowed attributes are kept. All other\n * tags are removed (their text content is preserved). This is\n * immune to regex bypass attacks because unknown tags are never\n * emitted \u2014 they're simply not in the whitelist.\n */\nexport function stripInteractiveElements(html: string): string {\n // Parse tags iteratively \u2014 no regex on untrusted HTML structure\n const out: string[] = [];\n let i = 0;\n const len = html.length;\n\n while (i < len) {\n const ltIdx = html.indexOf('<', i);\n if (ltIdx === -1) {\n // No more tags \u2014 emit remaining text\n out.push(html.slice(i));\n break;\n }\n\n // Emit text before the tag\n if (ltIdx > i) out.push(html.slice(i, ltIdx));\n\n // Find end of tag\n const gtIdx = html.indexOf('>', ltIdx);\n if (gtIdx === -1) {\n // Unclosed tag \u2014 emit as text\n out.push(html.slice(ltIdx));\n break;\n }\n\n const tagContent = html.slice(ltIdx + 1, gtIdx);\n const isClosing = tagContent.startsWith('/');\n const tagBody = isClosing ? tagContent.slice(1).trim() : tagContent.trim();\n\n // Extract tag name (first word)\n const spaceIdx = tagBody.search(/[\\s/]/);\n const tagName = (spaceIdx === -1 ? tagBody : tagBody.slice(0, spaceIdx)).toLowerCase();\n\n if (ALLOWED_TAGS.has(tagName)) {\n if (isClosing) {\n out.push(`</${tagName}>`);\n } else {\n // Rebuild tag with only allowed attributes\n const attrStr = spaceIdx === -1 ? '' : tagBody.slice(spaceIdx);\n const safeAttrs = filterAttributes(attrStr);\n const selfClose = tagContent.trimEnd().endsWith('/') ? ' /' : '';\n out.push(`<${tagName}${safeAttrs}${selfClose}>`);\n }\n } else if (!isClosing && CONTENT_BLOCK_TAGS.has(tagName)) {\n // Blocked tags whose CONTENT must also be removed (script, textarea, select, style)\n // Skip everything until the matching closing tag\n const closeTag = `</${tagName}`;\n const closeIdx = html.toLowerCase().indexOf(closeTag, gtIdx + 1);\n if (closeIdx !== -1) {\n const closeGt = html.indexOf('>', closeIdx);\n i = closeGt !== -1 ? closeGt + 1 : gtIdx + 1;\n continue;\n }\n }\n // else: tag not in whitelist \u2014 silently dropped (text content preserved)\n\n i = gtIdx + 1;\n }\n\n return out.join('');\n}\n\n/** Filter attributes: keep only whitelisted, strip javascript: URIs */\nfunction filterAttributes(attrString: string): string {\n const result: string[] = [];\n // Match attr=\"value\" or attr='value' or attr=value or standalone attr\n const attrRegex = /([a-z][a-z0-9-]*)\\s*(?:=\\s*(?:\"([^\"]*)\"|'([^']*)'|(\\S+)))?/gi;\n let match: RegExpExecArray | null;\n while ((match = attrRegex.exec(attrString)) !== null) {\n const name = match[1]!.toLowerCase();\n const value = match[2] ?? match[3] ?? match[4] ?? '';\n if (!ALLOWED_ATTRS.has(name)) continue;\n // Block javascript: URIs in href/src/style\n if (/javascript\\s*:/i.test(value)) continue;\n result.push(` ${name}=\"${escapeAttrValue(value)}\"`);\n }\n return result.join('');\n}\n\nfunction escapeAttrValue(val: string): string {\n return val\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\n// ---------------------------------------------------------------------------\n// Noscript HTML generation\n// ---------------------------------------------------------------------------\n\nexport function generateNoscriptHtml(config: NoscriptPluginConfig): string {\n const prefix = config.classPrefix ?? 'ns';\n const sections = config.sections;\n\n if (sections.length === 0) return '';\n\n // Navigation bar\n const navLinks = sections\n .map((s) => `<a href=\"#${s.id}\" class=\"${prefix}-nav-link\">${escapeHtml(s.title)}</a>`)\n .join('\\n ');\n\n // Section blocks\n const sectionBlocks = sections\n .map((s) => {\n const cleanHtml = stripInteractiveElements(s.html);\n return `\n <section id=\"${s.id}\" class=\"${prefix}-section\">\n <h2 class=\"${prefix}-section-title\">${escapeHtml(s.title)}</h2>\n <div class=\"${prefix}-section-content\">\n ${cleanHtml}\n </div>\n <p class=\"${prefix}-back-to-top\"><a href=\"#${prefix}-top\">Back to top</a></p>\n </section>`;\n })\n .join('\\n');\n\n const title = config.title ? `<h1 class=\"${prefix}-title\">${escapeHtml(config.title)}</h1>` : '';\n const desc = config.description\n ? `<p class=\"${prefix}-desc\">${escapeHtml(config.description)}</p>`\n : '';\n const copyright = config.copyright\n ? `<footer class=\"${prefix}-footer\"><p>${escapeHtml(config.copyright)}</p></footer>`\n : '';\n\n return `\n <noscript>\n <style>\n .${prefix}-container {\n max-width: 900px;\n margin: 0 auto;\n padding: 20px;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n line-height: 1.6;\n color: #1f2937;\n }\n .${prefix}-title {\n font-size: 2rem;\n margin-bottom: 0.5rem;\n color: #0f172a;\n }\n .${prefix}-desc {\n font-size: 1.1rem;\n color: #64748b;\n margin-bottom: 1.5rem;\n }\n .${prefix}-nav {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 0;\n border-bottom: 1px solid #e2e8f0;\n margin-bottom: 2rem;\n position: sticky;\n top: 0;\n background: white;\n z-index: 10;\n }\n .${prefix}-nav-link {\n padding: 6px 14px;\n border-radius: 6px;\n background: #f1f5f9;\n color: #3b82f6;\n text-decoration: none;\n font-size: 14px;\n font-weight: 500;\n }\n .${prefix}-nav-link:hover {\n background: #3b82f6;\n color: white;\n }\n .${prefix}-section {\n margin-bottom: 3rem;\n padding-bottom: 2rem;\n border-bottom: 1px solid #f1f5f9;\n }\n .${prefix}-section-title {\n font-size: 1.5rem;\n color: #1e293b;\n margin-bottom: 1rem;\n padding-top: 1rem;\n }\n .${prefix}-section-content h3 {\n font-size: 1.2rem;\n margin-top: 1.5rem;\n color: #334155;\n }\n .${prefix}-section-content p {\n margin: 0.5rem 0;\n }\n .${prefix}-section-content pre {\n background: #1e293b;\n color: #e2e8f0;\n padding: 12px 16px;\n border-radius: 6px;\n overflow-x: auto;\n font-size: 13px;\n line-height: 1.5;\n }\n .${prefix}-section-content code {\n background: #f1f5f9;\n padding: 2px 6px;\n border-radius: 3px;\n font-size: 0.9em;\n }\n .${prefix}-section-content pre code {\n background: none;\n padding: 0;\n }\n .${prefix}-section-content table {\n width: 100%;\n border-collapse: collapse;\n margin: 1rem 0;\n }\n .${prefix}-section-content th,\n .${prefix}-section-content td {\n padding: 8px 12px;\n border: 1px solid #e2e8f0;\n text-align: left;\n }\n .${prefix}-section-content th {\n background: #f8fafc;\n font-weight: 600;\n }\n .${prefix}-section-content img {\n max-width: 100%;\n height: auto;\n }\n .${prefix}-back-to-top {\n font-size: 13px;\n margin-top: 1.5rem;\n }\n .${prefix}-back-to-top a {\n color: #3b82f6;\n text-decoration: none;\n }\n .${prefix}-footer {\n margin-top: 3rem;\n padding-top: 1rem;\n border-top: 1px solid #e2e8f0;\n color: #94a3b8;\n font-size: 13px;\n text-align: center;\n }\n .${prefix}-js-notice {\n background: #fef3c7;\n border: 1px solid #f59e0b;\n border-radius: 6px;\n padding: 12px 16px;\n margin-bottom: 1.5rem;\n font-size: 14px;\n color: #92400e;\n }\n </style>\n <div id=\"${prefix}-top\" class=\"${prefix}-container\">\n ${title}\n ${desc}\n <div class=\"${prefix}-js-notice\">\n This page works best with JavaScript enabled. You are viewing a\n static version of the content.\n </div>\n <nav class=\"${prefix}-nav\" aria-label=\"Section navigation\">\n ${navLinks}\n </nav>\n ${sectionBlocks}\n ${copyright}\n </div>\n </noscript>`;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction escapeHtml(str: string): string {\n return str\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n}\n\n// ---------------------------------------------------------------------------\n// Vite Plugin\n// ---------------------------------------------------------------------------\n\nexport function specifyJsNoscriptPlugin(config: NoscriptPluginConfig): Plugin {\n return {\n name: 'specifyjs-noscript',\n /* v8 ignore start -- Vite closeBundle hook runs at build time, not in jsdom tests */\n closeBundle() {\n const distDir = path.resolve(process.cwd(), 'dist');\n const indexPath = path.join(distDir, 'index.html');\n\n if (!fs.existsSync(indexPath)) {\n console.warn('[specifyjs-noscript] index.html not found in dist/');\n return;\n }\n\n const noscriptHtml = generateNoscriptHtml(config);\n\n if (!noscriptHtml) {\n console.warn('[specifyjs-noscript] No sections provided, skipping.');\n return;\n }\n\n // Check content size\n const maxSize = config.maxContentSize ?? 512 * 1024;\n const noscriptSize = Buffer.byteLength(noscriptHtml, 'utf-8');\n if (noscriptSize > maxSize) {\n console.warn(\n `[specifyjs-noscript] Noscript content is ${(noscriptSize / 1024).toFixed(0)}KB ` +\n `(limit: ${(maxSize / 1024).toFixed(0)}KB). Consider reducing section content.`,\n );\n }\n\n // Inject before </body>\n let html = fs.readFileSync(indexPath, 'utf-8');\n html = html.replace('</body>', `${noscriptHtml}\\n</body>`);\n fs.writeFileSync(indexPath, html, 'utf-8');\n\n console.log(\n `Generated: noscript fallback (${config.sections.length} sections, ` +\n `${(noscriptSize / 1024).toFixed(1)}KB)`,\n );\n },\n /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K,QAAQ,QAAQ,IAAI,EAAG,MAAM,EAC5CC,EAAY,EAAAD,QAAK,KAAKD,EAAS,YAAY,EAEjD,GAAI,CAAC,EAAAG,QAAG,WAAWD,CAAS,EAAG,CAC7B,QAAQ,KAAK,oDAAoD,EACjE,MACF,CAEA,IAAME,EAAelB,EAAqBC,CAAM,EAEhD,GAAI,CAACiB,EAAc,CACjB,QAAQ,KAAK,sDAAsD,EACnE,MACF,CAGA,IAAMC,EAAUlB,EAAO,gBAAkB,IAAM,KACzCmB,EAAe,OAAO,WAAWF,EAAc,OAAO,EACxDE,EAAeD,GACjB,QAAQ,KACN,6CAA6CC,EAAe,MAAM,QAAQ,CAAC,CAAC,eAC9DD,EAAU,MAAM,QAAQ,CAAC,CAAC,yCAC1C,EAIF,IAAI7C,EAAO,EAAA2C,QAAG,aAAaD,EAAW,OAAO,EAC7C1C,EAAOA,EAAK,QAAQ,UAAW,GAAG4C,CAAY;AAAA,QAAW,EACzD,EAAAD,QAAG,cAAcD,EAAW1C,EAAM,OAAO,EAEzC,QAAQ,IACN,iCAAiC2B,EAAO,SAAS,MAAM,eACjDmB,EAAe,MAAM,QAAQ,CAAC,CAAC,KACvC,CACF,CAEF,CACF",
|
|
6
|
-
"names": ["index_exports", "__export", "generateNoscriptHtml", "specifyJsNoscriptPlugin", "specifyJsSeoPlugin", "stripInteractiveElements", "__toCommonJS", "import_fs", "import_path", "walkDocs", "rootDir", "results", "stack", "dir", "prefix", "entries", "fs", "entry", "path", "generateSitemap", "siteUrl", "routes", "today", "r", "generateRobots", "extraRules", "lines", "generateLlmsTxt", "config", "docPaths", "descLines", "dl", "guideNames", "p", "apiNames", "g", "a", "specifyJsSeoPlugin", "distDir", "dp", "sitemap", "robots", "llmsTxt", "indexPath", "html", "ldBlocks", "s", "extras", "import_fs", "import_path", "ALLOWED_TAGS", "CONTENT_BLOCK_TAGS", "ALLOWED_ATTRS", "stripInteractiveElements", "html", "out", "i", "len", "ltIdx", "gtIdx", "tagContent", "isClosing", "tagBody", "spaceIdx", "tagName", "attrStr", "safeAttrs", "filterAttributes", "selfClose", "closeTag", "closeIdx", "closeGt", "attrString", "result", "attrRegex", "match", "name", "value", "escapeAttrValue", "val", "generateNoscriptHtml", "config", "prefix", "sections", "navLinks", "s", "escapeHtml", "sectionBlocks", "cleanHtml", "title", "desc", "copyright", "str", "specifyJsNoscriptPlugin", "distDir", "path", "indexPath", "fs", "noscriptHtml", "maxSize", "noscriptSize"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/build/seo-plugin.ts", "../src/build/noscript-plugin.ts"],
|
|
4
|
-
"sourcesContent": ["// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\n/**\n * SpecifyJS SEO Plugin for Vite\n * Auto-generates sitemap.xml, robots.txt, and llms.txt at build time.\n *\n * Usage in vite.config.ts:\n * import { specifyJsSeoPlugin } from '@asymmetric-effort/specifyjs/build';\n * export default defineConfig({ plugins: [specifyJsSeoPlugin({ ... })] });\n */\n\nimport type { Plugin } from 'vite';\nimport fs from 'fs';\nimport path from 'path';\n\nexport interface SeoPluginConfig {\n /** Base URL of the site (e.g., 'https://example.com') */\n siteUrl: string;\n /** Site title for llms.txt */\n title?: string;\n /** Site description for llms.txt */\n description?: string;\n /** Hash-based routes to include in sitemap */\n routes?: string[];\n /** Path to docs directory (generates doc routes in sitemap) */\n docsDir?: string;\n /** npm package name for llms.txt install instructions */\n npmPackage?: string;\n /** Author name for llms.txt */\n author?: string;\n /** License for llms.txt */\n license?: string;\n /** Additional robots.txt rules */\n robotsRules?: string[];\n /** Repository URL for llms.txt */\n repository?: string;\n /** Schema.org structured data (JSON-LD). When provided, a\n * `<script type=\"application/ld+json\">` block is injected into index.html.\n * Can be a plain object or an array of objects for multiple schemas. */\n jsonLd?: Record<string, unknown> | Record<string, unknown>[];\n}\n\n/**\n * Iteratively walk a directory and collect markdown file paths (without .md extension).\n * Uses an explicit stack instead of recursion per project coding standards.\n */\nfunction walkDocs(rootDir: string, results: string[]): void {\n const stack: Array<{ dir: string; prefix: string }> = [{ dir: rootDir, prefix: '' }];\n while (stack.length > 0) {\n const { dir, prefix } = stack.pop()!;\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n stack.push({ dir: path.join(dir, entry.name), prefix: prefix + entry.name + '/' });\n } else if (entry.name.endsWith('.md')) {\n results.push(prefix + entry.name.replace('.md', ''));\n }\n }\n }\n}\n\n/**\n * Generate sitemap.xml content from a list of routes.\n */\nfunction generateSitemap(siteUrl: string, routes: string[], today: string): string {\n const sitemapEntries = routes.map(\n (r) => ` <url><loc>${siteUrl}${r}</loc><lastmod>${today}</lastmod></url>`,\n );\n return [\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">',\n ...sitemapEntries,\n '</urlset>',\n ].join('\\n');\n}\n\n/**\n * Generate robots.txt content.\n */\nfunction generateRobots(siteUrl: string, extraRules?: string[]): string {\n const lines = ['User-agent: *', 'Allow: /'];\n if (extraRules) {\n lines.push(...extraRules);\n }\n lines.push('', `Sitemap: ${siteUrl}/sitemap.xml`);\n return lines.join('\\n');\n}\n\n/**\n * Generate llms.txt content with project metadata and doc links.\n */\nfunction generateLlmsTxt(config: SeoPluginConfig, docPaths: string[]): string {\n const title = config.title ?? 'Site';\n const lines: string[] = [`# ${title}`];\n\n if (config.description) {\n lines.push('');\n const descLines = config.description.split('\\n');\n for (const dl of descLines) {\n lines.push(`> ${dl}`);\n }\n }\n\n lines.push('');\n lines.push(`## Website: ${config.siteUrl}`);\n if (config.repository) {\n lines.push(`## Repository: ${config.repository}`);\n }\n if (config.npmPackage) {\n lines.push(`## npm: https://www.npmjs.com/package/${config.npmPackage}`);\n }\n\n // Documentation section\n const guideNames = docPaths\n .filter((p) => p.startsWith('guides/'))\n .map((p) => p.replace('guides/', ''));\n const apiNames = docPaths.filter((p) => p.startsWith('api/')).map((p) => p.replace('api/', ''));\n\n if (guideNames.length > 0) {\n lines.push('', '## Documentation', '');\n for (const g of guideNames) {\n lines.push(`- ${g}: ${config.siteUrl}/#/docs/guides/${g}`);\n }\n }\n\n if (apiNames.length > 0) {\n lines.push('', '## API Reference', '');\n for (const a of apiNames) {\n lines.push(`- ${a}: ${config.siteUrl}/#/docs/api/${a}`);\n }\n }\n\n if (config.npmPackage) {\n lines.push('', '## Install', '', '```', `npm install ${config.npmPackage}`, '```');\n }\n\n if (config.license) {\n lines.push('', `## License: ${config.license}`);\n }\n if (config.author) {\n lines.push(`## Author: ${config.author}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Create the SpecifyJS SEO Vite plugin.\n *\n * Generates sitemap.xml, robots.txt, and llms.txt in the build output directory\n * during the closeBundle hook.\n */\nexport function specifyJsSeoPlugin(config: SeoPluginConfig): Plugin {\n return {\n name: 'specifyjs-seo',\n closeBundle() {\n const distDir = path.resolve(process.cwd(), 'dist');\n const today = new Date().toISOString().split('T')[0] ?? '';\n\n // Collect routes\n const routes = [...(config.routes ?? ['/'])];\n\n // Collect doc routes from docsDir\n const docPaths: string[] = [];\n if (config.docsDir && fs.existsSync(config.docsDir)) {\n walkDocs(config.docsDir, docPaths);\n for (const dp of docPaths) {\n routes.push(`/#/docs/${dp}`);\n }\n }\n\n // Generate and write sitemap.xml\n const sitemap = generateSitemap(config.siteUrl, routes, today);\n fs.writeFileSync(path.join(distDir, 'sitemap.xml'), sitemap);\n\n // Generate and write robots.txt\n const robots = generateRobots(config.siteUrl, config.robotsRules);\n fs.writeFileSync(path.join(distDir, 'robots.txt'), robots);\n\n // Generate and write llms.txt\n const llmsTxt = generateLlmsTxt(config, docPaths);\n fs.writeFileSync(path.join(distDir, 'llms.txt'), llmsTxt);\n\n /* v8 ignore start -- JSON-LD injection uses fs in Vite closeBundle */\n // Inject JSON-LD structured data into index.html\n if (config.jsonLd) {\n const indexPath = path.join(distDir, 'index.html');\n if (fs.existsSync(indexPath)) {\n let html = fs.readFileSync(indexPath, 'utf-8');\n const schemas = Array.isArray(config.jsonLd) ? config.jsonLd : [config.jsonLd];\n const ldBlocks = schemas\n .map((s) => `<script type=\"application/ld+json\">${JSON.stringify(s)}</script>`)\n .join('\\n ');\n html = html.replace('</head>', ` ${ldBlocks}\\n </head>`);\n fs.writeFileSync(indexPath, html, 'utf-8');\n }\n }\n\n /* v8 ignore stop */\n const extras = config.jsonLd ? ', JSON-LD' : '';\n console.log(`Generated: sitemap.xml (${routes.length} URLs), robots.txt, llms.txt${extras}`);\n },\n };\n}\n", "// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\n/**\n * SpecifyJS Noscript Plugin for Vite\n *\n * Generates a `<noscript>` fallback block inside the built index.html,\n * providing a fully navigable static HTML document for environments\n * where JavaScript is disabled (accessibility) or not executed\n * (search engine crawlers).\n *\n * The noscript content is a single long-form document with:\n * - A navigation bar with anchor links to each section\n * - Each section rendered as semantic HTML (headings, paragraphs, lists)\n * - Internal links mapped to `#section-id` anchors\n *\n * Usage in vite.config.ts:\n * import { specifyJsNoscriptPlugin } from 'specifyjs/build';\n * export default defineConfig({\n * plugins: [\n * specifyJsNoscriptPlugin({\n * title: 'My App',\n * sections: [\n * { id: 'home', title: 'Home', html: '<h1>Welcome</h1><p>...</p>' },\n * { id: 'docs', title: 'Docs', html: '<h2>Getting Started</h2>...' },\n * ],\n * }),\n * ],\n * });\n */\n\nimport type { Plugin } from 'vite';\nimport fs from 'fs';\nimport path from 'path';\n\n// ---------------------------------------------------------------------------\n// Configuration\n// ---------------------------------------------------------------------------\n\nexport interface NoscriptSection {\n /** Anchor ID (used in href=\"#id\" links) */\n id: string;\n /** Display title in the navigation bar */\n title: string;\n /** Static HTML content for this section.\n * Can include headings, paragraphs, lists, tables, code blocks, images.\n * Interactive elements (buttons, inputs) are stripped automatically. */\n html: string;\n}\n\nexport interface NoscriptPluginConfig {\n /** Page title shown at the top of the noscript document */\n title?: string;\n /** Subtitle / description shown below the title */\n description?: string;\n /** Sections to render in the noscript block */\n sections: NoscriptSection[];\n /** Copyright notice shown at the bottom */\n copyright?: string;\n /** CSS class prefix for noscript elements (default: 'ns') */\n classPrefix?: string;\n /** Maximum content length in bytes before truncation warning (default: 512KB) */\n maxContentSize?: number;\n}\n\n// ---------------------------------------------------------------------------\n// HTML sanitization\n// ---------------------------------------------------------------------------\n\n/**\n * Allowed HTML tags for noscript content.\n * Only these tags are preserved \u2014 everything else is stripped.\n * This whitelist approach avoids the inherent insecurity of\n * regex-based blocklist sanitization (no bypasses possible).\n */\nconst ALLOWED_TAGS = new Set([\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'p',\n 'br',\n 'hr',\n 'blockquote',\n 'ul',\n 'ol',\n 'li',\n 'dl',\n 'dt',\n 'dd',\n 'table',\n 'thead',\n 'tbody',\n 'tfoot',\n 'tr',\n 'th',\n 'td',\n 'caption',\n 'a',\n 'strong',\n 'em',\n 'b',\n 'i',\n 'u',\n 's',\n 'code',\n 'pre',\n 'kbd',\n 'samp',\n 'span',\n 'div',\n 'section',\n 'article',\n 'aside',\n 'header',\n 'footer',\n 'nav',\n 'img',\n 'figure',\n 'figcaption',\n 'picture',\n 'source',\n 'details',\n 'summary',\n 'mark',\n 'small',\n 'sub',\n 'sup',\n 'abbr',\n 'time',\n]);\n\n/** Tags whose content is removed entirely (not just the tag itself) */\nconst CONTENT_BLOCK_TAGS = new Set([\n 'script',\n 'style',\n 'textarea',\n 'select',\n 'noscript',\n 'iframe',\n 'object',\n 'embed',\n 'applet',\n]);\n\n/** Allowed attributes (no event handlers, no javascript: URIs) */\nconst ALLOWED_ATTRS = new Set([\n 'href',\n 'src',\n 'alt',\n 'title',\n 'width',\n 'height',\n 'class',\n 'id',\n 'name',\n 'colspan',\n 'rowspan',\n 'scope',\n 'rel',\n 'target',\n 'lang',\n 'dir',\n 'role',\n 'aria-label',\n 'aria-describedby',\n 'aria-hidden',\n 'style', // style is allowed but javascript: URIs within it are stripped\n]);\n\n/**\n * Strip interactive elements from HTML using a whitelist approach.\n * Only allowed tags with allowed attributes are kept. All other\n * tags are removed (their text content is preserved). This is\n * immune to regex bypass attacks because unknown tags are never\n * emitted \u2014 they're simply not in the whitelist.\n */\nexport function stripInteractiveElements(html: string): string {\n // Parse tags iteratively \u2014 no regex on untrusted HTML structure\n const out: string[] = [];\n let i = 0;\n const len = html.length;\n\n while (i < len) {\n const ltIdx = html.indexOf('<', i);\n if (ltIdx === -1) {\n // No more tags \u2014 emit remaining text\n out.push(html.slice(i));\n break;\n }\n\n // Emit text before the tag\n if (ltIdx > i) out.push(html.slice(i, ltIdx));\n\n // Find end of tag\n const gtIdx = html.indexOf('>', ltIdx);\n if (gtIdx === -1) {\n // Unclosed tag \u2014 emit as text\n out.push(html.slice(ltIdx));\n break;\n }\n\n const tagContent = html.slice(ltIdx + 1, gtIdx);\n const isClosing = tagContent.startsWith('/');\n const tagBody = isClosing ? tagContent.slice(1).trim() : tagContent.trim();\n\n // Extract tag name (first word)\n const spaceIdx = tagBody.search(/[\\s/]/);\n const tagName = (spaceIdx === -1 ? tagBody : tagBody.slice(0, spaceIdx)).toLowerCase();\n\n if (ALLOWED_TAGS.has(tagName)) {\n if (isClosing) {\n out.push(`</${tagName}>`);\n } else {\n // Rebuild tag with only allowed attributes\n const attrStr = spaceIdx === -1 ? '' : tagBody.slice(spaceIdx);\n const safeAttrs = filterAttributes(attrStr);\n const selfClose = tagContent.trimEnd().endsWith('/') ? ' /' : '';\n out.push(`<${tagName}${safeAttrs}${selfClose}>`);\n }\n } else if (!isClosing && CONTENT_BLOCK_TAGS.has(tagName)) {\n // Blocked tags whose CONTENT must also be removed (script, textarea, select, style)\n // Skip everything until the matching closing tag\n const closeTag = `</${tagName}`;\n const closeIdx = html.toLowerCase().indexOf(closeTag, gtIdx + 1);\n if (closeIdx !== -1) {\n const closeGt = html.indexOf('>', closeIdx);\n i = closeGt !== -1 ? closeGt + 1 : gtIdx + 1;\n continue;\n }\n }\n // else: tag not in whitelist \u2014 silently dropped (text content preserved)\n\n i = gtIdx + 1;\n }\n\n return out.join('');\n}\n\n/** Filter attributes: keep only whitelisted, strip javascript: URIs */\nfunction filterAttributes(attrString: string): string {\n const result: string[] = [];\n // Match attr=\"value\" or attr='value' or attr=value or standalone attr\n const attrRegex = /([a-z][a-z0-9-]*)\\s*(?:=\\s*(?:\"([^\"]*)\"|'([^']*)'|(\\S+)))?/gi;\n let match: RegExpExecArray | null;\n while ((match = attrRegex.exec(attrString)) !== null) {\n const name = match[1]!.toLowerCase();\n const value = match[2] ?? match[3] ?? match[4] ?? '';\n if (!ALLOWED_ATTRS.has(name)) continue;\n // Block javascript: URIs in href/src/style\n if (/javascript\\s*:/i.test(value)) continue;\n result.push(` ${name}=\"${escapeAttrValue(value)}\"`);\n }\n return result.join('');\n}\n\nfunction escapeAttrValue(val: string): string {\n return val\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\n// ---------------------------------------------------------------------------\n// Noscript HTML generation\n// ---------------------------------------------------------------------------\n\nexport function generateNoscriptHtml(config: NoscriptPluginConfig): string {\n const prefix = config.classPrefix ?? 'ns';\n const sections = config.sections;\n\n if (sections.length === 0) return '';\n\n // Navigation bar\n const navLinks = sections\n .map((s) => `<a href=\"#${s.id}\" class=\"${prefix}-nav-link\">${escapeHtml(s.title)}</a>`)\n .join('\\n ');\n\n // Section blocks\n const sectionBlocks = sections\n .map((s) => {\n const cleanHtml = stripInteractiveElements(s.html);\n return `\n <section id=\"${s.id}\" class=\"${prefix}-section\">\n <h2 class=\"${prefix}-section-title\">${escapeHtml(s.title)}</h2>\n <div class=\"${prefix}-section-content\">\n ${cleanHtml}\n </div>\n <p class=\"${prefix}-back-to-top\"><a href=\"#${prefix}-top\">Back to top</a></p>\n </section>`;\n })\n .join('\\n');\n\n const title = config.title ? `<h1 class=\"${prefix}-title\">${escapeHtml(config.title)}</h1>` : '';\n const desc = config.description\n ? `<p class=\"${prefix}-desc\">${escapeHtml(config.description)}</p>`\n : '';\n const copyright = config.copyright\n ? `<footer class=\"${prefix}-footer\"><p>${escapeHtml(config.copyright)}</p></footer>`\n : '';\n\n return `\n <noscript>\n <style>\n .${prefix}-container {\n max-width: 900px;\n margin: 0 auto;\n padding: 20px;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n line-height: 1.6;\n color: #1f2937;\n }\n .${prefix}-title {\n font-size: 2rem;\n margin-bottom: 0.5rem;\n color: #0f172a;\n }\n .${prefix}-desc {\n font-size: 1.1rem;\n color: #64748b;\n margin-bottom: 1.5rem;\n }\n .${prefix}-nav {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 0;\n border-bottom: 1px solid #e2e8f0;\n margin-bottom: 2rem;\n position: sticky;\n top: 0;\n background: white;\n z-index: 10;\n }\n .${prefix}-nav-link {\n padding: 6px 14px;\n border-radius: 6px;\n background: #f1f5f9;\n color: #3b82f6;\n text-decoration: none;\n font-size: 14px;\n font-weight: 500;\n }\n .${prefix}-nav-link:hover {\n background: #3b82f6;\n color: white;\n }\n .${prefix}-section {\n margin-bottom: 3rem;\n padding-bottom: 2rem;\n border-bottom: 1px solid #f1f5f9;\n }\n .${prefix}-section-title {\n font-size: 1.5rem;\n color: #1e293b;\n margin-bottom: 1rem;\n padding-top: 1rem;\n }\n .${prefix}-section-content h3 {\n font-size: 1.2rem;\n margin-top: 1.5rem;\n color: #334155;\n }\n .${prefix}-section-content p {\n margin: 0.5rem 0;\n }\n .${prefix}-section-content pre {\n background: #1e293b;\n color: #e2e8f0;\n padding: 12px 16px;\n border-radius: 6px;\n overflow-x: auto;\n font-size: 13px;\n line-height: 1.5;\n }\n .${prefix}-section-content code {\n background: #f1f5f9;\n padding: 2px 6px;\n border-radius: 3px;\n font-size: 0.9em;\n }\n .${prefix}-section-content pre code {\n background: none;\n padding: 0;\n }\n .${prefix}-section-content table {\n width: 100%;\n border-collapse: collapse;\n margin: 1rem 0;\n }\n .${prefix}-section-content th,\n .${prefix}-section-content td {\n padding: 8px 12px;\n border: 1px solid #e2e8f0;\n text-align: left;\n }\n .${prefix}-section-content th {\n background: #f8fafc;\n font-weight: 600;\n }\n .${prefix}-section-content img {\n max-width: 100%;\n height: auto;\n }\n .${prefix}-back-to-top {\n font-size: 13px;\n margin-top: 1.5rem;\n }\n .${prefix}-back-to-top a {\n color: #3b82f6;\n text-decoration: none;\n }\n .${prefix}-footer {\n margin-top: 3rem;\n padding-top: 1rem;\n border-top: 1px solid #e2e8f0;\n color: #94a3b8;\n font-size: 13px;\n text-align: center;\n }\n .${prefix}-js-notice {\n background: #fef3c7;\n border: 1px solid #f59e0b;\n border-radius: 6px;\n padding: 12px 16px;\n margin-bottom: 1.5rem;\n font-size: 14px;\n color: #92400e;\n }\n </style>\n <div id=\"${prefix}-top\" class=\"${prefix}-container\">\n ${title}\n ${desc}\n <div class=\"${prefix}-js-notice\">\n This page works best with JavaScript enabled. You are viewing a\n static version of the content.\n </div>\n <nav class=\"${prefix}-nav\" aria-label=\"Section navigation\">\n ${navLinks}\n </nav>\n ${sectionBlocks}\n ${copyright}\n </div>\n </noscript>`;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction escapeHtml(str: string): string {\n return str\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n}\n\n// ---------------------------------------------------------------------------\n// Vite Plugin\n// ---------------------------------------------------------------------------\n\nexport function specifyJsNoscriptPlugin(config: NoscriptPluginConfig): Plugin {\n return {\n name: 'specifyjs-noscript',\n /* v8 ignore start -- Vite closeBundle hook runs at build time, not in jsdom tests */\n closeBundle() {\n const distDir = path.resolve(process.cwd(), 'dist');\n const indexPath = path.join(distDir, 'index.html');\n\n if (!fs.existsSync(indexPath)) {\n console.warn('[specifyjs-noscript] index.html not found in dist/');\n return;\n }\n\n const noscriptHtml = generateNoscriptHtml(config);\n\n if (!noscriptHtml) {\n console.warn('[specifyjs-noscript] No sections provided, skipping.');\n return;\n }\n\n // Check content size\n const maxSize = config.maxContentSize ?? 512 * 1024;\n const noscriptSize = Buffer.byteLength(noscriptHtml, 'utf-8');\n if (noscriptSize > maxSize) {\n console.warn(\n `[specifyjs-noscript] Noscript content is ${(noscriptSize / 1024).toFixed(0)}KB ` +\n `(limit: ${(maxSize / 1024).toFixed(0)}KB). Consider reducing section content.`,\n );\n }\n\n // Inject before </body>\n let html = fs.readFileSync(indexPath, 'utf-8');\n html = html.replace('</body>', `${noscriptHtml}\\n</body>`);\n fs.writeFileSync(indexPath, html, 'utf-8');\n\n console.log(\n `Generated: noscript fallback (${config.sections.length} sections, ` +\n `${(noscriptSize / 1024).toFixed(1)}KB)`,\n );\n },\n /* v8 ignore stop */\n };\n}\n"],
|
|
5
|
-
"mappings": ";AAaA,OAAOA,MAAQ,KACf,OAAOC,MAAU,OAiCjB,SAASC,EAASC,EAAiBC,EAAyB,CAC1D,IAAMC,EAAgD,CAAC,CAAE,IAAKF,EAAS,OAAQ,EAAG,CAAC,EACnF,KAAOE,EAAM,OAAS,GAAG,CACvB,GAAM,CAAE,IAAAC,EAAK,OAAAC,CAAO,EAAIF,EAAM,IAAI,EAC5BG,EAAUR,EAAG,YAAYM,EAAK,CAAE,cAAe,EAAK,CAAC,EAC3D,QAAWG,KAASD,EACdC,EAAM,YAAY,EACpBJ,EAAM,KAAK,CAAE,IAAKJ,EAAK,KAAKK,EAAKG,EAAM,IAAI,EAAG,OAAQF,EAASE,EAAM,KAAO,GAAI,CAAC,EACxEA,EAAM,KAAK,SAAS,KAAK,GAClCL,EAAQ,KAAKG,EAASE,EAAM,KAAK,QAAQ,MAAO,EAAE,CAAC,CAGzD,CACF,CAKA,SAASC,EAAgBC,EAAiBC,EAAkBC,EAAuB,CAIjF,MAA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ACLC,CAAI;AAAA,sBACQR,CAAM;AAAA;AAAA;AAAA;AAAA,sBAINA,CAAM;AAAA,YAChBE,CAAQ;AAAA;AAAA,UAEVG,CAAa;AAAA,UACbI,CAAS;AAAA;AAAA,gBAGnB,CAMA,SAASL,EAAWM,EAAqB,CACvC,OAAOA,EACJ,QAAQ,KAAM,OAAO,EACrB,QAAQ,KAAM,MAAM,EACpB,QAAQ,KAAM,MAAM,EACpB,QAAQ,KAAM,QAAQ,CAC3B,CAMO,SAASC,EAAwBZ,EAAsC,CAC5E,MAAO,CACL,KAAM,qBAEN,aAAc,CACZ,IAAMa,EAAU7C,EAAK,QAAQ,QAAQ,IAAI,EAAG,MAAM,EAC5C8C,EAAY9C,EAAK,KAAK6C,EAAS,YAAY,EAEjD,GAAI,CAAC9C,EAAG,WAAW+C,CAAS,EAAG,CAC7B,QAAQ,KAAK,oDAAoD,EACjE,MACF,CAEA,IAAMC,EAAehB,EAAqBC,CAAM,EAEhD,GAAI,CAACe,EAAc,CACjB,QAAQ,KAAK,sDAAsD,EACnE,MACF,CAGA,IAAMC,EAAUhB,EAAO,gBAAkB,IAAM,KACzCiB,EAAe,OAAO,WAAWF,EAAc,OAAO,EACxDE,EAAeD,GACjB,QAAQ,KACN,6CAA6CC,EAAe,MAAM,QAAQ,CAAC,CAAC,eAC9DD,EAAU,MAAM,QAAQ,CAAC,CAAC,yCAC1C,EAIF,IAAI3C,EAAON,EAAG,aAAa+C,EAAW,OAAO,EAC7CzC,EAAOA,EAAK,QAAQ,UAAW,GAAG0C,CAAY;AAAA,QAAW,EACzDhD,EAAG,cAAc+C,EAAWzC,EAAM,OAAO,EAEzC,QAAQ,IACN,iCAAiC2B,EAAO,SAAS,MAAM,eACjDiB,EAAe,MAAM,QAAQ,CAAC,CAAC,KACvC,CACF,CAEF,CACF",
|
|
6
|
-
"names": ["fs", "path", "walkDocs", "rootDir", "results", "stack", "dir", "prefix", "entries", "entry", "generateSitemap", "siteUrl", "routes", "today", "r", "generateRobots", "extraRules", "lines", "generateLlmsTxt", "config", "docPaths", "descLines", "dl", "guideNames", "p", "apiNames", "g", "a", "specifyJsSeoPlugin", "distDir", "dp", "sitemap", "robots", "llmsTxt", "indexPath", "html", "ldBlocks", "s", "extras", "fs", "path", "ALLOWED_TAGS", "CONTENT_BLOCK_TAGS", "ALLOWED_ATTRS", "stripInteractiveElements", "html", "out", "i", "len", "ltIdx", "gtIdx", "tagContent", "isClosing", "tagBody", "spaceIdx", "tagName", "attrStr", "safeAttrs", "filterAttributes", "selfClose", "closeTag", "closeIdx", "closeGt", "attrString", "result", "attrRegex", "match", "name", "value", "escapeAttrValue", "val", "generateNoscriptHtml", "config", "prefix", "sections", "navLinks", "s", "escapeHtml", "sectionBlocks", "cleanHtml", "title", "desc", "copyright", "str", "specifyJsNoscriptPlugin", "distDir", "indexPath", "noscriptHtml", "maxSize", "noscriptSize"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/client/index.ts", "../src/hooks/index.ts", "../src/shared/secure-fetch.ts", "../src/client/rest.ts", "../src/client/protobuf.ts", "../src/client/graphql.ts"],
|
|
4
|
-
"sourcesContent": ["// ============================================================================\n// SpecifyJS Client \u2014 Native API client modules\n// ============================================================================\n// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nexport {\n createRestClient,\n useRest,\n RestError,\n type RestClientConfig,\n type RestClient,\n type RestResponse,\n type RequestConfig,\n type RequestInterceptor,\n type ResponseInterceptor,\n} from './rest';\n\nexport {\n defineMessage,\n createGrpcWebClient,\n useProto,\n type MessageType,\n type GrpcWebClient,\n} from './protobuf';\n\nexport {\n createGraphQLClient,\n gql,\n useQuery,\n useMutation,\n type GraphQLClient,\n type GraphQLClientConfig,\n type GraphQLResponse,\n type GraphQLError,\n} from './graphql';\n", "// ============================================================================\n// SpecifyJS Hooks\n// ============================================================================\n// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport type { SpecContext } from '../shared/types';\n\n// Internal: the currently rendering fiber sets these\ntype Dispatcher = {\n useState: typeof useState;\n useEffect: typeof useEffect;\n useContext: typeof useContext;\n useReducer: typeof useReducer;\n useCallback: typeof useCallback;\n useMemo: typeof useMemo;\n useRef: typeof useRef;\n useImperativeHandle: typeof useImperativeHandle;\n useLayoutEffect: typeof useLayoutEffect;\n useDebugValue: typeof useDebugValue;\n useId: typeof useId;\n useDeferredValue: typeof useDeferredValue;\n useTransition: typeof useTransition;\n useSyncExternalStore: typeof useSyncExternalStore;\n useInsertionEffect: typeof useInsertionEffect;\n};\n\nlet currentDispatcher: Dispatcher | null = null;\n\nexport function __setDispatcher(dispatcher: Dispatcher | null): void {\n currentDispatcher = dispatcher;\n}\n\nexport function __getDispatcher(): Dispatcher | null {\n return currentDispatcher;\n}\n\nfunction resolveDispatcher(): Dispatcher {\n if (currentDispatcher === null) {\n throw new Error(\n 'Invalid hook call. Hooks can only be called inside the body of a function component.',\n );\n }\n return currentDispatcher;\n}\n\nexport function useState<T>(\n initialState: T | (() => T),\n): [T, (action: T | ((prev: T) => T)) => void] {\n return resolveDispatcher().useState(initialState);\n}\n\nexport function useEffect(create: () => void | (() => void), deps?: readonly unknown[]): void {\n return resolveDispatcher().useEffect(create, deps);\n}\n\nexport function useContext<T>(context: SpecContext<T>): T {\n return resolveDispatcher().useContext(context);\n}\n\nexport function useReducer<S, A>(\n reducer: (state: S, action: A) => S,\n initialArg: S,\n init?: (arg: S) => S,\n): [S, (action: A) => void] {\n return resolveDispatcher().useReducer(reducer, initialArg, init);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useCallback<T extends (...args: any[]) => any>(\n callback: T,\n deps: readonly unknown[],\n): T {\n return resolveDispatcher().useCallback(callback, deps);\n}\n\nexport function useMemo<T>(factory: () => T, deps: readonly unknown[]): T {\n return resolveDispatcher().useMemo(factory, deps);\n}\n\nexport function useRef<T>(initialValue: T): { current: T };\nexport function useRef<T>(initialValue: T | null): { current: T | null };\nexport function useRef<T>(): { current: T | undefined };\nexport function useRef<T>(initialValue?: T): { current: T | undefined } {\n return resolveDispatcher().useRef(initialValue);\n}\n\nexport function useImperativeHandle<T>(\n ref: { current: T | null } | ((instance: T | null) => void) | null,\n createHandle: () => T,\n deps?: readonly unknown[],\n): void {\n return resolveDispatcher().useImperativeHandle(ref, createHandle, deps);\n}\n\nexport function useLayoutEffect(\n create: () => void | (() => void),\n deps?: readonly unknown[],\n): void {\n return resolveDispatcher().useLayoutEffect(create, deps);\n}\n\nexport function useDebugValue<T>(value: T, format?: (value: T) => unknown): void {\n return resolveDispatcher().useDebugValue(value, format);\n}\n\nexport function useId(): string {\n return resolveDispatcher().useId();\n}\n\nexport function useDeferredValue<T>(value: T): T {\n return resolveDispatcher().useDeferredValue(value);\n}\n\nexport function useTransition(): [boolean, (callback: () => void) => void] {\n return resolveDispatcher().useTransition();\n}\n\nexport function useSyncExternalStore<T>(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n): T {\n return resolveDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n\nexport function useInsertionEffect(\n create: () => void | (() => void),\n deps?: readonly unknown[],\n): void {\n return resolveDispatcher().useInsertionEffect(create, deps);\n}\n\n// Custom hooks (not dispatcher-based)\nexport { useHead } from './use-head';\nexport type { HeadMeta, HeadHttpEquiv } from './use-head';\n", "// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\n/**\n * Secure fetch wrapper \u2014 enforces HTTPS-only policy.\n *\n * SpecifyJS prohibits HTTP connections. All network requests must use\n * HTTPS or be relative URLs. This prevents data from being transmitted\n * in plaintext, protecting against eavesdropping and MITM attacks.\n *\n * Exceptions:\n * - Relative URLs (./path, /path) \u2014 resolved by the browser\n * - localhost and 127.0.0.1 \u2014 development only\n */\n\n/**\n * Validate that a URL uses HTTPS or is a relative/localhost URL.\n * Throws if the URL uses plaintext HTTP.\n */\nexport function assertSecureUrl(url: string): void {\n // Block protocol-relative URLs (//evil.com) \u2014 they inherit the page's protocol\n if (url.startsWith('//')) {\n throw new Error(\n `[SpecifyJS] Protocol-relative URL rejected: \"${url}\". ` + `Use an explicit https:// prefix.`,\n );\n }\n\n // Relative URLs are always allowed\n if (url.startsWith('/') || url.startsWith('./') || url.startsWith('../')) {\n return;\n }\n\n // Data URIs: allow but limit size to prevent memory exhaustion\n if (url.startsWith('data:')) {\n if (url.length > 1024 * 1024) {\n throw new Error('[SpecifyJS] secureFetch: data: URI exceeds 1MB limit');\n }\n return;\n }\n\n // Parse absolute URLs \u2014 reject if unparseable\n let parsed: URL;\n try {\n parsed = new URL(url, typeof window !== 'undefined' ? window.location.href : undefined);\n } catch {\n throw new Error(\n `[SpecifyJS] secureFetch: unable to validate URL \"${url}\". ` +\n `Provide a valid absolute HTTPS URL or a relative path.`,\n );\n }\n\n // Allow HTTPS\n if (parsed.protocol === 'https:') {\n return;\n }\n\n // Allow localhost for development (any protocol) \u2014 covers IPv4/IPv6 loopback\n if (\n parsed.hostname === 'localhost' ||\n parsed.hostname === '127.0.0.1' ||\n parsed.hostname === '[::1]' ||\n parsed.hostname === '0.0.0.0' ||\n parsed.hostname.startsWith('127.')\n ) {\n return;\n }\n\n // Reject HTTP and other insecure protocols\n throw new Error(\n `[SpecifyJS] Insecure URL rejected: \"${url}\". ` +\n `SpecifyJS enforces HTTPS-only for all network requests. ` +\n `Use https:// or a relative URL. ` +\n `Localhost URLs are allowed for development.`,\n );\n}\n\n/**\n * Secure fetch \u2014 drop-in replacement for window.fetch that enforces HTTPS.\n * Use this instead of fetch() directly to comply with the HTTPS-only policy.\n */\nexport function secureFetch(input: string | URL | Request, init?: RequestInit): Promise<Response> {\n const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;\n assertSecureUrl(url);\n // Default to rejecting redirects to prevent redirect-based SSRF.\n // Callers can override with { redirect: 'follow' } if they trust the target.\n return fetch(input, { redirect: 'error', ...init });\n}\n", "// ============================================================================\n// SpecifyJS REST Client\n// Zero-dependency REST client built on the browser Fetch API\n// ============================================================================\n// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport { useState, useEffect, useCallback, useRef } from '../hooks/index';\nimport { assertSecureUrl } from '../shared/secure-fetch';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface RestClientConfig {\n baseURL: string;\n headers?: Record<string, string>;\n timeout?: number;\n interceptors?: {\n request?: RequestInterceptor[];\n response?: ResponseInterceptor[];\n error?: ErrorInterceptor[];\n };\n}\n\nexport interface RequestConfig {\n url: string;\n method: string;\n headers: Record<string, string>;\n body?: unknown;\n signal?: AbortSignal;\n timeout?: number;\n}\n\nexport interface RestResponse<T> {\n data: T;\n status: number;\n headers: Record<string, string>;\n ok: boolean;\n}\n\nexport type RequestInterceptor = (config: RequestConfig) => RequestConfig | Promise<RequestConfig>;\nexport type ResponseInterceptor = (response: RestResponse<unknown>) => RestResponse<unknown>;\nexport type ErrorInterceptor = (error: RestError) => RestError | Promise<RestError>;\n\nexport interface RequestOptions {\n headers?: Record<string, string>;\n signal?: AbortSignal;\n timeout?: number;\n}\n\nexport interface RestClient {\n get<T>(path: string, opts?: RequestOptions): Promise<RestResponse<T>>;\n post<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<RestResponse<T>>;\n put<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<RestResponse<T>>;\n patch<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<RestResponse<T>>;\n delete<T>(path: string, opts?: RequestOptions): Promise<RestResponse<T>>;\n}\n\n// ---------------------------------------------------------------------------\n// RestError\n// ---------------------------------------------------------------------------\n\nexport class RestError extends Error {\n public readonly status: number;\n public readonly statusText: string;\n public readonly data: unknown;\n public readonly config: RequestConfig;\n\n constructor(\n message: string,\n status: number,\n statusText: string,\n data: unknown,\n config: RequestConfig,\n ) {\n super(message);\n this.name = 'RestError';\n this.status = status;\n this.statusText = statusText;\n this.data = data;\n this.config = config;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nfunction parseResponseHeaders(headers: Headers): Record<string, string> {\n const result: Record<string, string> = {};\n headers.forEach((value, key) => {\n result[key] = value;\n });\n return result;\n}\n\nfunction buildURL(baseURL: string, path: string): string {\n const base = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;\n const rel = path.startsWith('/') ? path : '/' + path;\n return base + rel;\n}\n\n// ---------------------------------------------------------------------------\n// createRestClient\n// ---------------------------------------------------------------------------\n\nexport function createRestClient(config: RestClientConfig): RestClient {\n const {\n baseURL,\n headers: defaultHeaders = {},\n timeout: defaultTimeout,\n interceptors = {},\n } = config;\n\n const requestInterceptors = interceptors.request ?? [];\n const responseInterceptors = interceptors.response ?? [];\n const errorInterceptors = interceptors.error ?? [];\n\n async function request<T>(\n method: string,\n path: string,\n body?: unknown,\n opts?: RequestOptions,\n ): Promise<RestResponse<T>> {\n // Build initial request config\n let reqConfig: RequestConfig = {\n url: buildURL(baseURL, path),\n method,\n headers: {\n ...defaultHeaders,\n ...(opts?.headers ?? {}),\n },\n body,\n signal: opts?.signal,\n timeout: opts?.timeout ?? defaultTimeout,\n };\n\n // Add Content-Type for requests with a body\n if (body !== undefined && body !== null && !reqConfig.headers['Content-Type']) {\n reqConfig.headers['Content-Type'] = 'application/json';\n }\n\n // Run request interceptors\n for (const interceptor of requestInterceptors) {\n reqConfig = await interceptor(reqConfig);\n }\n\n // Set up timeout via AbortController\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n let controller: AbortController | undefined;\n\n if (reqConfig.timeout && reqConfig.timeout > 0) {\n controller = new AbortController();\n timeoutId = setTimeout(() => {\n controller!.abort();\n }, reqConfig.timeout);\n\n // If the caller already provided a signal, listen for its abort too\n if (reqConfig.signal) {\n const externalSignal = reqConfig.signal;\n if (externalSignal.aborted) {\n controller.abort();\n } else {\n externalSignal.addEventListener('abort', () => {\n controller!.abort();\n });\n }\n }\n }\n\n const fetchSignal = controller ? controller.signal : reqConfig.signal;\n\n // Build fetch init\n const fetchInit: RequestInit = {\n method: reqConfig.method,\n headers: reqConfig.headers,\n signal: fetchSignal,\n };\n\n if (body !== undefined && body !== null) {\n fetchInit.body = JSON.stringify(body);\n }\n\n let response: Response;\n try {\n assertSecureUrl(reqConfig.url);\n response = await fetch(reqConfig.url, fetchInit);\n } catch (err: unknown) {\n if (timeoutId !== undefined) {\n clearTimeout(timeoutId);\n }\n\n const isAbort = err instanceof DOMException && err.name === 'AbortError';\n const message = isAbort\n ? `Request timeout after ${reqConfig.timeout}ms`\n : err instanceof Error\n ? err.message\n : 'Network error';\n\n let restError = new RestError(message, 0, '', null, reqConfig);\n for (const interceptor of errorInterceptors) {\n restError = await interceptor(restError);\n }\n throw restError;\n }\n\n if (timeoutId !== undefined) {\n clearTimeout(timeoutId);\n }\n\n // Parse response body\n const contentType = response.headers.get('content-type') ?? '';\n let data: T;\n if (contentType.includes('application/json')) {\n data = (await response.json()) as T;\n } else {\n const text = await response.text();\n // Attempt JSON parse for responses without explicit content-type\n try {\n data = JSON.parse(text) as T;\n } catch {\n data = text as unknown as T;\n }\n }\n\n const parsedHeaders = parseResponseHeaders(response.headers);\n\n if (!response.ok) {\n let restError = new RestError(\n `Request failed with status ${response.status}`,\n response.status,\n response.statusText,\n data,\n reqConfig,\n );\n for (const interceptor of errorInterceptors) {\n restError = await interceptor(restError);\n }\n throw restError;\n }\n\n let restResponse: RestResponse<T> = {\n data,\n status: response.status,\n headers: parsedHeaders,\n ok: response.ok,\n };\n\n // Run response interceptors\n for (const interceptor of responseInterceptors) {\n restResponse = interceptor(restResponse as RestResponse<unknown>) as RestResponse<T>;\n }\n\n return restResponse;\n }\n\n return {\n get<T>(path: string, opts?: RequestOptions): Promise<RestResponse<T>> {\n return request<T>('GET', path, undefined, opts);\n },\n post<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<RestResponse<T>> {\n return request<T>('POST', path, body, opts);\n },\n put<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<RestResponse<T>> {\n return request<T>('PUT', path, body, opts);\n },\n patch<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<RestResponse<T>> {\n return request<T>('PATCH', path, body, opts);\n },\n delete<T>(path: string, opts?: RequestOptions): Promise<RestResponse<T>> {\n return request<T>('DELETE', path, undefined, opts);\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// useRest hook\n// ---------------------------------------------------------------------------\n\nexport interface UseRestOptions {\n method?: string;\n body?: unknown;\n deps?: readonly unknown[];\n enabled?: boolean;\n}\n\nexport interface UseRestResult<T> {\n data: T | null;\n loading: boolean;\n error: RestError | null;\n refetch: () => void;\n}\n\nexport function useRest<T>(\n client: RestClient,\n path: string,\n opts?: UseRestOptions,\n): UseRestResult<T> {\n const method = opts?.method ?? 'GET';\n const body = opts?.body;\n const deps = opts?.deps ?? [];\n const enabled = opts?.enabled ?? true;\n\n const [data, setData] = useState<T | null>(null);\n const [loading, setLoading] = useState<boolean>(enabled);\n const [error, setError] = useState<RestError | null>(null);\n const controllerRef = useRef<AbortController | null>(null);\n const mountedRef = useRef<boolean>(true);\n\n const fetchData = useCallback(() => {\n if (!enabled) {\n setLoading(false);\n return;\n }\n\n // Cancel any previous in-flight request\n if (controllerRef.current) {\n controllerRef.current.abort();\n }\n\n const controller = new AbortController();\n controllerRef.current = controller;\n\n setLoading(true);\n setError(null);\n\n const requestOpts: RequestOptions = { signal: controller.signal };\n\n let promise: Promise<RestResponse<T>>;\n const upperMethod = method.toUpperCase();\n if (upperMethod === 'POST') {\n promise = client.post<T>(path, body, requestOpts);\n } else if (upperMethod === 'PUT') {\n promise = client.put<T>(path, body, requestOpts);\n } else if (upperMethod === 'PATCH') {\n promise = client.patch<T>(path, body, requestOpts);\n } else if (upperMethod === 'DELETE') {\n promise = client.delete<T>(path, requestOpts);\n } else {\n promise = client.get<T>(path, requestOpts);\n }\n\n promise\n .then((response) => {\n if (mountedRef.current && !controller.signal.aborted) {\n setData(response.data);\n setLoading(false);\n }\n })\n .catch((err: unknown) => {\n if (mountedRef.current && !controller.signal.aborted) {\n setError(\n err instanceof RestError\n ? err\n : new RestError(err instanceof Error ? err.message : 'Unknown error', 0, '', null, {\n url: path,\n method: upperMethod,\n headers: {},\n }),\n );\n setLoading(false);\n }\n });\n }, [client, path, method, body, enabled, ...deps]);\n\n useEffect(() => {\n mountedRef.current = true;\n fetchData();\n\n return () => {\n mountedRef.current = false;\n if (controllerRef.current) {\n controllerRef.current.abort();\n }\n };\n }, [fetchData]);\n\n const refetch = useCallback(() => {\n fetchData();\n }, [fetchData]);\n\n return { data, loading, error, refetch };\n}\n", "// ============================================================================\n// SpecifyJS Protobuf / gRPC-Web Client\n// Zero third-party dependencies \u2014 wire format implemented from scratch.\n// ============================================================================\n// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport { useState, useEffect, useCallback, useRef } from '../hooks/index';\nimport { assertSecureUrl } from '../shared/secure-fetch';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type FieldType = 'int32' | 'uint32' | 'string' | 'bool' | 'bytes' | 'float64' | 'enum';\n\nexport interface FieldDescriptor {\n tag: number;\n type: FieldType;\n repeated?: boolean;\n}\n\nexport type FieldMap = Record<string, FieldDescriptor>;\n\nexport interface MessageType<T> {\n name: string;\n fields: FieldMap;\n encode(obj: T): Uint8Array;\n decode(bytes: Uint8Array): T;\n}\n\nexport interface GrpcWebClientConfig {\n baseURL: string;\n headers?: Record<string, string>;\n}\n\nexport interface GrpcWebClient {\n unary<Req, Res>(\n service: string,\n method: string,\n reqType: MessageType<Req>,\n resType: MessageType<Res>,\n request: Req,\n ): Promise<Res>;\n}\n\nexport interface UseProtoResult<T> {\n data: T | null;\n loading: boolean;\n error: Error | null;\n refetch: () => void;\n}\n\n// ---------------------------------------------------------------------------\n// Varint helpers\n// ---------------------------------------------------------------------------\n\n/** Encode an unsigned 32-bit integer as a varint into an array of bytes. */\nexport function encodeVarint(value: number): number[] {\n const bytes: number[] = [];\n // Treat as unsigned 32-bit\n let v = value >>> 0;\n while (v > 0x7f) {\n bytes.push((v & 0x7f) | 0x80);\n v >>>= 7;\n }\n bytes.push(v & 0x7f);\n return bytes;\n}\n\n/** Decode a varint from a Uint8Array starting at `offset`. Returns [value, newOffset]. */\nexport function decodeVarint(bytes: Uint8Array, offset: number): [number, number] {\n let result = 0;\n let shift = 0;\n let pos = offset;\n while (pos < bytes.length) {\n const b = bytes[pos]!;\n result |= (b & 0x7f) << shift;\n pos++;\n if ((b & 0x80) === 0) {\n return [result >>> 0, pos];\n }\n shift += 7;\n if (shift >= 35) {\n throw new Error('Varint too long');\n }\n }\n throw new Error('Unexpected end of data while decoding varint');\n}\n\n// ---------------------------------------------------------------------------\n// Wire-type helpers\n// ---------------------------------------------------------------------------\n\nconst WIRE_VARINT = 0;\nconst WIRE_64BIT = 1;\nconst WIRE_LENGTH_DELIMITED = 2;\n\nfunction wireTypeFor(type: FieldType): number {\n switch (type) {\n case 'int32':\n case 'uint32':\n case 'bool':\n case 'enum':\n return WIRE_VARINT;\n case 'float64':\n return WIRE_64BIT;\n case 'string':\n case 'bytes':\n return WIRE_LENGTH_DELIMITED;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Field encoding\n// ---------------------------------------------------------------------------\n\nfunction encodeFieldKey(tag: number, wireType: number): number[] {\n return encodeVarint((tag << 3) | wireType);\n}\n\nfunction encodeFieldValue(type: FieldType, value: unknown): number[] {\n switch (type) {\n case 'int32': {\n const n = value as number;\n // Signed int32 \u2014 use zig-zag? No, standard protobuf int32 just uses varint.\n // Negative int32 in proto uses 10-byte two's complement, but for simplicity\n // we treat as unsigned 32-bit (matching proto3 behavior for small negatives).\n return encodeVarint(n | 0);\n }\n case 'uint32':\n return encodeVarint((value as number) >>> 0);\n case 'bool':\n return encodeVarint(value ? 1 : 0);\n case 'enum':\n return encodeVarint((value as number) >>> 0);\n case 'float64': {\n const buf = new ArrayBuffer(8);\n new DataView(buf).setFloat64(0, value as number, true); // little-endian\n return Array.from(new Uint8Array(buf));\n }\n case 'string': {\n const encoded = new TextEncoder().encode(value as string);\n return [...encodeVarint(encoded.length), ...encoded];\n }\n case 'bytes': {\n const data = value as Uint8Array;\n return [...encodeVarint(data.length), ...data];\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Field decoding\n// ---------------------------------------------------------------------------\n\nfunction decodeFieldValue(\n type: FieldType,\n wireType: number,\n bytes: Uint8Array,\n offset: number,\n): [unknown, number] {\n switch (wireType) {\n case WIRE_VARINT: {\n const [val, newOffset] = decodeVarint(bytes, offset);\n switch (type) {\n case 'bool':\n return [val !== 0, newOffset];\n case 'int32':\n return [val | 0, newOffset]; // sign-extend\n case 'uint32':\n case 'enum':\n return [val >>> 0, newOffset];\n default:\n return [val, newOffset];\n }\n }\n case WIRE_64BIT: {\n if (offset + 8 > bytes.length) {\n throw new Error('Unexpected end of data while decoding 64-bit value');\n }\n const buf = new ArrayBuffer(8);\n const view = new Uint8Array(buf);\n for (let i = 0; i < 8; i++) {\n view[i] = bytes[offset + i] ?? 0;\n }\n const dv = new DataView(buf);\n return [dv.getFloat64(0, true), offset + 8];\n }\n case WIRE_LENGTH_DELIMITED: {\n const [len, dataStart] = decodeVarint(bytes, offset);\n if (dataStart + len > bytes.length) {\n throw new Error('Unexpected end of data while decoding length-delimited value');\n }\n const slice = bytes.slice(dataStart, dataStart + len);\n if (type === 'string') {\n return [new TextDecoder().decode(slice), dataStart + len];\n }\n // bytes\n return [slice, dataStart + len];\n }\n default:\n throw new Error(`Unknown wire type: ${wireType}`);\n }\n}\n\n// ---------------------------------------------------------------------------\n// defineMessage\n// ---------------------------------------------------------------------------\n\nexport function defineMessage<T>(name: string, fields: FieldMap): MessageType<T> {\n // Build lookup: tag -> { fieldName, descriptor }\n const tagToField = new Map<number, { fieldName: string; descriptor: FieldDescriptor }>();\n for (const [fieldName, descriptor] of Object.entries(fields)) {\n tagToField.set(descriptor.tag, { fieldName, descriptor });\n }\n\n function encode(obj: T): Uint8Array {\n const out: number[] = [];\n const record = obj as Record<string, unknown>;\n\n for (const [fieldName, descriptor] of Object.entries(fields)) {\n const value = record[fieldName];\n if (value === undefined || value === null) continue;\n\n const wt = wireTypeFor(descriptor.type);\n\n if (descriptor.repeated) {\n const arr = value as unknown[];\n for (const item of arr) {\n out.push(...encodeFieldKey(descriptor.tag, wt));\n out.push(...encodeFieldValue(descriptor.type, item));\n }\n } else {\n out.push(...encodeFieldKey(descriptor.tag, wt));\n out.push(...encodeFieldValue(descriptor.type, value));\n }\n }\n\n return new Uint8Array(out);\n }\n\n function decode(bytes: Uint8Array): T {\n const result: Record<string, unknown> = {};\n\n // Initialize repeated fields as empty arrays\n for (const [fieldName, descriptor] of Object.entries(fields)) {\n if (descriptor.repeated) {\n result[fieldName] = [];\n }\n }\n\n let offset = 0;\n while (offset < bytes.length) {\n const [keyVarint, newOffset] = decodeVarint(bytes, offset);\n const tag = keyVarint >>> 3;\n const wireType = keyVarint & 0x07;\n offset = newOffset;\n\n const entry = tagToField.get(tag);\n if (!entry) {\n // Skip unknown field\n offset = skipField(wireType, bytes, offset);\n continue;\n }\n\n const [value, nextOffset] = decodeFieldValue(entry.descriptor.type, wireType, bytes, offset);\n offset = nextOffset;\n\n if (entry.descriptor.repeated) {\n (result[entry.fieldName] as unknown[]).push(value);\n } else {\n result[entry.fieldName] = value;\n }\n }\n\n return result as T;\n }\n\n return { name, fields, encode, decode };\n}\n\n/** Skip an unknown field so parsing can continue. */\nfunction skipField(wireType: number, bytes: Uint8Array, offset: number): number {\n switch (wireType) {\n case WIRE_VARINT: {\n const [, next] = decodeVarint(bytes, offset);\n return next;\n }\n case WIRE_64BIT:\n return offset + 8;\n case WIRE_LENGTH_DELIMITED: {\n const [len, dataStart] = decodeVarint(bytes, offset);\n return dataStart + len;\n }\n default:\n throw new Error(`Cannot skip unknown wire type: ${wireType}`);\n }\n}\n\n// ---------------------------------------------------------------------------\n// gRPC-Web framing helpers\n// ---------------------------------------------------------------------------\n\n/** Encode a message into a gRPC-Web frame: [flags:1][length:4][data:N] */\nexport function encodeGrpcWebFrame(data: Uint8Array, flags: number = 0): Uint8Array {\n const frame = new Uint8Array(5 + data.length);\n frame[0] = flags;\n // Big-endian 4-byte length\n const dv = new DataView(frame.buffer, frame.byteOffset, frame.byteLength);\n dv.setUint32(1, data.length, false);\n frame.set(data, 5);\n return frame;\n}\n\n/** Decode the first gRPC-Web frame from bytes. Returns [flags, data, bytesConsumed]. */\nexport function decodeGrpcWebFrame(bytes: Uint8Array): [number, Uint8Array, number] {\n if (bytes.length < 5) {\n throw new Error('gRPC-Web frame too short');\n }\n const flags = bytes[0] ?? 0;\n const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const length = dv.getUint32(1, false);\n if (bytes.length < 5 + length) {\n throw new Error('gRPC-Web frame data incomplete');\n }\n const data = bytes.slice(5, 5 + length);\n return [flags, data, 5 + length] as [number, Uint8Array, number];\n}\n\n// ---------------------------------------------------------------------------\n// gRPC-Web client\n// ---------------------------------------------------------------------------\n\nexport function createGrpcWebClient(config: GrpcWebClientConfig): GrpcWebClient {\n const { baseURL, headers: extraHeaders } = config;\n\n async function unary<Req, Res>(\n service: string,\n method: string,\n reqType: MessageType<Req>,\n resType: MessageType<Res>,\n request: Req,\n ): Promise<Res> {\n const reqBytes = reqType.encode(request);\n const frame = encodeGrpcWebFrame(reqBytes);\n\n const url = `${baseURL.replace(/\\/+$/, '')}/${service}/${method}`;\n\n const hdrs: Record<string, string> = {\n 'Content-Type': 'application/grpc-web+proto',\n Accept: 'application/grpc-web+proto',\n 'X-Grpc-Web': '1',\n ...extraHeaders,\n };\n\n assertSecureUrl(url);\n const response = await fetch(url, {\n method: 'POST',\n headers: hdrs,\n body: frame.buffer as ArrayBuffer,\n });\n\n if (!response.ok) {\n throw new Error(`gRPC-Web request failed: ${response.status} ${response.statusText}`);\n }\n\n const responseBytes = new Uint8Array(await response.arrayBuffer());\n\n // The response contains one or more gRPC-Web frames.\n // The first frame with flags === 0 contains the data.\n let offset = 0;\n while (offset < responseBytes.length) {\n const [flags, data, consumed] = decodeGrpcWebFrame(responseBytes.subarray(offset));\n offset += consumed;\n\n // flags === 0 means data frame, flags & 0x80 means trailers\n if ((flags & 0x80) === 0) {\n return resType.decode(data);\n }\n }\n\n throw new Error('No data frame found in gRPC-Web response');\n }\n\n return { unary };\n}\n\n// ---------------------------------------------------------------------------\n// useProto hook\n// ---------------------------------------------------------------------------\n\nexport function useProto<Req, Res>(\n client: GrpcWebClient,\n service: string,\n method: string,\n reqType: MessageType<Req>,\n resType: MessageType<Res>,\n request: Req,\n opts?: { enabled?: boolean },\n): UseProtoResult<Res> {\n const [data, setData] = useState<Res | null>(null);\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n const mountedRef = useRef(true);\n const requestRef = useRef(request);\n requestRef.current = request;\n\n const enabled = opts?.enabled !== false;\n\n const refetch = useCallback(() => {\n if (!enabled) return;\n\n setLoading(true);\n setError(null);\n\n client\n .unary(service, method, reqType, resType, requestRef.current)\n .then((res) => {\n if (mountedRef.current) {\n setData(res);\n setLoading(false);\n }\n })\n .catch((err: unknown) => {\n if (mountedRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setLoading(false);\n }\n });\n }, [client, service, method, reqType, resType, enabled]);\n\n useEffect(() => {\n mountedRef.current = true;\n refetch();\n return () => {\n mountedRef.current = false;\n };\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n", "// ============================================================================\n// SpecifyJS GraphQL Client \u2014 Zero-dependency native GraphQL client\n// ============================================================================\n// (c) 2025-2026 Asymmetric Effort, LLC. MIT LICENSE\n// SPDX-License-Identifier: MIT\n\nimport { useState, useEffect, useRef, useCallback } from '../hooks/index';\nimport { assertSecureUrl } from '../shared/secure-fetch';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface GraphQLError {\n message: string;\n locations?: { line: number; column: number }[];\n path?: (string | number)[];\n}\n\nexport interface GraphQLResponse<T> {\n data: T | null;\n errors: GraphQLError[] | null;\n extensions?: Record<string, unknown>;\n}\n\nexport interface GraphQLClientConfig {\n url: string;\n headers?: Record<string, string>;\n credentials?: RequestCredentials;\n cache?: boolean;\n}\n\nexport interface GraphQLClient {\n query<T>(query: string, variables?: Record<string, unknown>): Promise<GraphQLResponse<T>>;\n mutate<T>(mutation: string, variables?: Record<string, unknown>): Promise<GraphQLResponse<T>>;\n clearCache(): void;\n invalidate(query: string): void;\n}\n\nexport interface UseQueryOptions {\n variables?: Record<string, unknown>;\n deps?: readonly unknown[];\n enabled?: boolean;\n cache?: boolean;\n}\n\nexport interface UseQueryResult<T> {\n data: T | null;\n loading: boolean;\n error: GraphQLError[] | null;\n refetch: () => void;\n}\n\n// ---------------------------------------------------------------------------\n// gql template tag\n// ---------------------------------------------------------------------------\n\n/**\n * Tagged template literal for GraphQL queries.\n * Returns the query string as-is. Provides editor syntax highlighting support.\n */\nexport function gql(strings: TemplateStringsArray, ...values: unknown[]): string {\n let result = '';\n for (let i = 0; i < strings.length; i++) {\n result += strings[i];\n if (i < values.length) {\n const val = String(values[i]);\n // Reject interpolated values with GraphQL metacharacters to prevent injection\n if (/[{}():]/.test(val)) {\n throw new Error(\n `[SpecifyJS] gql: Interpolated value \"${val}\" contains GraphQL metacharacters ({, }, (, ), :). ` +\n 'Use the variables parameter instead of string interpolation to prevent injection.',\n );\n }\n result += val;\n }\n }\n return result.replace(/\\s+/g, ' ').trim();\n}\n\n// ---------------------------------------------------------------------------\n// createGraphQLClient\n// ---------------------------------------------------------------------------\n\n/**\n * Factory function that creates a GraphQL client instance.\n */\nexport function createGraphQLClient(config: GraphQLClientConfig): GraphQLClient {\n const { url, headers: configHeaders, credentials, cache: cacheEnabled = false } = config;\n\n const MAX_CACHE_SIZE = 100;\n const responseCache = new Map<string, GraphQLResponse<unknown>>();\n\n function buildCacheKey(query: string, variables?: Record<string, unknown>): string {\n return JSON.stringify({ query, variables });\n }\n\n async function execute<T>(\n query: string,\n variables?: Record<string, unknown>,\n ): Promise<GraphQLResponse<T>> {\n const reqHeaders: Record<string, string> = {\n 'Content-Type': 'application/json',\n ...configHeaders,\n };\n\n const body = JSON.stringify({ query, variables });\n\n assertSecureUrl(url);\n const response = await fetch(url, {\n method: 'POST',\n headers: reqHeaders,\n credentials,\n body,\n });\n\n if (!response.ok) {\n throw new Error(`GraphQL request failed with status ${response.status}`);\n }\n\n const json = (await response.json()) as GraphQLResponse<T>;\n\n return {\n data: json.data ?? null,\n errors: json.errors ?? null,\n ...(json.extensions !== undefined ? { extensions: json.extensions } : {}),\n };\n }\n\n const client: GraphQLClient = {\n async query<T>(\n query: string,\n variables?: Record<string, unknown>,\n ): Promise<GraphQLResponse<T>> {\n if (cacheEnabled) {\n const key = buildCacheKey(query, variables);\n const cached = responseCache.get(key);\n if (cached) {\n return cached as GraphQLResponse<T>;\n }\n const result = await execute<T>(query, variables);\n if (responseCache.size >= MAX_CACHE_SIZE) {\n const oldest = responseCache.keys().next().value;\n if (oldest !== undefined) responseCache.delete(oldest);\n }\n responseCache.set(key, result);\n return result;\n }\n return execute<T>(query, variables);\n },\n\n async mutate<T>(\n mutation: string,\n variables?: Record<string, unknown>,\n ): Promise<GraphQLResponse<T>> {\n return execute<T>(mutation, variables);\n },\n\n clearCache(): void {\n responseCache.clear();\n },\n\n invalidate(query: string): void {\n for (const key of responseCache.keys()) {\n try {\n const parsed = JSON.parse(key) as { query: string };\n if (parsed.query === query) {\n responseCache.delete(key);\n }\n } catch {\n // skip malformed keys\n }\n }\n },\n };\n\n return client;\n}\n\n// ---------------------------------------------------------------------------\n// useQuery hook\n// ---------------------------------------------------------------------------\n\n/**\n * Hook for executing GraphQL queries with automatic fetching.\n * Auto-fetches on mount and when deps change.\n */\nexport function useQuery<T>(\n client: GraphQLClient,\n query: string,\n opts?: UseQueryOptions,\n): UseQueryResult<T> {\n const variables = opts?.variables;\n const deps = opts?.deps;\n const enabled = opts?.enabled ?? true;\n\n const [data, setData] = useState<T | null>(null);\n const [loading, setLoading] = useState<boolean>(enabled);\n const [error, setError] = useState<GraphQLError[] | null>(null);\n\n const fetchIdRef = useRef(0);\n\n const fetchData = useCallback(() => {\n if (!enabled) return;\n\n const id = ++fetchIdRef.current;\n setLoading(true);\n setError(null);\n\n client\n .query<T>(query, variables)\n .then((result) => {\n if (fetchIdRef.current !== id) return;\n setData(result.data);\n setError(result.errors);\n setLoading(false);\n })\n .catch((err: unknown) => {\n if (fetchIdRef.current !== id) return;\n setError([{ message: err instanceof Error ? err.message : String(err) }]);\n setLoading(false);\n });\n }, [client, query, variables, enabled]);\n\n const effectDeps = deps ? [fetchData, ...deps] : [fetchData];\n\n useEffect(() => {\n fetchData();\n }, effectDeps);\n\n return { data, loading, error, refetch: fetchData };\n}\n\n// ---------------------------------------------------------------------------\n// useMutation hook\n// ---------------------------------------------------------------------------\n\n/**\n * Hook for executing GraphQL mutations.\n * Does not auto-fire; only executes on explicit call.\n */\nexport function useMutation<T>(\n client: GraphQLClient,\n mutation: string,\n): [\n (variables?: Record<string, unknown>) => Promise<GraphQLResponse<T>>,\n { data: T | null; loading: boolean; error: GraphQLError[] | null },\n] {\n const [data, setData] = useState<T | null>(null);\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<GraphQLError[] | null>(null);\n\n const mutateFn = async (variables?: Record<string, unknown>): Promise<GraphQLResponse<T>> => {\n setLoading(true);\n setError(null);\n\n try {\n const result = await client.mutate<T>(mutation, variables);\n setData(result.data);\n setError(result.errors);\n setLoading(false);\n return result;\n } catch (err: unknown) {\n const errors: GraphQLError[] = [\n { message: err instanceof Error ? err.message : String(err) },\n ];\n setError(errors);\n setLoading(false);\n return { data: null, errors, extensions: undefined };\n }\n };\n\n const mutate = useCallback(\n ((...args: unknown[]) => mutateFn(args[0] as Record<string, unknown> | undefined)) as (\n ...args: unknown[]\n ) => unknown,\n [client, mutation],\n ) as unknown as (variables?: Record<string, unknown>) => Promise<GraphQLResponse<T>>;\n\n return [mutate, { data, loading, error }];\n}\n"],
|
|
5
|
-
"mappings": ";ibAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,eAAAE,EAAA,wBAAAC,EAAA,wBAAAC,EAAA,qBAAAC,EAAA,kBAAAC,EAAA,QAAAC,EAAA,gBAAAC,EAAA,aAAAC,EAAA,aAAAC,EAAA,YAAAC,IAAA,eAAAC,GAAAZ,IC2BA,IAAIa,EAAuC,KAU3C,SAASC,GAAgC,CACvC,GAAIC,IAAsB,KACxB,MAAM,IAAI,MACR,sFACF,EAEF,OAAOA,CACT,CAEO,SAASC,EACdC,EAC6C,CAC7C,OAAOH,EAAkB,EAAE,SAASG,CAAY,CAClD,CAEO,SAASC,EAAUC,EAAmCC,EAAiC,CAC5F,OAAON,EAAkB,EAAE,UAAUK,EAAQC,CAAI,CACnD,CAeO,SAASC,EACdC,EACAC,EACG,CACH,OAAOC,EAAkB,EAAE,YAAYF,EAAUC,CAAI,CACvD,CASO,SAASE,EAAUC,EAA8C,CACtE,OAAOC,EAAkB,EAAE,OAAOD,CAAY,CAChD,CClEO,SAASE,EAAgBC,EAAmB,CAEjD,GAAIA,EAAI,WAAW,IAAI,EACrB,MAAM,IAAI,MACR,gDAAgDA,CAAG,qCACrD,EAIF,GAAIA,EAAI,WAAW,GAAG,GAAKA,EAAI,WAAW,IAAI,GAAKA,EAAI,WAAW,KAAK,EACrE,OAIF,GAAIA,EAAI,WAAW,OAAO,EAAG,CAC3B,GAAIA,EAAI,OAAS,KAAO,KACtB,MAAM,IAAI,MAAM,sDAAsD,EAExE,MACF,CAGA,IAAIC,EACJ,GAAI,CACFA,EAAS,IAAI,IAAID,EAAK,OAAO,OAAW,IAAc,OAAO,SAAS,KAAO,MAAS,CACxF,MAAQ,CACN,MAAM,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R,EAAQb,EAAOC,EAAWe,CAAO,CAAC,EAEhCc,EAAaf,EAAO,CAACW,EAAW,GAAGX,CAAI,EAAI,CAACW,CAAS,EAE3D,OAAAK,EAAU,IAAM,CACdL,EAAU,CACZ,EAAGI,CAAU,EAEN,CAAE,KAAAb,EAAM,QAAAG,EAAS,MAAAE,EAAO,QAASI,CAAU,CACpD,CAUO,SAASM,EACdnB,EACAF,EAIA,CACA,GAAM,CAACM,EAAMC,CAAO,EAAIC,EAAmB,IAAI,EACzC,CAACC,EAASC,CAAU,EAAIF,EAAkB,EAAK,EAC/C,CAACG,EAAOC,CAAQ,EAAIJ,EAAgC,IAAI,EAExDc,EAAW,MAAOhC,GAAqE,CAC3FoB,EAAW,EAAI,EACfE,EAAS,IAAI,EAEb,GAAI,CACF,IAAMnC,EAAS,MAAMyB,EAAO,OAAUF,EAAUV,CAAS,EACzD,OAAAiB,EAAQ9B,EAAO,IAAI,EACnBmC,EAASnC,EAAO,MAAM,EACtBiC,EAAW,EAAK,EACTjC,CACT,OAASyC,EAAc,CACrB,IAAMK,EAAyB,CAC7B,CAAE,QAASL,aAAe,MAAQA,EAAI,QAAU,OAAOA,CAAG,CAAE,CAC9D,EACA,OAAAN,EAASW,CAAM,EACfb,EAAW,EAAK,EACT,CAAE,KAAM,KAAM,OAAAa,EAAQ,WAAY,MAAU,CACrD,CACF,EASA,MAAO,CAPQP,GACZ,IAAIQ,IAAoBF,EAASE,EAAK,CAAC,CAAwC,GAGhF,CAACtB,EAAQF,CAAQ,CACnB,EAEgB,CAAE,KAAAM,EAAM,QAAAG,EAAS,MAAAE,CAAM,CAAC,CAC1C",
|
|
6
|
-
"names": ["index_exports", "__export", "RestError", "createGraphQLClient", "createGrpcWebClient", "createRestClient", "defineMessage", "gql", "useMutation", "useProto", "useQuery", "useRest", "__toCommonJS", "currentDispatcher", "resolveDispatcher", "currentDispatcher", "useState", "initialState", "useEffect", "create", "deps", "useCallback", "callback", "deps", "resolveDispatcher", "useRef", "initialValue", "resolveDispatcher", "assertSecureUrl", "url", "parsed", "RestError", "message", "status", "statusText", "data", "config", "parseResponseHeaders", "headers", "result", "value", "key", "buildURL", "baseURL", "path", "base", "rel", "createRestClient", "defaultHeaders", "defaultTimeout", "interceptors", "requestInterceptors", "responseInterceptors", "errorInterceptors", "request", "method", "body", "opts", "reqConfig", "interceptor", "timeoutId", "controller", "externalSignal", "fetchSignal", "fetchInit", "response", "assertSecureUrl", "err", "restError", "contentType", "text", "parsedHeaders", "restResponse", "useRest", "client", "deps", "enabled", "setData", "useState", "loading", "setLoading", "error", "setError", "controllerRef", "useRef", "mountedRef", "fetchData", "useCallback", "requestOpts", "promise", "upperMethod", "useEffect", "refetch", "encodeVarint", "value", "bytes", "v", "decodeVarint", "offset", "result", "shift", "pos", "b", "WIRE_VARINT", "WIRE_64BIT", "WIRE_LENGTH_DELIMITED", "wireTypeFor", "type", "encodeFieldKey", "tag", "wireType", "encodeFieldValue", "buf", "encoded", "data", "decodeFieldValue", "val", "newOffset", "view", "i", "len", "dataStart", "slice", "defineMessage", "name", "fields", "tagToField", "fieldName", "descriptor", "encode", "obj", "out", "record", "wt", "arr", "item", "decode", "keyVarint", "entry", "skipField", "nextOffset", "next", "encodeGrpcWebFrame", "flags", "frame", "decodeGrpcWebFrame", "length", "createGrpcWebClient", "config", "baseURL", "extraHeaders", "unary", "service", "method", "reqType", "resType", "request", "reqBytes", "url", "hdrs", "assertSecureUrl", "response", "responseBytes", "consumed", "useProto", "client", "opts", "setData", "useState", "loading", "setLoading", "error", "setError", "mountedRef", "useRef", "requestRef", "enabled", "refetch", "useCallback", "res", "err", "useEffect", "gql", "strings", "values", "result", "i", "val", "createGraphQLClient", "config", "url", "configHeaders", "credentials", "cacheEnabled", "MAX_CACHE_SIZE", "responseCache", "buildCacheKey", "query", "variables", "execute", "reqHeaders", "body", "assertSecureUrl", "response", "json", "key", "cached", "oldest", "mutation", "useQuery", "client", "opts", "deps", "enabled", "data", "setData", "useState", "loading", "setLoading", "error", "setError", "fetchIdRef", "useRef", "fetchData", "useCallback", "id", "err", "effectDeps", "useEffect", "useMutation", "mutateFn", "errors", "args"]
|
|
7
|
-
}
|