@mrclrchtr/supi-code-intelligence 4.10.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +111 -5
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +7 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +22 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +245 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +78 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +171 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-evidence.ts +413 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +15 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-publication.ts +214 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-pull.ts +62 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +690 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +97 -16
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-waiters.ts +206 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +448 -298
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +70 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +231 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +25 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +529 -119
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +161 -33
- package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +12 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +5 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +68 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +176 -24
- package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +45 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/workspace-sentinels.ts +46 -10
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +79 -9
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +17 -7
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +350 -26
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +5 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +586 -96
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +130 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +45 -329
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +57 -120
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +320 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +207 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/readiness.ts +72 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +151 -26
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +92 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +165 -118
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +49 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +102 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +17 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/README.md +258 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/babel.cjs +257 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/jiti.cjs +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-cli.mjs +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-native.mjs +121 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.d.mts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.mjs +4 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-static.mjs +23 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.cjs +30 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.cts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.mts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.mjs +29 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/types.d.ts +420 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/package.json +146 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +0 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -8
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +16 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +65 -87
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +47 -95
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-timing.ts +147 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client-lifecycle.ts +39 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +561 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-message-size.ts +24 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +452 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +12 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +5 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +33 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/blocking-test-bootstrap.mjs +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/bootstrap.mjs +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store-helpers.ts +23 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +400 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/request-control.ts +48 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-parser-helpers.ts +24 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-query-helpers.ts +43 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +421 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +116 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +201 -0
- package/package.json +5 -5
- package/src/analysis/health/diagnostics.ts +221 -77
- package/src/analysis/health/file-scope.ts +184 -0
- package/src/analysis/health/recovery.ts +14 -3
- package/src/analysis/provider.ts +58 -0
- package/src/analysis/readiness.ts +34 -9
- package/src/analysis/refactor/apply.ts +45 -1
- package/src/analysis/refactor/mutation-authority.ts +143 -0
- package/src/analysis/relations/callees.ts +9 -1
- package/src/analysis/relations/types.ts +5 -2
- package/src/analysis/search/ast-scan-timing.ts +9 -2
- package/src/analysis/search/ast-scan.ts +5 -2
- package/src/analysis/search/deadline.ts +2 -2
- package/src/analysis/search/pattern-analysis.ts +54 -33
- package/src/analysis/search/pattern.ts +18 -3
- package/src/analysis/target/anchored.ts +20 -11
- package/src/analysis/target/file.ts +18 -11
- package/src/analysis/target/identity.ts +19 -3
- package/src/analysis/target/symbol.ts +36 -15
- package/src/api.ts +4 -0
- package/src/config.ts +35 -1
- package/src/diagnostics/evidence.ts +51 -0
- package/src/extension.ts +57 -14
- package/src/overview/overview-data.ts +9 -2
- package/src/overview/overview.ts +49 -30
- package/src/overview/types.ts +2 -0
- package/src/session/capability-adapter.ts +12 -3
- package/src/session/find-types.ts +2 -2
- package/src/session/find-workflow.ts +20 -9
- package/src/session/graph/collect.ts +18 -2
- package/src/session/graph-workflow.ts +19 -12
- package/src/session/health-refresh.ts +175 -0
- package/src/session/health-types.ts +43 -15
- package/src/session/health-workflow.ts +69 -54
- package/src/session/input/workflows.ts +2 -2
- package/src/session/inspect/collect.ts +20 -3
- package/src/session/inspect-workflow.ts +12 -6
- package/src/session/orientation/collect.ts +12 -3
- package/src/session/orientation/context-facts.ts +3 -1
- package/src/session/orientation/context-sections.ts +20 -7
- package/src/session/orientation/gather.ts +17 -11
- package/src/session/orientation-types.ts +4 -1
- package/src/session/orientation-workflow.ts +23 -10
- package/src/session/refactor-plans.ts +2 -0
- package/src/session/refactor-workflow.ts +61 -15
- package/src/session/session.ts +29 -2
- package/src/session/target-workflow.ts +54 -23
- package/src/session/workflow-control.ts +7 -3
- package/src/substrate/lsp/lifecycle.ts +26 -46
- package/src/substrate/lsp/maintenance.ts +284 -28
- package/src/substrate/lsp/recovery.ts +11 -5
- package/src/substrate/lsp/state.ts +2 -2
- package/src/substrate/workspace-provider-host.ts +25 -3
- package/src/tool/{find → code_find}/execute.ts +2 -16
- package/src/tool/code_find/guidance.ts +8 -0
- package/src/tool/{find → code_find}/render.ts +21 -4
- package/src/tool/{result/find.ts → code_find/result.ts} +78 -9
- package/src/tool/code_find/spec.ts +37 -0
- package/src/tool/code_find/tui.ts +41 -0
- package/src/tool/code_graph/execute.ts +24 -0
- package/src/tool/code_graph/guidance.ts +6 -0
- package/src/tool/{graph → code_graph}/markdown.ts +1 -1
- package/src/tool/{result/graph.ts → code_graph/result.ts} +111 -3
- package/src/tool/code_graph/spec.ts +39 -0
- package/src/tool/code_graph/tui.ts +117 -0
- package/src/tool/{health → code_health}/execute.ts +2 -13
- package/src/tool/code_health/guidance.ts +8 -0
- package/src/tool/{health → code_health}/markdown.ts +119 -27
- package/src/tool/code_health/refresh-status.ts +105 -0
- package/src/tool/{result/health.ts → code_health/result.ts} +80 -3
- package/src/tool/code_health/spec.ts +41 -0
- package/src/tool/{health → code_health}/tui.ts +95 -98
- package/src/tool/{inspect → code_inspect}/execute.ts +2 -16
- package/src/tool/code_inspect/guidance.ts +6 -0
- package/src/tool/{inspect → code_inspect}/markdown.ts +1 -1
- package/src/tool/{result/inspect.ts → code_inspect/result.ts} +143 -2
- package/src/tool/code_inspect/spec.ts +25 -0
- package/src/tool/code_inspect/tui.ts +44 -0
- package/src/tool/code_orientation/execute.ts +25 -0
- package/src/tool/code_orientation/guidance.ts +9 -0
- package/src/tool/{orientation → code_orientation}/markdown.ts +1 -1
- package/src/tool/code_orientation/result.ts +248 -0
- package/src/tool/code_orientation/spec.ts +25 -0
- package/src/tool/{orientation → code_orientation}/tui.ts +51 -35
- package/src/tool/code_refactor_apply/execute.ts +17 -0
- package/src/tool/code_refactor_apply/guidance.ts +5 -0
- package/src/tool/{refactor-apply/execute.ts → code_refactor_apply/result.ts} +8 -11
- package/src/tool/code_refactor_apply/spec.ts +26 -0
- package/src/tool/code_refactor_apply/tui.ts +73 -0
- package/src/tool/code_refactor_plan/execute.ts +27 -0
- package/src/tool/code_refactor_plan/guidance.ts +8 -0
- package/src/tool/{refactor-plan/execute.ts → code_refactor_plan/result.ts} +13 -22
- package/src/tool/code_refactor_plan/spec.ts +25 -0
- package/src/tool/code_refactor_plan/tui.ts +54 -0
- package/src/tool/code_resolve/execute.ts +19 -0
- package/src/tool/code_resolve/guidance.ts +8 -0
- package/src/tool/{resolve → code_resolve}/markdown.ts +1 -1
- package/src/tool/{result/resolve.ts → code_resolve/result.ts} +79 -29
- package/src/tool/code_resolve/spec.ts +25 -0
- package/src/tool/code_resolve/tui.ts +60 -0
- package/src/tool/guidance.ts +71 -52
- package/src/tool/infra/truncate.ts +40 -0
- package/src/tool/infra/workflow-control.ts +8 -0
- package/src/tool/{refactor-plan/markdown.ts → refactor-markdown.ts} +4 -7
- package/src/tool/register.ts +105 -88
- package/src/tool/result/display.ts +107 -0
- package/src/tool/result/errors.ts +20 -17
- package/src/tool/result/refactor.ts +37 -8
- package/src/tool/result/types.ts +20 -0
- package/src/tool/schemas.ts +26 -157
- package/src/tool/specs.ts +40 -126
- package/src/types/execution.ts +18 -5
- package/src/types/index.ts +8 -1
- package/src/ui/status-command.ts +5 -3
- package/src/ui/status-overlay.ts +4 -0
- package/src/ui/tui/common.ts +108 -10
- package/src/ui/tui/display.ts +48 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime.ts +0 -351
- package/src/tool/find/tui.ts +0 -39
- package/src/tool/graph/execute.ts +0 -62
- package/src/tool/graph/tui.ts +0 -104
- package/src/tool/inspect/tui.ts +0 -36
- package/src/tool/orientation/execute.ts +0 -62
- package/src/tool/refactor-apply/tui.ts +0 -55
- package/src/tool/refactor-plan/tui.ts +0 -41
- package/src/tool/resolve/execute.ts +0 -36
- package/src/tool/resolve/tui.ts +0 -42
- package/src/tool/result/orientation.ts +0 -132
- /package/src/tool/{find → code_find}/ast-kinds.ts +0 -0
- /package/src/tool/{find → code_find}/markdown.ts +0 -0
- /package/src/tool/{find → code_find}/modes.ts +0 -0
- /package/src/tool/{health → code_health}/semantic-state.ts +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { dirname, join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { isBuiltin } from "node:module";
|
|
6
|
+
import { createJiti } from "./jiti.mjs";
|
|
7
|
+
|
|
8
|
+
let jiti;
|
|
9
|
+
|
|
10
|
+
// https://nodejs.org/api/module.html#initialize
|
|
11
|
+
export async function initialize() {
|
|
12
|
+
jiti = createJiti();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// https://nodejs.org/api/module.html#resolvespecifier-context-nextresolve
|
|
16
|
+
export async function resolve(specifier, context, nextResolve) {
|
|
17
|
+
if (_shouldSkip(specifier)) {
|
|
18
|
+
return nextResolve(specifier, context);
|
|
19
|
+
}
|
|
20
|
+
const resolvedPath = jiti.esmResolve(specifier, {
|
|
21
|
+
parentURL: context?.parentURL,
|
|
22
|
+
conditions: context?.conditions,
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
url: resolvedPath,
|
|
26
|
+
shortCircuit: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// https://nodejs.org/api/module.html#loadurl-context-nextload
|
|
31
|
+
export async function load(url, context, nextLoad) {
|
|
32
|
+
if (_shouldSkip(url)) {
|
|
33
|
+
return nextLoad(url, context);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const filename = fileURLToPath(url);
|
|
37
|
+
|
|
38
|
+
if (url.endsWith(".js")) {
|
|
39
|
+
const pkg = await _findClosestPackageJson(dirname(filename));
|
|
40
|
+
if (pkg && pkg.type === "module") {
|
|
41
|
+
return nextLoad(url, context);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const rawSource = await readFile(filename, "utf8");
|
|
46
|
+
|
|
47
|
+
if (url.endsWith(".json")) {
|
|
48
|
+
const pkg = await _findClosestPackageJson(dirname(filename));
|
|
49
|
+
return pkg && pkg.type === "module"
|
|
50
|
+
? {
|
|
51
|
+
source: `export default ${rawSource}`,
|
|
52
|
+
format: "module",
|
|
53
|
+
shortCircuit: true,
|
|
54
|
+
}
|
|
55
|
+
: {
|
|
56
|
+
source: `module.exports = ${rawSource}`,
|
|
57
|
+
format: "commonjs",
|
|
58
|
+
shortCircuit: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const transpiledSource = jiti.transform({
|
|
63
|
+
source: rawSource,
|
|
64
|
+
filename: filename,
|
|
65
|
+
ts: url.endsWith("ts"),
|
|
66
|
+
retainLines: true,
|
|
67
|
+
async: true,
|
|
68
|
+
jsx: jiti.options.jsx,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (url.endsWith(".js") && !transpiledSource.includes("jitiImport")) {
|
|
72
|
+
return {
|
|
73
|
+
source: transpiledSource,
|
|
74
|
+
format: "commonjs",
|
|
75
|
+
shortCircuit: true,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
source: _wrapSource(transpiledSource, filename),
|
|
81
|
+
format: "module",
|
|
82
|
+
shortCircuit: true,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function _wrapSource(source, filename) {
|
|
87
|
+
const _jitiPath = new URL("jiti.mjs", import.meta.url).href;
|
|
88
|
+
return /*js*/ `import { createJiti as __createJiti__ } from ${JSON.stringify(_jitiPath)};async function _module(exports, require, module, __filename, __dirname, jitiImport) { ${source}\n};
|
|
89
|
+
// GENERATED BY JITI ESM LOADER
|
|
90
|
+
const filename = ${JSON.stringify(filename)};
|
|
91
|
+
const dirname = ${JSON.stringify(dirname(filename))};
|
|
92
|
+
const jiti = __createJiti__(filename);
|
|
93
|
+
const module = { exports: Object.create(null) };
|
|
94
|
+
await _module(module.exports, jiti, module, filename, dirname, jiti.import);
|
|
95
|
+
if (module.exports && module.exports.__JITI_ERROR__) {
|
|
96
|
+
const { filename, line, column, code, message } =
|
|
97
|
+
module.exports.__JITI_ERROR__;
|
|
98
|
+
const loc = [filename, line, column].join(':');
|
|
99
|
+
const err = new Error(code + ": " + message + " " + loc);
|
|
100
|
+
Error.captureStackTrace(err, _module);
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
export default module.exports;
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function _shouldSkip(url) {
|
|
108
|
+
return (
|
|
109
|
+
!jiti ||
|
|
110
|
+
url.endsWith(".mjs") ||
|
|
111
|
+
url.endsWith(".cjs") ||
|
|
112
|
+
(!url.startsWith("./") && !url.startsWith("file://")) ||
|
|
113
|
+
isBuiltin(url)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function _findClosestPackageJson(dir) {
|
|
118
|
+
if (dir === "/") return null;
|
|
119
|
+
const packageJsonPath = join(dir, "package.json");
|
|
120
|
+
if (existsSync(packageJsonPath)) {
|
|
121
|
+
return JSON.parse(await readFile(packageJsonPath, "utf8"));
|
|
122
|
+
}
|
|
123
|
+
return _findClosestPackageJson(dirname(dir));
|
|
124
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./types').Jiti} Jiti
|
|
3
|
+
* @typedef {import('./types').JitiOptions} JitiOptions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const isDeno = "Deno" in globalThis;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {string|URL} [parentURL]
|
|
10
|
+
* @param {JitiOptions} [jitiOptions]
|
|
11
|
+
* @returns {Jiti}
|
|
12
|
+
*/
|
|
13
|
+
export function createJiti(parentURL, jitiOptions) {
|
|
14
|
+
parentURL = normalizeParentURL(parentURL);
|
|
15
|
+
|
|
16
|
+
/** @type {Jiti} */
|
|
17
|
+
function jiti() {
|
|
18
|
+
throw unsupportedError(
|
|
19
|
+
"`jiti()` is not supported in native mode, use `jiti.import()` instead.",
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
jiti.resolve = () => {
|
|
24
|
+
throw unsupportedError("`jiti.resolve()` is not supported in native mode.");
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
jiti.esmResolve = (id, opts) => {
|
|
28
|
+
try {
|
|
29
|
+
const importMeta = jitiOptions?.importMeta || import.meta;
|
|
30
|
+
if (isDeno) {
|
|
31
|
+
// Deno throws TypeError: Invalid arguments when passing parentURL
|
|
32
|
+
return importMeta.resolve(id);
|
|
33
|
+
}
|
|
34
|
+
const parent = normalizeParentURL(opts?.parentURL || parentURL);
|
|
35
|
+
return importMeta.resolve(id, parent);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (opts?.try) {
|
|
38
|
+
return undefined;
|
|
39
|
+
} else {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
jiti.import = async function (id, opts) {
|
|
46
|
+
for (const suffix of ["", "/index"]) {
|
|
47
|
+
// prettier-ignore
|
|
48
|
+
for (const ext of ["", ".js", ".mjs", ".cjs", ".ts", ".tsx", ".mts", ".cts"]) {
|
|
49
|
+
try {
|
|
50
|
+
const resolved = this.esmResolve(id + suffix + ext, opts);
|
|
51
|
+
if (!resolved) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
let importAttrs = undefined
|
|
55
|
+
if (resolved.endsWith('.json')) {
|
|
56
|
+
importAttrs = { with: { type: 'json'}}
|
|
57
|
+
}
|
|
58
|
+
return await import(resolved, importAttrs);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
if (opts?.try) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!opts?.try) {
|
|
71
|
+
const parent = normalizeParentURL(opts?.parentURL || parentURL);
|
|
72
|
+
const error = new Error(
|
|
73
|
+
`[jiti] [ERR_MODULE_NOT_FOUND] Cannot import '${id}' from '${parent}'.`,
|
|
74
|
+
);
|
|
75
|
+
error.code = "ERR_MODULE_NOT_FOUND";
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
jiti.transform = () => {
|
|
81
|
+
throw unsupportedError(
|
|
82
|
+
"`jiti.transform()` is not supported in native mode.",
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
jiti.evalModule = () => {
|
|
87
|
+
throw unsupportedError(
|
|
88
|
+
"`jiti.evalModule()` is not supported in native mode.",
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
jiti.main = undefined;
|
|
93
|
+
jiti.extensions = Object.create(null);
|
|
94
|
+
jiti.cache = Object.create(null);
|
|
95
|
+
|
|
96
|
+
return jiti;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default createJiti;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {string} message
|
|
103
|
+
*/
|
|
104
|
+
function unsupportedError(message) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`[jiti] ${message} (import or require 'jiti' instead of 'jiti/native' for more features).`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function normalizeParentURL(input) {
|
|
111
|
+
if (!input) {
|
|
112
|
+
return "file:///";
|
|
113
|
+
}
|
|
114
|
+
if (typeof filename !== "string" || input.startsWith("file://")) {
|
|
115
|
+
return input;
|
|
116
|
+
}
|
|
117
|
+
if (input.endsWith("/")) {
|
|
118
|
+
input += "_"; // append a dummy filename
|
|
119
|
+
}
|
|
120
|
+
return `file://${input}`;
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// eslint-disable-next-line unicorn/no-empty-file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import _createJiti from "../dist/jiti.cjs";
|
|
3
|
+
// Static import so Bun bundles babel.cjs into compiled binaries
|
|
4
|
+
import _babelTransform from "../dist/babel.cjs";
|
|
5
|
+
|
|
6
|
+
function onError(err) {
|
|
7
|
+
throw err; /* ↓ Check stack trace ↓ */
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const nativeImport = (id) => import(id);
|
|
11
|
+
|
|
12
|
+
export function createJiti(id, opts = {}) {
|
|
13
|
+
if (!opts.transform) {
|
|
14
|
+
opts = { ...opts, transform: _babelTransform };
|
|
15
|
+
}
|
|
16
|
+
return _createJiti(id, opts, {
|
|
17
|
+
onError,
|
|
18
|
+
nativeImport,
|
|
19
|
+
createRequire,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default createJiti;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const { createRequire } = require("node:module");
|
|
2
|
+
const _createJiti = require("../dist/jiti.cjs");
|
|
3
|
+
|
|
4
|
+
function onError(err) {
|
|
5
|
+
throw err; /* ↓ Check stack trace ↓ */
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const nativeImport = (id) => import(id);
|
|
9
|
+
|
|
10
|
+
let _transform;
|
|
11
|
+
function lazyTransform(...args) {
|
|
12
|
+
if (!_transform) {
|
|
13
|
+
_transform = require("../dist/babel.cjs");
|
|
14
|
+
}
|
|
15
|
+
return _transform(...args);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function createJiti(id, opts = {}) {
|
|
19
|
+
if (!opts.transform) {
|
|
20
|
+
opts = { ...opts, transform: lazyTransform };
|
|
21
|
+
}
|
|
22
|
+
return _createJiti(id, opts, {
|
|
23
|
+
onError,
|
|
24
|
+
nativeImport,
|
|
25
|
+
createRequire,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = createJiti;
|
|
30
|
+
module.exports.createJiti = createJiti;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as types from "./types.js";
|
|
2
|
+
declare const allExports: typeof types & {
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Please use `const { createJiti } = require("jiti")` or use ESM import.
|
|
5
|
+
*/
|
|
6
|
+
(...args: Parameters<typeof types.createJiti>): types.Jiti;
|
|
7
|
+
};
|
|
8
|
+
export = allExports;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import _createJiti from "../dist/jiti.cjs";
|
|
3
|
+
|
|
4
|
+
function onError(err) {
|
|
5
|
+
throw err; /* ↓ Check stack trace ↓ */
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const nativeImport = (id) => import(id);
|
|
9
|
+
|
|
10
|
+
let _transform;
|
|
11
|
+
function lazyTransform(...args) {
|
|
12
|
+
if (!_transform) {
|
|
13
|
+
_transform = createRequire(import.meta.url)("../dist/babel.cjs");
|
|
14
|
+
}
|
|
15
|
+
return _transform(...args);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function createJiti(id, opts = {}) {
|
|
19
|
+
if (!opts.transform) {
|
|
20
|
+
opts = { ...opts, transform: lazyTransform };
|
|
21
|
+
}
|
|
22
|
+
return _createJiti(id, opts, {
|
|
23
|
+
onError,
|
|
24
|
+
nativeImport,
|
|
25
|
+
createRequire,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default createJiti;
|