mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
Revert "chore(deps): route @codemirror imports through src/editor/codemirror barrel"
This reverts commit 6c4d19d229.
This commit is contained in:
parent
dc08ced1f6
commit
ef0c8f3387
14 changed files with 19 additions and 74 deletions
|
|
@ -141,42 +141,6 @@ export default [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// @codemirror/state and @codemirror/view are provided by Obsidian at runtime
|
|
||||||
// (declared as peerDependencies on `obsidian` and marked external in our
|
|
||||||
// esbuild config), so they intentionally aren't listed in our package.json
|
|
||||||
// — when they were, the obsidian community-plugins review ran out of memory
|
|
||||||
// analyzing the resulting dep tree. All imports of these packages must go
|
|
||||||
// through the `src/editor/codemirror.ts` barrel so we can scope the
|
|
||||||
// `import/no-extraneous-dependencies` exemption to a single file. The
|
|
||||||
// barrel itself is exempted here; everywhere else, the
|
|
||||||
// `no-restricted-imports` rule below blocks direct @codemirror imports.
|
|
||||||
{
|
|
||||||
files: ["src/editor/codemirror.ts"],
|
|
||||||
rules: {
|
|
||||||
"import/no-extraneous-dependencies": "off",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ["src/**/*.{ts,tsx}"],
|
|
||||||
ignores: ["src/editor/codemirror.ts"],
|
|
||||||
rules: {
|
|
||||||
"no-restricted-imports": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
patterns: [
|
|
||||||
{
|
|
||||||
group: ["@codemirror/state", "@codemirror/view"],
|
|
||||||
message:
|
|
||||||
"Import codemirror symbols from '@/editor/codemirror' instead. " +
|
|
||||||
"Direct imports from @codemirror/* are restricted because those packages " +
|
|
||||||
"are intentionally absent from package.json (see src/editor/codemirror.ts).",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
// Test files need Jest globals
|
// Test files need Jest globals
|
||||||
{
|
{
|
||||||
files: ["**/*.test.{js,jsx,ts,tsx}", "jest.setup.js", "__mocks__/**"],
|
files: ["**/*.test.{js,jsx,ts,tsx}", "jest.setup.js", "__mocks__/**"],
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import { logError } from "@/logger";
|
||||||
import { cleanMessageForCopy, findCustomModel, insertIntoEditor } from "@/utils";
|
import { cleanMessageForCopy, findCustomModel, insertIntoEditor } from "@/utils";
|
||||||
import { computeVerticalPlacement } from "@/utils/panelPlacement";
|
import { computeVerticalPlacement } from "@/utils/panelPlacement";
|
||||||
import { computeSelectionAnchors } from "@/utils/selectionAnchors";
|
import { computeSelectionAnchors } from "@/utils/selectionAnchors";
|
||||||
import type { EditorView } from "@/editor/codemirror";
|
import type { EditorView } from "@codemirror/view";
|
||||||
import { PenLine } from "lucide-react";
|
import { PenLine } from "lucide-react";
|
||||||
import { App, Component, MarkdownRenderer, Notice, MarkdownView, Scope } from "obsidian";
|
import { App, Component, MarkdownRenderer, Notice, MarkdownView, Scope } from "obsidian";
|
||||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
* QuickAskPanel fills its container and delegates resize events here.
|
* QuickAskPanel fills its container and delegates resize events here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EditorView } from "@/editor/codemirror";
|
import { EditorView } from "@codemirror/view";
|
||||||
import type { Editor } from "obsidian";
|
import type { Editor } from "obsidian";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Root } from "react-dom/client";
|
import { Root } from "react-dom/client";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* Type definitions for Quick Ask feature.
|
* Type definitions for Quick Ask feature.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { EditorView } from "@/editor/codemirror";
|
import type { EditorView } from "@codemirror/view";
|
||||||
import type { Editor } from "obsidian";
|
import type { Editor } from "obsidian";
|
||||||
import type CopilotPlugin from "@/main";
|
import type CopilotPlugin from "@/main";
|
||||||
import type { ReplaceGuard } from "@/editor/replaceGuard";
|
import type { ReplaceGuard } from "@/editor/replaceGuard";
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
* conflicts with SelectionHighlight used by QuickAsk and CustomCommandModal.
|
* conflicts with SelectionHighlight used by QuickAsk and CustomCommandModal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EditorView } from "@/editor/codemirror";
|
import { EditorView } from "@codemirror/view";
|
||||||
import { MarkdownView, type WorkspaceLeaf } from "obsidian";
|
import { MarkdownView, type WorkspaceLeaf } from "obsidian";
|
||||||
|
|
||||||
import type CopilotPlugin from "@/main";
|
import type CopilotPlugin from "@/main";
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
// Re-exports for the @codemirror/* APIs the plugin uses.
|
|
||||||
//
|
|
||||||
// Why this barrel exists: Obsidian provides @codemirror/state and
|
|
||||||
// @codemirror/view at runtime (declared as peerDependencies on `obsidian` and
|
|
||||||
// marked external in esbuild.config.mjs), so they aren't listed in our own
|
|
||||||
// package.json — when we listed them as devDependencies, the obsidian
|
|
||||||
// community-plugins review ran out of memory analyzing the resulting dep tree.
|
|
||||||
// The `import/no-extraneous-dependencies` ESLint rule has no per-package
|
|
||||||
// whitelist, so we funnel every @codemirror import through this single file
|
|
||||||
// and exempt only this file in eslint.config.mjs (paired with a
|
|
||||||
// `no-restricted-imports` rule that forbids direct @codemirror imports
|
|
||||||
// elsewhere). All other source files import codemirror symbols from
|
|
||||||
// `@/editor/codemirror`.
|
|
||||||
|
|
||||||
export { EditorState, StateEffect, StateField } from "@codemirror/state";
|
|
||||||
export type { ChangeDesc, Extension, StateEffectType } from "@codemirror/state";
|
|
||||||
export { Decoration, EditorView, ViewPlugin } from "@codemirror/view";
|
|
||||||
export type { ViewUpdate } from "@codemirror/view";
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { createPersistentHighlight } from "./persistentHighlight";
|
import { createPersistentHighlight } from "./persistentHighlight";
|
||||||
import { EditorState, EditorView } from "@/editor/codemirror";
|
import { EditorState } from "@codemirror/state";
|
||||||
|
import { EditorView } from "@codemirror/view";
|
||||||
|
|
||||||
describe("createPersistentHighlight", () => {
|
describe("createPersistentHighlight", () => {
|
||||||
describe("factory isolation", () => {
|
describe("factory isolation", () => {
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,8 @@
|
||||||
* (e.g. QuickAsk and Chat) can coexist without state conflicts.
|
* (e.g. QuickAsk and Chat) can coexist without state conflicts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { StateEffect, StateEffectType, StateField, type Extension } from "@codemirror/state";
|
||||||
Decoration,
|
import { Decoration, EditorView } from "@codemirror/view";
|
||||||
EditorView,
|
|
||||||
StateEffect,
|
|
||||||
StateField,
|
|
||||||
type Extension,
|
|
||||||
type StateEffectType,
|
|
||||||
} from "@/editor/codemirror";
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Types
|
// Types
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
* Manages the lifecycle of Quick Ask panels and integrates with CM6.
|
* Manages the lifecycle of Quick Ask panels and integrates with CM6.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EditorView, type Extension } from "@/editor/codemirror";
|
import type { Extension } from "@codemirror/state";
|
||||||
|
import { EditorView } from "@codemirror/view";
|
||||||
import { MarkdownView } from "obsidian";
|
import { MarkdownView } from "obsidian";
|
||||||
import { quickAskWidgetEffect, quickAskOverlayPlugin } from "./quickAskExtension";
|
import { quickAskWidgetEffect, quickAskOverlayPlugin } from "./quickAskExtension";
|
||||||
import { QuickAskOverlay } from "@/components/quick-ask/QuickAskOverlay";
|
import { QuickAskOverlay } from "@/components/quick-ask/QuickAskOverlay";
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
* that occur when dispatching from within ViewPlugin.update().
|
* that occur when dispatching from within ViewPlugin.update().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EditorView, StateEffect, ViewPlugin, type ViewUpdate } from "@/editor/codemirror";
|
import { StateEffect } from "@codemirror/state";
|
||||||
|
import { EditorView, ViewPlugin, ViewUpdate } from "@codemirror/view";
|
||||||
import { QuickAskOverlay } from "@/components/quick-ask/QuickAskOverlay";
|
import { QuickAskOverlay } from "@/components/quick-ask/QuickAskOverlay";
|
||||||
import type { QuickAskWidgetPayload } from "@/components/quick-ask/types";
|
import type { QuickAskWidgetPayload } from "@/components/quick-ask/types";
|
||||||
import { mapQuickAskAnchorPositions } from "@/utils/quickAskAnchorMapping";
|
import { mapQuickAskAnchorPositions } from "@/utils/quickAskAnchorMapping";
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import {
|
||||||
createHighlightReplaceGuard,
|
createHighlightReplaceGuard,
|
||||||
getErrorMessage,
|
getErrorMessage,
|
||||||
} from "./replaceGuard";
|
} from "./replaceGuard";
|
||||||
import type { EditorView } from "@/editor/codemirror";
|
import type { EditorView } from "@codemirror/view";
|
||||||
import type { WorkspaceLeaf } from "obsidian";
|
import type { WorkspaceLeaf } from "obsidian";
|
||||||
|
|
||||||
// Mock dependencies
|
// Mock dependencies
|
||||||
|
|
@ -318,7 +318,7 @@ describe("createMapPosReplaceGuard", () => {
|
||||||
mapPos: (pos: number, assoc: number) => pos + 3,
|
mapPos: (pos: number, assoc: number) => pos + 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
guard.onDocChanged?.(mockChanges as unknown as import("@/editor/codemirror").ChangeDesc);
|
guard.onDocChanged?.(mockChanges as unknown as import("@codemirror/state").ChangeDesc);
|
||||||
|
|
||||||
expect(guard.getRange()).toEqual({ from: 3, to: 8 });
|
expect(guard.getRange()).toEqual({ from: 3, to: 8 });
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// src/editor/replaceGuard.ts
|
// src/editor/replaceGuard.ts
|
||||||
|
|
||||||
import type { ChangeDesc, EditorView } from "@/editor/codemirror";
|
import type { ChangeDesc } from "@codemirror/state";
|
||||||
|
import type { EditorView } from "@codemirror/view";
|
||||||
import type { WorkspaceLeaf } from "obsidian";
|
import type { WorkspaceLeaf } from "obsidian";
|
||||||
import { SelectionHighlight } from "./selectionHighlight";
|
import { SelectionHighlight } from "./selectionHighlight";
|
||||||
import { logError } from "@/logger";
|
import { logError } from "@/logger";
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
* factory, preserving the original public API for backwards compatibility.
|
* factory, preserving the original public API for backwards compatibility.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EditorView, StateEffect } from "@/editor/codemirror";
|
import { StateEffect } from "@codemirror/state";
|
||||||
|
import { EditorView } from "@codemirror/view";
|
||||||
import { logError } from "@/logger";
|
import { logError } from "@/logger";
|
||||||
import {
|
import {
|
||||||
createPersistentHighlight,
|
createPersistentHighlight,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type { EditorView } from "@/editor/codemirror";
|
import type { EditorView } from "@codemirror/view";
|
||||||
import { type TFile } from "obsidian";
|
import { type TFile } from "obsidian";
|
||||||
|
|
||||||
declare module "obsidian" {
|
declare module "obsidian" {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue