veryfront 0.1.128 → 0.1.129
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/esm/cli/router.d.ts +0 -5
- package/esm/cli/router.d.ts.map +1 -1
- package/esm/cli/router.js +30 -2
- package/esm/cli/shared/update-check.d.ts +4 -0
- package/esm/cli/shared/update-check.d.ts.map +1 -0
- package/esm/cli/shared/update-check.js +97 -0
- package/esm/deno.d.ts +5 -0
- package/esm/deno.js +13 -8
- package/esm/src/channels/control-plane.d.ts.map +1 -1
- package/esm/src/channels/control-plane.js +5 -5
- package/esm/src/channels/invoke.d.ts +1 -1
- package/esm/src/channels/invoke.d.ts.map +1 -1
- package/esm/src/channels/invoke.js +6 -6
- package/esm/src/chat/index.d.ts +12 -24
- package/esm/src/chat/index.d.ts.map +1 -1
- package/esm/src/chat/index.js +5 -25
- package/esm/src/config/env.d.ts.map +1 -1
- package/esm/src/config/env.js +18 -10
- package/esm/src/data/static-data-fetcher.d.ts +3 -0
- package/esm/src/data/static-data-fetcher.d.ts.map +1 -1
- package/esm/src/data/static-data-fetcher.js +29 -25
- package/esm/src/data/static-paths-fetcher.d.ts.map +1 -1
- package/esm/src/data/static-paths-fetcher.js +3 -2
- package/esm/src/errors/logging.d.ts.map +1 -1
- package/esm/src/errors/logging.js +16 -7
- package/esm/src/errors/user-friendly/error-formatter.d.ts.map +1 -1
- package/esm/src/errors/user-friendly/error-formatter.js +9 -25
- package/esm/src/fs/index.d.ts +11 -12
- package/esm/src/fs/index.d.ts.map +1 -1
- package/esm/src/fs/index.js +11 -24
- package/esm/src/html/dev-scripts.d.ts.map +1 -1
- package/esm/src/html/dev-scripts.js +5 -8
- package/esm/src/html/html-escape.d.ts +1 -0
- package/esm/src/html/html-escape.d.ts.map +1 -1
- package/esm/src/html/html-escape.js +3 -0
- package/esm/src/html/html-injection.js +2 -2
- package/esm/src/html/html-shell-generator.d.ts +5 -2
- package/esm/src/html/html-shell-generator.d.ts.map +1 -1
- package/esm/src/html/html-shell-generator.js +41 -30
- package/esm/src/html/hydration-script-builder/dev-client-renderer.js +2 -2
- package/esm/src/html/hydration-script-builder/dev-component-manifest.js +2 -2
- package/esm/src/html/hydration-script-builder/dev-error-logger.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/dev-error-logger.js +2 -6
- package/esm/src/html/hydration-script-builder/dev-scripts.js +2 -2
- package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts +3 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.js +2 -2
- package/esm/src/html/hydration-script-builder/index.d.ts +1 -1
- package/esm/src/html/hydration-script-builder/index.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/index.js +1 -1
- package/esm/src/html/hydration-script-builder/prod-hydration.js +2 -2
- package/esm/src/html/hydration-script-builder/prod-scripts.d.ts +2 -0
- package/esm/src/html/hydration-script-builder/prod-scripts.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/prod-scripts.js +14 -14
- package/esm/src/html/schemas/html.schema.d.ts +2 -0
- package/esm/src/html/schemas/html.schema.d.ts.map +1 -1
- package/esm/src/html/schemas/html.schema.js +2 -0
- package/esm/src/html/styles-builder/css-pregeneration.d.ts +17 -1
- package/esm/src/html/styles-builder/css-pregeneration.d.ts.map +1 -1
- package/esm/src/html/styles-builder/css-pregeneration.js +103 -1
- package/esm/src/html/styles-builder/dev-styles.js +2 -2
- package/esm/src/html/utils.d.ts +2 -0
- package/esm/src/html/utils.d.ts.map +1 -1
- package/esm/src/html/utils.js +49 -28
- package/esm/src/integrations/remote-tools.d.ts.map +1 -1
- package/esm/src/integrations/remote-tools.js +32 -39
- package/esm/src/internal-agents/ag-ui-sse.d.ts +0 -1
- package/esm/src/internal-agents/ag-ui-sse.d.ts.map +1 -1
- package/esm/src/internal-agents/ag-ui-sse.js +2 -16
- package/esm/src/internal-agents/control-plane-auth.d.ts.map +1 -1
- package/esm/src/internal-agents/control-plane-auth.js +5 -3
- package/esm/src/internal-agents/request-body.d.ts.map +1 -1
- package/esm/src/internal-agents/request-body.js +6 -3
- package/esm/src/internal-agents/session-manager.d.ts +1 -0
- package/esm/src/internal-agents/session-manager.d.ts.map +1 -1
- package/esm/src/internal-agents/session-manager.js +12 -18
- package/esm/src/issues/core.d.ts.map +1 -1
- package/esm/src/issues/core.js +24 -23
- package/esm/src/issues/schemas/issue.schema.d.ts.map +1 -1
- package/esm/src/issues/schemas/issue.schema.js +2 -1
- package/esm/src/jobs/runtime-env.d.ts.map +1 -1
- package/esm/src/jobs/runtime-env.js +21 -44
- package/esm/src/markdown/index.d.ts +1 -2
- package/esm/src/markdown/index.d.ts.map +1 -1
- package/esm/src/markdown/index.js +1 -6
- package/esm/src/mcp/server.d.ts +0 -1
- package/esm/src/mcp/server.d.ts.map +1 -1
- package/esm/src/mcp/server.js +40 -41
- package/esm/src/mdx/index.d.ts +3 -2
- package/esm/src/mdx/index.d.ts.map +1 -1
- package/esm/src/mdx/index.js +3 -5
- package/esm/src/middleware/builtin/logger.d.ts.map +1 -1
- package/esm/src/middleware/builtin/logger.js +31 -28
- package/esm/src/middleware/builtin/security/rate-limit.d.ts.map +1 -1
- package/esm/src/middleware/builtin/security/rate-limit.js +17 -12
- package/esm/src/middleware/builtin/timeout.d.ts.map +1 -1
- package/esm/src/middleware/builtin/timeout.js +17 -10
- package/esm/src/modules/import-map/default-import-map.d.ts.map +1 -1
- package/esm/src/modules/import-map/default-import-map.js +4 -3
- package/esm/src/oauth/handlers/callback-handler.d.ts +0 -5
- package/esm/src/oauth/handlers/callback-handler.d.ts.map +1 -1
- package/esm/src/oauth/handlers/callback-handler.js +9 -14
- package/esm/src/oauth/handlers/index.d.ts +1 -1
- package/esm/src/oauth/handlers/index.js +1 -1
- package/esm/src/oauth/handlers/init-handler.d.ts.map +1 -1
- package/esm/src/oauth/handlers/init-handler.js +32 -20
- package/esm/src/oauth/providers/index.d.ts +1 -1
- package/esm/src/oauth/providers/index.js +1 -1
- package/esm/src/oauth/schemas/index.d.ts +1 -1
- package/esm/src/oauth/schemas/index.js +1 -1
- package/esm/src/oauth/token-store/index.d.ts +1 -1
- package/esm/src/oauth/token-store/index.js +1 -1
- package/esm/src/oauth/token-store/memory.d.ts +1 -1
- package/esm/src/oauth/token-store/memory.d.ts.map +1 -1
- package/esm/src/oauth/token-store/memory.js +8 -8
- package/esm/src/observability/request-profiler.d.ts +31 -0
- package/esm/src/observability/request-profiler.d.ts.map +1 -0
- package/esm/src/observability/request-profiler.js +94 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -1
- package/esm/src/observability/tracing/otlp-setup.js +16 -21
- package/esm/src/prompt/factory.d.ts.map +1 -1
- package/esm/src/prompt/factory.js +10 -12
- package/esm/src/prompt/registry.d.ts.map +1 -1
- package/esm/src/prompt/registry.js +12 -10
- package/esm/src/prompt/schemas/prompt.schema.d.ts.map +1 -1
- package/esm/src/prompt/schemas/prompt.schema.js +0 -2
- package/esm/src/prompt/types.d.ts +1 -1
- package/esm/src/prompt/types.d.ts.map +1 -1
- package/esm/src/provider/local/ai-sdk-adapter.d.ts.map +1 -1
- package/esm/src/provider/local/ai-sdk-adapter.js +3 -8
- package/esm/src/provider/local/env.d.ts +4 -6
- package/esm/src/provider/local/env.d.ts.map +1 -1
- package/esm/src/provider/local/env.js +14 -1
- package/esm/src/provider/local/local-engine.d.ts.map +1 -1
- package/esm/src/provider/local/local-engine.js +2 -7
- package/esm/src/provider/model-registry.d.ts.map +1 -1
- package/esm/src/provider/model-registry.js +2 -7
- package/esm/src/provider/veryfront-cloud/provider.d.ts.map +1 -1
- package/esm/src/provider/veryfront-cloud/provider.js +1 -7
- package/esm/src/provider/veryfront-cloud/shared.d.ts.map +1 -1
- package/esm/src/provider/veryfront-cloud/shared.js +9 -11
- package/esm/src/proxy/handler.d.ts.map +1 -1
- package/esm/src/proxy/handler.js +56 -57
- package/esm/src/react/compat/hooks-adapter.d.ts +1 -7
- package/esm/src/react/compat/hooks-adapter.d.ts.map +1 -1
- package/esm/src/react/compat/hooks-adapter.js +35 -40
- package/esm/src/react/components/Head.d.ts +1 -26
- package/esm/src/react/components/Head.d.ts.map +1 -1
- package/esm/src/react/components/Head.js +1 -172
- package/esm/src/react/context/index.d.ts +2 -46
- package/esm/src/react/context/index.d.ts.map +1 -1
- package/esm/src/react/context/index.js +1 -44
- package/esm/src/react/head-collector.d.ts +1 -10
- package/esm/src/react/head-collector.d.ts.map +1 -1
- package/esm/src/react/head-collector.js +4 -0
- package/esm/src/react/router/index.d.ts +2 -45
- package/esm/src/react/router/index.d.ts.map +1 -1
- package/esm/src/react/router/index.js +1 -49
- package/esm/src/react/runtime/core.d.ts +49 -0
- package/esm/src/react/runtime/core.d.ts.map +1 -0
- package/esm/src/react/runtime/core.js +200 -0
- package/esm/src/rendering/orchestrator/html.d.ts +2 -0
- package/esm/src/rendering/orchestrator/html.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/html.js +69 -12
- package/esm/src/rendering/orchestrator/ssr-orchestrator.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/ssr-orchestrator.js +4 -0
- package/esm/src/rendering/orchestrator/types.d.ts +4 -0
- package/esm/src/rendering/orchestrator/types.d.ts.map +1 -1
- package/esm/src/repositories/types.d.ts.map +1 -1
- package/esm/src/resource/factory.d.ts.map +1 -1
- package/esm/src/resource/factory.js +12 -9
- package/esm/src/resource/registry.d.ts +3 -3
- package/esm/src/resource/registry.d.ts.map +1 -1
- package/esm/src/resource/registry.js +7 -7
- package/esm/src/schemas/common.d.ts.map +1 -1
- package/esm/src/schemas/common.js +7 -4
- package/esm/src/security/http/config.d.ts +0 -1
- package/esm/src/security/http/config.d.ts.map +1 -1
- package/esm/src/security/http/config.js +3 -16
- package/esm/src/security/http/response/security-handler.d.ts +1 -0
- package/esm/src/security/http/response/security-handler.d.ts.map +1 -1
- package/esm/src/security/http/response/security-handler.js +17 -12
- package/esm/src/security/index.d.ts +4 -2
- package/esm/src/security/index.d.ts.map +1 -1
- package/esm/src/security/index.js +3 -1
- package/esm/src/server/handlers/dev/styles-css.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/styles-css.handler.js +8 -7
- package/esm/src/server/handlers/monitoring/metrics.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/monitoring/metrics.handler.js +3 -1
- package/esm/src/server/handlers/request/module/module-server-handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/module/module-server-handler.js +18 -15
- package/esm/src/server/handlers/request/prod-hydration-module.handler.d.ts +8 -0
- package/esm/src/server/handlers/request/prod-hydration-module.handler.d.ts.map +1 -0
- package/esm/src/server/handlers/request/prod-hydration-module.handler.js +41 -0
- package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/ssr/ssr.handler.js +3 -0
- package/esm/src/server/production-server.d.ts.map +1 -1
- package/esm/src/server/production-server.js +65 -0
- package/esm/src/server/runtime-handler/handler-context-builder.d.ts +1 -1
- package/esm/src/server/runtime-handler/handler-context-builder.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/index.d.ts +1 -1
- package/esm/src/server/runtime-handler/index.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/index.js +36 -11
- package/esm/src/server/runtime-handler/request-utils.d.ts +7 -0
- package/esm/src/server/runtime-handler/request-utils.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/request-utils.js +10 -0
- package/esm/src/server/services/rendering/ssr.service.d.ts +1 -0
- package/esm/src/server/services/rendering/ssr.service.d.ts.map +1 -1
- package/esm/src/server/services/rendering/ssr.service.js +12 -5
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
- package/esm/src/skill/allowed-tools.d.ts +3 -8
- package/esm/src/skill/allowed-tools.d.ts.map +1 -1
- package/esm/src/skill/executor.js +2 -2
- package/esm/src/skill/parser.d.ts.map +1 -1
- package/esm/src/skill/parser.js +12 -12
- package/esm/src/skill/path-safety.js +1 -1
- package/esm/src/skill/tools.d.ts.map +1 -1
- package/esm/src/skill/tools.js +18 -11
- package/esm/src/studio/bridge/bridge-bundle.generated.d.ts.map +1 -1
- package/esm/src/studio/bridge/bridge-bundle.generated.js +1 -1
- package/esm/src/task/discovery.d.ts.map +1 -1
- package/esm/src/task/discovery.js +73 -95
- package/esm/src/tool/executor.d.ts.map +1 -1
- package/esm/src/tool/executor.js +8 -7
- package/esm/src/tool/factory.d.ts.map +1 -1
- package/esm/src/tool/factory.js +13 -16
- package/esm/src/transforms/esm/package-registry.d.ts +4 -0
- package/esm/src/transforms/esm/package-registry.d.ts.map +1 -1
- package/esm/src/transforms/esm/package-registry.js +34 -17
- package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.js +2 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.js +26 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.js +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.js +3 -0
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.d.ts +1 -1
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.js +1 -1
- package/esm/src/transforms/veryfront-module-urls.d.ts.map +1 -1
- package/esm/src/transforms/veryfront-module-urls.js +7 -3
- package/esm/src/types/entities/getEntityInfo.d.ts.map +1 -1
- package/esm/src/types/entities/getEntityInfo.js +79 -127
- package/esm/src/utils/path-utils.d.ts +1 -1
- package/esm/src/utils/path-utils.d.ts.map +1 -1
- package/esm/src/utils/path-utils.js +16 -7
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/esm/src/utils/version.d.ts.map +1 -1
- package/esm/src/utils/version.js +0 -1
- package/esm/src/workflow/worker/dynamic-job-entrypoint.d.ts.map +1 -1
- package/esm/src/workflow/worker/dynamic-job-entrypoint.js +5 -72
- package/esm/src/workflow/worker/job-entrypoint.d.ts.map +1 -1
- package/esm/src/workflow/worker/job-entrypoint.js +5 -72
- package/esm/src/workflow/worker/shared.d.ts +18 -0
- package/esm/src/workflow/worker/shared.d.ts.map +1 -0
- package/esm/src/workflow/worker/shared.js +77 -0
- package/package.json +1 -1
- package/src/cli/router.ts +41 -2
- package/src/cli/shared/update-check.ts +110 -0
- package/src/deno.js +13 -8
- package/src/src/channels/control-plane.ts +6 -10
- package/src/src/channels/invoke.ts +7 -7
- package/src/src/chat/index.ts +96 -132
- package/src/src/config/env.ts +24 -11
- package/src/src/data/static-data-fetcher.ts +59 -34
- package/src/src/data/static-paths-fetcher.ts +4 -2
- package/src/src/errors/logging.ts +21 -7
- package/src/src/errors/user-friendly/error-formatter.ts +14 -29
- package/src/src/fs/index.ts +21 -30
- package/src/src/html/dev-scripts.ts +5 -9
- package/src/src/html/html-escape.ts +4 -0
- package/src/src/html/html-injection.ts +2 -2
- package/src/src/html/html-shell-generator.ts +60 -26
- package/src/src/html/hydration-script-builder/dev-client-renderer.ts +2 -2
- package/src/src/html/hydration-script-builder/dev-component-manifest.ts +2 -2
- package/src/src/html/hydration-script-builder/dev-error-logger.ts +2 -8
- package/src/src/html/hydration-script-builder/dev-scripts.ts +2 -2
- package/src/src/html/hydration-script-builder/hydration-data-generator.ts +2 -1
- package/src/src/html/hydration-script-builder/index.ts +5 -1
- package/src/src/html/hydration-script-builder/prod-hydration.ts +2 -2
- package/src/src/html/hydration-script-builder/prod-scripts.ts +16 -15
- package/src/src/html/schemas/html.schema.ts +2 -0
- package/src/src/html/styles-builder/css-pregeneration.ts +133 -1
- package/src/src/html/styles-builder/dev-styles.ts +2 -2
- package/src/src/html/utils.ts +62 -29
- package/src/src/integrations/remote-tools.ts +39 -37
- package/src/src/internal-agents/ag-ui-sse.ts +2 -17
- package/src/src/internal-agents/control-plane-auth.ts +8 -6
- package/src/src/internal-agents/request-body.ts +7 -5
- package/src/src/internal-agents/session-manager.ts +16 -20
- package/src/src/issues/core.ts +24 -27
- package/src/src/issues/schemas/issue.schema.ts +3 -1
- package/src/src/jobs/runtime-env.ts +24 -50
- package/src/src/markdown/index.ts +5 -8
- package/src/src/mcp/server.ts +50 -53
- package/src/src/mdx/index.ts +7 -8
- package/src/src/middleware/builtin/logger.ts +44 -29
- package/src/src/middleware/builtin/security/rate-limit.ts +20 -11
- package/src/src/middleware/builtin/timeout.ts +22 -13
- package/src/src/modules/import-map/default-import-map.ts +4 -3
- package/src/src/oauth/handlers/callback-handler.ts +9 -16
- package/src/src/oauth/handlers/index.ts +1 -1
- package/src/src/oauth/handlers/init-handler.ts +56 -27
- package/src/src/oauth/providers/index.ts +1 -1
- package/src/src/oauth/schemas/index.ts +1 -1
- package/src/src/oauth/token-store/index.ts +1 -1
- package/src/src/oauth/token-store/memory.ts +8 -8
- package/src/src/observability/request-profiler.ts +140 -0
- package/src/src/observability/tracing/otlp-setup.ts +16 -22
- package/src/src/prompt/factory.ts +16 -14
- package/src/src/prompt/registry.ts +14 -13
- package/src/src/prompt/schemas/prompt.schema.ts +0 -4
- package/src/src/prompt/types.ts +1 -2
- package/src/src/provider/local/ai-sdk-adapter.ts +3 -10
- package/src/src/provider/local/env.ts +22 -2
- package/src/src/provider/local/local-engine.ts +2 -9
- package/src/src/provider/model-registry.ts +2 -9
- package/src/src/provider/veryfront-cloud/provider.ts +1 -8
- package/src/src/provider/veryfront-cloud/shared.ts +12 -15
- package/src/src/proxy/handler.ts +90 -74
- package/src/src/react/compat/hooks-adapter.ts +43 -44
- package/src/src/react/components/Head.tsx +1 -181
- package/src/src/react/context/index.tsx +2 -83
- package/src/src/react/head-collector.ts +9 -0
- package/src/src/react/router/index.tsx +2 -100
- package/src/src/react/runtime/core.ts +303 -0
- package/src/src/rendering/orchestrator/html.ts +122 -18
- package/src/src/rendering/orchestrator/ssr-orchestrator.ts +8 -0
- package/src/src/rendering/orchestrator/types.ts +4 -0
- package/src/src/repositories/types.ts +0 -4
- package/src/src/resource/factory.ts +15 -11
- package/src/src/resource/registry.ts +7 -7
- package/src/src/schemas/common.ts +8 -5
- package/src/src/security/http/config.ts +3 -19
- package/src/src/security/http/response/security-handler.ts +22 -13
- package/src/src/security/index.ts +4 -7
- package/src/src/server/handlers/dev/styles-css.handler.ts +32 -14
- package/src/src/server/handlers/monitoring/metrics.handler.ts +3 -1
- package/src/src/server/handlers/request/module/module-server-handler.ts +24 -17
- package/src/src/server/handlers/request/prod-hydration-module.handler.ts +61 -0
- package/src/src/server/handlers/request/ssr/ssr.handler.ts +3 -0
- package/src/src/server/production-server.ts +84 -0
- package/src/src/server/runtime-handler/handler-context-builder.ts +1 -1
- package/src/src/server/runtime-handler/index.ts +44 -13
- package/src/src/server/runtime-handler/request-utils.ts +11 -0
- package/src/src/server/services/rendering/ssr.service.ts +31 -18
- package/src/src/server/services/rsc/endpoints/rsc-bundles.generated.ts +1 -1
- package/src/src/skill/allowed-tools.ts +1 -8
- package/src/src/skill/executor.ts +2 -2
- package/src/src/skill/parser.ts +13 -20
- package/src/src/skill/path-safety.ts +1 -1
- package/src/src/skill/tools.ts +27 -20
- package/src/src/studio/bridge/bridge-bundle.generated.ts +1 -1
- package/src/src/task/discovery.ts +97 -97
- package/src/src/tool/executor.ts +10 -8
- package/src/src/tool/factory.ts +21 -22
- package/src/src/tool/types.ts +0 -17
- package/src/src/transforms/esm/package-registry.ts +52 -20
- package/src/src/transforms/import-rewriter/strategies/veryfront-strategy.ts +2 -1
- package/src/src/transforms/mdx/esm-module-loader/cache-format.ts +34 -1
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts +1 -1
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.ts +4 -0
- package/src/src/transforms/pipeline/stages/ssr-vf-modules/index.ts +1 -1
- package/src/src/transforms/veryfront-module-urls.ts +6 -2
- package/src/src/types/entities/getEntityInfo.ts +131 -152
- package/src/src/utils/path-utils.ts +16 -7
- package/src/src/utils/version-constant.ts +1 -1
- package/src/src/utils/version.ts +0 -1
- package/src/src/workflow/worker/dynamic-job-entrypoint.ts +18 -84
- package/src/src/workflow/worker/job-entrypoint.ts +18 -85
- package/src/src/workflow/worker/shared.ts +127 -0
- package/esm/src/prompt/schemas/index.d.ts +0 -7
- package/esm/src/prompt/schemas/index.d.ts.map +0 -1
- package/esm/src/prompt/schemas/index.js +0 -6
- package/esm/src/security/http/handlers-index.d.ts +0 -5
- package/esm/src/security/http/handlers-index.d.ts.map +0 -1
- package/esm/src/security/http/handlers-index.js +0 -3
- package/src/src/prompt/schemas/index.ts +0 -7
- package/src/src/security/http/handlers-index.ts +0 -4
package/src/src/prompt/types.ts
CHANGED
|
@@ -13,8 +13,8 @@ import { generate, generateStream } from "./local-engine.js";
|
|
|
13
13
|
import type { ChatMessage, GenerateOptions } from "./local-engine.js";
|
|
14
14
|
import { DEFAULT_LOCAL_MODEL } from "./model-catalog.js";
|
|
15
15
|
import { serverLogger } from "../../utils/index.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { fromError } from "../../errors/veryfront-error.js";
|
|
17
|
+
import { throwIfLocalAIDisabled } from "./env.js";
|
|
18
18
|
|
|
19
19
|
const logger = serverLogger.component("local-llm");
|
|
20
20
|
|
|
@@ -132,14 +132,7 @@ export function createLocalModel(modelId?: string): LanguageModel {
|
|
|
132
132
|
// Note: getTransformers() in local-engine.ts also checks this, but we need
|
|
133
133
|
// the check here too because doStream creates a ReadableStream wrapper and
|
|
134
134
|
// errors inside it would be swallowed as in-band stream errors.
|
|
135
|
-
|
|
136
|
-
throw toError(
|
|
137
|
-
createError({
|
|
138
|
-
type: "no_ai_available",
|
|
139
|
-
message: "Local AI disabled via VERYFRONT_DISABLE_LOCAL_AI environment variable.",
|
|
140
|
-
}),
|
|
141
|
-
);
|
|
142
|
-
}
|
|
135
|
+
throwIfLocalAIDisabled();
|
|
143
136
|
|
|
144
137
|
const messages = convertPrompt(options.prompt);
|
|
145
138
|
const genOptions = toGenerateOptions(options);
|
|
@@ -6,13 +6,18 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module provider/local
|
|
8
8
|
*/
|
|
9
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
import { createError, toError } from "../../errors/veryfront-error.js";
|
|
13
|
+
|
|
14
|
+
const LOCAL_AI_DISABLED_MESSAGE =
|
|
15
|
+
"Local AI disabled via VERYFRONT_DISABLE_LOCAL_AI environment variable.";
|
|
9
16
|
|
|
10
17
|
/**
|
|
11
18
|
* Check whether local AI is explicitly disabled via environment variable.
|
|
12
19
|
* Works in Deno, Node, and compiled binaries.
|
|
13
20
|
*/
|
|
14
|
-
import * as dntShim from "../../../_dnt.shims.js";
|
|
15
|
-
|
|
16
21
|
export function isLocalAIDisabled(): boolean {
|
|
17
22
|
const denoVal = (dntShim.dntGlobalThis as Record<string, unknown>).Deno as
|
|
18
23
|
| { env?: { get?: (key: string) => string | undefined } }
|
|
@@ -29,3 +34,18 @@ export function isLocalAIDisabled(): boolean {
|
|
|
29
34
|
|
|
30
35
|
return false;
|
|
31
36
|
}
|
|
37
|
+
|
|
38
|
+
export function createLocalAIDisabledError(): Error {
|
|
39
|
+
return toError(
|
|
40
|
+
createError({
|
|
41
|
+
type: "no_ai_available",
|
|
42
|
+
message: LOCAL_AI_DISABLED_MESSAGE,
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function throwIfLocalAIDisabled(): void {
|
|
48
|
+
if (isLocalAIDisabled()) {
|
|
49
|
+
throw createLocalAIDisabledError();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -15,7 +15,7 @@ import { serverLogger } from "../../utils/index.js";
|
|
|
15
15
|
import { createError, toError } from "../../errors/veryfront-error.js";
|
|
16
16
|
import { importTransformers } from "../../platform/compat/opaque-deps.js";
|
|
17
17
|
import { DEFAULT_LOCAL_MODEL, type ModelInfo, resolveLocalModel } from "./model-catalog.js";
|
|
18
|
-
import {
|
|
18
|
+
import { throwIfLocalAIDisabled } from "./env.js";
|
|
19
19
|
|
|
20
20
|
const logger = serverLogger.component("local-llm");
|
|
21
21
|
|
|
@@ -89,14 +89,7 @@ let transformersModule: TransformersModule | null = null;
|
|
|
89
89
|
export async function getTransformers(): Promise<TransformersModule> {
|
|
90
90
|
if (transformersModule) return transformersModule;
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
throw toError(
|
|
94
|
-
createError({
|
|
95
|
-
type: "no_ai_available",
|
|
96
|
-
message: "Local AI disabled via VERYFRONT_DISABLE_LOCAL_AI environment variable.",
|
|
97
|
-
}),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
92
|
+
throwIfLocalAIDisabled();
|
|
100
93
|
|
|
101
94
|
logger.info("Loading @huggingface/transformers...");
|
|
102
95
|
|
|
@@ -27,7 +27,7 @@ import { ProjectScopedRegistryManager } from "../ai/registry-manager.js";
|
|
|
27
27
|
import { serverLogger } from "../utils/index.js";
|
|
28
28
|
import { DEFAULT_LOCAL_MODEL } from "./local/model-catalog.js";
|
|
29
29
|
import { createLocalModel } from "./local/ai-sdk-adapter.js";
|
|
30
|
-
import {
|
|
30
|
+
import { throwIfLocalAIDisabled } from "./local/env.js";
|
|
31
31
|
import { verifyLocalRuntime } from "./local/local-engine.js";
|
|
32
32
|
import {
|
|
33
33
|
getDefaultVeryfrontCloudModel,
|
|
@@ -270,14 +270,7 @@ export function resolveModel(modelString: string): LanguageModel {
|
|
|
270
270
|
manager.has("local")
|
|
271
271
|
) {
|
|
272
272
|
// Check if local AI is explicitly disabled (e.g., for testing)
|
|
273
|
-
|
|
274
|
-
throw toError(
|
|
275
|
-
createError({
|
|
276
|
-
type: "no_ai_available",
|
|
277
|
-
message: "Local AI disabled via VERYFRONT_DISABLE_LOCAL_AI environment variable.",
|
|
278
|
-
}),
|
|
279
|
-
);
|
|
280
|
-
}
|
|
273
|
+
throwIfLocalAIDisabled();
|
|
281
274
|
|
|
282
275
|
localLogger.info(
|
|
283
276
|
`⚡ "${providerName}" unavailable (missing credentials or configuration). ` +
|
|
@@ -25,14 +25,6 @@ export function createVeryfrontCloudModel(modelId: string): LanguageModel {
|
|
|
25
25
|
fetch,
|
|
26
26
|
})(upstreamModelId);
|
|
27
27
|
|
|
28
|
-
case "openai":
|
|
29
|
-
return createOpenAI({
|
|
30
|
-
apiKey: apiToken,
|
|
31
|
-
baseURL,
|
|
32
|
-
name: "veryfront-cloud",
|
|
33
|
-
fetch,
|
|
34
|
-
})(upstreamModelId);
|
|
35
|
-
|
|
36
28
|
case "google":
|
|
37
29
|
return createGoogleGenerativeAI({
|
|
38
30
|
apiKey: apiToken,
|
|
@@ -41,6 +33,7 @@ export function createVeryfrontCloudModel(modelId: string): LanguageModel {
|
|
|
41
33
|
fetch,
|
|
42
34
|
})(upstreamModelId);
|
|
43
35
|
|
|
36
|
+
case "openai":
|
|
44
37
|
case "moonshotai":
|
|
45
38
|
return createOpenAI({
|
|
46
39
|
apiKey: apiToken,
|
|
@@ -32,19 +32,23 @@ function joinUrl(base: string, path: string): string {
|
|
|
32
32
|
return `${base.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function createInvalidModelIdError(modelId: string): Error {
|
|
36
|
+
return toError(
|
|
37
|
+
createError({
|
|
38
|
+
type: "config",
|
|
39
|
+
message: `Invalid veryfront-cloud model string: "${modelId}". Expected ` +
|
|
40
|
+
`"veryfront-cloud/provider/model".`,
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
export function parseVeryfrontCloudModelId(
|
|
36
46
|
modelId: string,
|
|
37
47
|
kind: "language" | "embedding",
|
|
38
48
|
): ParsedVeryfrontCloudModelId {
|
|
39
49
|
const slashIndex = modelId.indexOf("/");
|
|
40
50
|
if (slashIndex === -1) {
|
|
41
|
-
throw
|
|
42
|
-
createError({
|
|
43
|
-
type: "config",
|
|
44
|
-
message: `Invalid veryfront-cloud model string: "${modelId}". Expected ` +
|
|
45
|
-
`"veryfront-cloud/provider/model".`,
|
|
46
|
-
}),
|
|
47
|
-
);
|
|
51
|
+
throw createInvalidModelIdError(modelId);
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
const rawProvider = modelId.slice(0, slashIndex);
|
|
@@ -52,13 +56,7 @@ export function parseVeryfrontCloudModelId(
|
|
|
52
56
|
const upstreamModelId = modelId.slice(slashIndex + 1);
|
|
53
57
|
|
|
54
58
|
if (!normalizedProvider || !upstreamModelId) {
|
|
55
|
-
throw
|
|
56
|
-
createError({
|
|
57
|
-
type: "config",
|
|
58
|
-
message: `Invalid veryfront-cloud model string: "${modelId}". Expected ` +
|
|
59
|
-
`"veryfront-cloud/provider/model".`,
|
|
60
|
-
}),
|
|
61
|
-
);
|
|
59
|
+
throw createInvalidModelIdError(modelId);
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
if (
|
|
@@ -128,7 +126,6 @@ export function createVeryfrontCloudFetch(apiToken: string): typeof dntShim.fetc
|
|
|
128
126
|
|
|
129
127
|
headers.delete("x-api-key");
|
|
130
128
|
headers.delete("x-goog-api-key");
|
|
131
|
-
headers.delete("Authorization");
|
|
132
129
|
headers.set("Authorization", `Bearer ${apiToken}`);
|
|
133
130
|
|
|
134
131
|
return dntShim.fetch(new dntShim.Request(request, { headers }));
|
package/src/src/proxy/handler.ts
CHANGED
|
@@ -210,7 +210,7 @@ function extractUserToken(cookieHeader: string): string | undefined {
|
|
|
210
210
|
return match?.[1] ? decodeURIComponent(match[1]) : undefined;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
function
|
|
213
|
+
function parseStatusFromError(error: unknown): number | null {
|
|
214
214
|
const message = error instanceof Error ? error.message : String(error);
|
|
215
215
|
const match = message.match(/failed: (\d+)/);
|
|
216
216
|
return match ? Number(match[1]) : null;
|
|
@@ -392,6 +392,75 @@ export function createProxyHandler(options: ProxyHandlerOptions) {
|
|
|
392
392
|
return `https://veryfront.com/sign-in?from=${encodeURIComponent(returnPath)}`;
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
function makePreviewProjectNotFoundContext(
|
|
396
|
+
base: {
|
|
397
|
+
scope: TokenScope;
|
|
398
|
+
host: string;
|
|
399
|
+
parsedDomain: ParsedDomain;
|
|
400
|
+
},
|
|
401
|
+
token?: string,
|
|
402
|
+
): ProxyContext {
|
|
403
|
+
return makeErrorContext(
|
|
404
|
+
base,
|
|
405
|
+
404,
|
|
406
|
+
"Preview project not found",
|
|
407
|
+
token,
|
|
408
|
+
undefined,
|
|
409
|
+
"project-not-found",
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
async function resolveRequestToken(
|
|
414
|
+
req: dntShim.Request,
|
|
415
|
+
scope: TokenScope,
|
|
416
|
+
host: string,
|
|
417
|
+
projectSlug: string | undefined,
|
|
418
|
+
options: {
|
|
419
|
+
allowSignedInternalControlPlaneToken?: boolean;
|
|
420
|
+
tokenFetchErrorMessage: string;
|
|
421
|
+
},
|
|
422
|
+
): Promise<{ token?: string; userToken?: string; tokenFetchError?: unknown }> {
|
|
423
|
+
const userToken = extractUserToken(req.headers.get("cookie") ?? "");
|
|
424
|
+
const useSignedInternalControlPlaneToken = options.allowSignedInternalControlPlaneToken &&
|
|
425
|
+
isSignedInternalControlPlaneRequest(req);
|
|
426
|
+
|
|
427
|
+
let token: string | undefined;
|
|
428
|
+
let tokenFetchError: unknown;
|
|
429
|
+
|
|
430
|
+
if (useSignedInternalControlPlaneToken) {
|
|
431
|
+
token = req.headers.get("x-token") ?? undefined;
|
|
432
|
+
logger?.debug("Using signed control-plane token for internal request", {
|
|
433
|
+
pathname: new URL(req.url).pathname,
|
|
434
|
+
scope,
|
|
435
|
+
});
|
|
436
|
+
} else if (scope === "preview" && userToken) {
|
|
437
|
+
token = userToken;
|
|
438
|
+
logger?.debug("Using user auth token for preview");
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (!token && config.apiClientId && config.apiClientSecret) {
|
|
442
|
+
const customDomain = projectSlug ? undefined : host;
|
|
443
|
+
if (projectSlug || customDomain) {
|
|
444
|
+
try {
|
|
445
|
+
token = await tokenManager.getToken(scope, projectSlug, customDomain);
|
|
446
|
+
} catch (error) {
|
|
447
|
+
tokenFetchError = error;
|
|
448
|
+
logger?.error(options.tokenFetchErrorMessage, error as Error, {
|
|
449
|
+
projectSlug,
|
|
450
|
+
customDomain,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (!token && config.apiToken) {
|
|
457
|
+
token = config.apiToken;
|
|
458
|
+
logger?.debug("Using static API token fallback");
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return { token, userToken, tokenFetchError };
|
|
462
|
+
}
|
|
463
|
+
|
|
395
464
|
async function checkProtectedAccess(
|
|
396
465
|
req: dntShim.Request,
|
|
397
466
|
matchingEnv: NonNullable<DomainLookupResult["environments"]>[number] | undefined,
|
|
@@ -486,6 +555,7 @@ export function createProxyHandler(options: ProxyHandlerOptions) {
|
|
|
486
555
|
const host = rawHost.replace(/:\d+$/, "");
|
|
487
556
|
const parsedDomain = parseProjectDomain(host);
|
|
488
557
|
const scope = getScope(parsedDomain.environment);
|
|
558
|
+
const base = { scope, host, parsedDomain };
|
|
489
559
|
|
|
490
560
|
let projectSlug = parsedDomain.slug ?? undefined;
|
|
491
561
|
let projectId: string | undefined;
|
|
@@ -494,7 +564,7 @@ export function createProxyHandler(options: ProxyHandlerOptions) {
|
|
|
494
564
|
|
|
495
565
|
const isCustomDomain = !projectSlug && !parsedDomain.isVeryfrontDomain;
|
|
496
566
|
|
|
497
|
-
if (!projectSlug && parsedDomain.isVeryfrontDomain
|
|
567
|
+
if (!projectSlug && parsedDomain.isVeryfrontDomain) {
|
|
498
568
|
return {
|
|
499
569
|
token: undefined,
|
|
500
570
|
projectSlug: undefined,
|
|
@@ -519,58 +589,29 @@ export function createProxyHandler(options: ProxyHandlerOptions) {
|
|
|
519
589
|
isCustomDomain,
|
|
520
590
|
});
|
|
521
591
|
|
|
522
|
-
|
|
523
|
-
const userToken = extractUserToken(cookieHeader);
|
|
524
|
-
const signedInternalControlPlaneRequest = isSignedInternalControlPlaneRequest(req);
|
|
525
|
-
|
|
592
|
+
let userToken: string | undefined;
|
|
526
593
|
let token: string | undefined;
|
|
527
594
|
let tokenFetchError: unknown;
|
|
528
595
|
|
|
529
596
|
if (isLocalProject) {
|
|
530
597
|
logger?.debug("Local project, skipping token fetch", { localPath });
|
|
531
598
|
} else {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (!token && config.apiClientId && config.apiClientSecret) {
|
|
544
|
-
const customDomain = projectSlug ? undefined : host;
|
|
545
|
-
if (projectSlug || customDomain) {
|
|
546
|
-
try {
|
|
547
|
-
token = await tokenManager.getToken(scope, projectSlug, customDomain);
|
|
548
|
-
} catch (error) {
|
|
549
|
-
tokenFetchError = error;
|
|
550
|
-
logger?.error("Token fetch failed", error as Error, { projectSlug, customDomain });
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
if (!token && config.apiToken) {
|
|
556
|
-
token = config.apiToken;
|
|
557
|
-
logger?.debug("Using static API token fallback");
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
const base = { scope, host, parsedDomain };
|
|
599
|
+
({ token, userToken, tokenFetchError } = await resolveRequestToken(
|
|
600
|
+
req,
|
|
601
|
+
scope,
|
|
602
|
+
host,
|
|
603
|
+
projectSlug,
|
|
604
|
+
{
|
|
605
|
+
allowSignedInternalControlPlaneToken: true,
|
|
606
|
+
tokenFetchErrorMessage: "Token fetch failed",
|
|
607
|
+
},
|
|
608
|
+
));
|
|
561
609
|
|
|
562
610
|
if (projectSlug && scope === "preview" && !token) {
|
|
563
|
-
const status =
|
|
611
|
+
const status = parseStatusFromError(tokenFetchError);
|
|
564
612
|
if (status === 404) {
|
|
565
613
|
logger?.info("Preview project not found", { projectSlug, host });
|
|
566
|
-
return
|
|
567
|
-
base,
|
|
568
|
-
404,
|
|
569
|
-
"Preview project not found",
|
|
570
|
-
undefined,
|
|
571
|
-
undefined,
|
|
572
|
-
"project-not-found",
|
|
573
|
-
);
|
|
614
|
+
return makePreviewProjectNotFoundContext(base);
|
|
574
615
|
}
|
|
575
616
|
|
|
576
617
|
logger?.warn("Preview request has no usable token", {
|
|
@@ -686,14 +727,7 @@ export function createProxyHandler(options: ProxyHandlerOptions) {
|
|
|
686
727
|
|
|
687
728
|
if (!resolved.projectId) {
|
|
688
729
|
logger?.info("Preview project not found after lookup", { projectSlug, host });
|
|
689
|
-
return
|
|
690
|
-
base,
|
|
691
|
-
404,
|
|
692
|
-
"Preview project not found",
|
|
693
|
-
token,
|
|
694
|
-
undefined,
|
|
695
|
-
"project-not-found",
|
|
696
|
-
);
|
|
730
|
+
return makePreviewProjectNotFoundContext(base, token);
|
|
697
731
|
}
|
|
698
732
|
|
|
699
733
|
projectId = resolved.projectId;
|
|
@@ -754,28 +788,10 @@ export function createProxyHandler(options: ProxyHandlerOptions) {
|
|
|
754
788
|
const parsedDomain = parseProjectDomain(host);
|
|
755
789
|
const scope = getScope(parsedDomain.environment);
|
|
756
790
|
const projectSlug = parsedDomain.slug ?? undefined;
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
if (userToken) return userToken;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
if (config.apiClientId && config.apiClientSecret) {
|
|
765
|
-
const customDomain = projectSlug ? undefined : host;
|
|
766
|
-
if (projectSlug || customDomain) {
|
|
767
|
-
try {
|
|
768
|
-
return await tokenManager.getToken(scope, projectSlug, customDomain);
|
|
769
|
-
} catch (error) {
|
|
770
|
-
logger?.error("Token fetch failed for API", error as Error, {
|
|
771
|
-
projectSlug,
|
|
772
|
-
customDomain,
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
return config.apiToken;
|
|
791
|
+
const { token } = await resolveRequestToken(req, scope, host, projectSlug, {
|
|
792
|
+
tokenFetchErrorMessage: "Token fetch failed for API",
|
|
793
|
+
});
|
|
794
|
+
return token;
|
|
779
795
|
}
|
|
780
796
|
|
|
781
797
|
async function getStats() {
|
|
@@ -16,6 +16,19 @@ function hasReactHook(hookName: string): boolean {
|
|
|
16
16
|
return typeof (React as Record<string, unknown>)[hookName] === "function";
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
function createDefaultFormStatus(): FormStatus {
|
|
20
|
+
return { pending: false, data: null, method: null, action: null };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function supportsConcurrentHooks(): boolean {
|
|
24
|
+
const { isReact18, isReact19 } = getReactVersionInfo();
|
|
25
|
+
return isReact18 || isReact19;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function warnHookFallback(hookName: string, fallbackDescription: string): void {
|
|
29
|
+
logger.warn(`${hookName} not available, ${fallbackDescription}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
19
32
|
export function createTransitionFallbackScheduler(
|
|
20
33
|
onPendingChange: (pending: boolean) => void,
|
|
21
34
|
): {
|
|
@@ -45,14 +58,14 @@ export function createTransitionFallbackScheduler(
|
|
|
45
58
|
|
|
46
59
|
export function useFormStatusCompat(): FormStatus {
|
|
47
60
|
if (!hasFeature("useFormStatus") || !hasReactHook("useFormStatus")) {
|
|
48
|
-
return
|
|
61
|
+
return createDefaultFormStatus();
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
try {
|
|
52
65
|
return (React as typeof React & { useFormStatus: () => FormStatus }).useFormStatus();
|
|
53
|
-
} catch
|
|
54
|
-
|
|
55
|
-
return
|
|
66
|
+
} catch {
|
|
67
|
+
warnHookFallback("useFormStatus", "falling back to the default idle state");
|
|
68
|
+
return createDefaultFormStatus();
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
|
|
@@ -70,8 +83,8 @@ export function useOptimisticCompat<State, OptimisticState = State>(
|
|
|
70
83
|
) => [S, (action: OptimisticStateAction<O>) => void];
|
|
71
84
|
}
|
|
72
85
|
).useOptimistic(state, updateFn);
|
|
73
|
-
} catch
|
|
74
|
-
|
|
86
|
+
} catch {
|
|
87
|
+
warnHookFallback("useOptimistic", "falling back to React.useState");
|
|
75
88
|
}
|
|
76
89
|
}
|
|
77
90
|
|
|
@@ -107,13 +120,11 @@ export function useOptimisticCompat<State, OptimisticState = State>(
|
|
|
107
120
|
}
|
|
108
121
|
|
|
109
122
|
export function useTransitionCompat(): ReturnType<typeof React.useTransition> {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (versionInfo.isReact18 || versionInfo.isReact19) {
|
|
123
|
+
if (supportsConcurrentHooks()) {
|
|
113
124
|
try {
|
|
114
125
|
return React.useTransition();
|
|
115
|
-
} catch
|
|
116
|
-
|
|
126
|
+
} catch {
|
|
127
|
+
warnHookFallback("useTransition", "falling back to the timeout scheduler");
|
|
117
128
|
}
|
|
118
129
|
}
|
|
119
130
|
|
|
@@ -138,13 +149,11 @@ export function useTransitionCompat(): ReturnType<typeof React.useTransition> {
|
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
export function useDeferredValueCompat<T>(value: T): T {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (versionInfo.isReact18 || versionInfo.isReact19) {
|
|
152
|
+
if (supportsConcurrentHooks()) {
|
|
144
153
|
try {
|
|
145
154
|
return React.useDeferredValue(value);
|
|
146
|
-
} catch
|
|
147
|
-
|
|
155
|
+
} catch {
|
|
156
|
+
warnHookFallback("useDeferredValue", "returning the value directly");
|
|
148
157
|
}
|
|
149
158
|
}
|
|
150
159
|
|
|
@@ -154,13 +163,11 @@ export function useDeferredValueCompat<T>(value: T): T {
|
|
|
154
163
|
let idCounter = 0;
|
|
155
164
|
|
|
156
165
|
export function useIdCompat(): string {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (versionInfo.isReact18 || versionInfo.isReact19) {
|
|
166
|
+
if (supportsConcurrentHooks()) {
|
|
160
167
|
try {
|
|
161
168
|
return React.useId();
|
|
162
|
-
} catch
|
|
163
|
-
|
|
169
|
+
} catch {
|
|
170
|
+
warnHookFallback("useId", "using the incremental fallback id");
|
|
164
171
|
}
|
|
165
172
|
}
|
|
166
173
|
|
|
@@ -191,16 +198,18 @@ export interface CompatHooks {
|
|
|
191
198
|
useId: typeof useIdCompat;
|
|
192
199
|
}
|
|
193
200
|
|
|
201
|
+
const defaultCompatHooks: CompatHooks = {
|
|
202
|
+
useFormStatus: useFormStatusCompat,
|
|
203
|
+
useOptimistic: useOptimisticCompat,
|
|
204
|
+
useTransition: useTransitionCompat,
|
|
205
|
+
useDeferredValue: useDeferredValueCompat,
|
|
206
|
+
useId: useIdCompat,
|
|
207
|
+
};
|
|
208
|
+
|
|
194
209
|
let compatHooksContext: React.Context<CompatHooks> | null = null;
|
|
195
210
|
|
|
196
211
|
function getCompatHooksContext(): React.Context<CompatHooks> {
|
|
197
|
-
compatHooksContext ??= React.createContext<CompatHooks>(
|
|
198
|
-
useFormStatus: useFormStatusCompat,
|
|
199
|
-
useOptimistic: useOptimisticCompat,
|
|
200
|
-
useTransition: useTransitionCompat,
|
|
201
|
-
useDeferredValue: useDeferredValueCompat,
|
|
202
|
-
useId: useIdCompat,
|
|
203
|
-
});
|
|
212
|
+
compatHooksContext ??= React.createContext<CompatHooks>(defaultCompatHooks);
|
|
204
213
|
|
|
205
214
|
return compatHooksContext;
|
|
206
215
|
}
|
|
@@ -222,21 +231,11 @@ export function CompatHooksProvider({
|
|
|
222
231
|
}: {
|
|
223
232
|
children: React.ReactNode;
|
|
224
233
|
}): React.ReactElement {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
useId: useIdCompat,
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
return React.createElement(getCompatHooksContext().Provider, { value: hooks }, children);
|
|
234
|
+
return React.createElement(
|
|
235
|
+
getCompatHooksContext().Provider,
|
|
236
|
+
{ value: defaultCompatHooks },
|
|
237
|
+
children,
|
|
238
|
+
);
|
|
234
239
|
}
|
|
235
240
|
|
|
236
|
-
export const compatHooks =
|
|
237
|
-
useFormStatus: useFormStatusCompat,
|
|
238
|
-
useOptimistic: useOptimisticCompat,
|
|
239
|
-
useTransition: useTransitionCompat,
|
|
240
|
-
useDeferredValue: useDeferredValueCompat,
|
|
241
|
-
useId: useIdCompat,
|
|
242
|
-
} as const;
|
|
241
|
+
export const compatHooks = defaultCompatHooks;
|