@code-inspector/core 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-inspector/core",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "types/index.d.ts",
@@ -113,6 +113,7 @@ export declare class CodeInspectorComponent extends LitElement {
113
113
  checked: () => boolean;
114
114
  onChange: () => void;
115
115
  }[];
116
+ private eventListeners;
116
117
  isTracking: (e: any) => boolean | "";
117
118
  getDomPropertyValue: (target: HTMLElement, property: string) => number;
118
119
  calculateElementInfoPosition: (target: HTMLElement) => Promise<{
@@ -180,6 +181,14 @@ export declare class CodeInspectorComponent extends LitElement {
180
181
  toggleLocate: () => void;
181
182
  toggleCopy: () => void;
182
183
  toggleTarget: () => void;
184
+ /**
185
+ * Attach all event listeners
186
+ */
187
+ private attachEventListeners;
188
+ /**
189
+ * Detach all event listeners
190
+ */
191
+ private detachEventListeners;
183
192
  protected firstUpdated(): void;
184
193
  disconnectedCallback(): void;
185
194
  renderNodeTree: (node: TreeNode) => TemplateResult;
@@ -0,0 +1,29 @@
1
+ import MagicString from 'magic-string';
2
+ import { EscapeTags } from '../../shared';
3
+ import type { ElementNode } from '@vue/compiler-dom';
4
+ export interface PugFileInfo {
5
+ content: string;
6
+ offsets: number[];
7
+ }
8
+ export declare const pugMap: Map<string, PugFileInfo>;
9
+ /**
10
+ * Check if a template node uses Pug syntax
11
+ * @param templateNode - The template element node to check
12
+ * @returns true if the template uses Pug, false otherwise
13
+ */
14
+ export declare function isPugTemplate(templateNode: ElementNode | undefined): boolean;
15
+ /**
16
+ * Calculate line offsets for content
17
+ * @param content - The file content
18
+ * @returns Array of line offsets
19
+ */
20
+ export declare function calculateLineOffsets(content: string): number[];
21
+ /**
22
+ * Transform Pug template in Vue SFC
23
+ * @param content - The file content
24
+ * @param filePath - The file path
25
+ * @param templateNode - The template element node
26
+ * @param escapeTags - Tags to escape from transformation
27
+ * @param s - MagicString instance for code transformation
28
+ */
29
+ export declare function transformPugTemplate(content: string, filePath: string, templateNode: ElementNode, escapeTags: EscapeTags, s: MagicString): void;
@@ -6,14 +6,133 @@ export declare function getFilePathWithoutExt(filePath: string): string;
6
6
  export declare function normalizePath(filepath: string): string;
7
7
  export declare function isEscapeTags(escapeTags: EscapeTags, tag: string): boolean;
8
8
  export declare function getDependenciesMap(): any;
9
- export declare function getDenpendencies(): string[];
9
+ export declare function getDependencies(): string[];
10
10
  type BooleanFunction = () => boolean;
11
+ /**
12
+ * Determine if the current environment is development mode
13
+ *
14
+ * Priority: user-specified environment > system default environment
15
+ *
16
+ * @param userDev - User-specified development mode setting:
17
+ * - `true`: Force development mode
18
+ * - `false`: Force production mode
19
+ * - `function`: Dynamic function that returns boolean
20
+ * - `undefined`: Use system default
21
+ * @param systemDev - System default development mode (e.g., from NODE_ENV)
22
+ * @returns `true` if in development mode, `false` otherwise
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Force development mode
27
+ * isDev(true, false) // Returns: true
28
+ *
29
+ * // Force production mode
30
+ * isDev(false, true) // Returns: false
31
+ *
32
+ * // Use system default
33
+ * isDev(undefined, true) // Returns: true
34
+ *
35
+ * // Dynamic function
36
+ * isDev(() => process.env.NODE_ENV === 'development', false)
37
+ * ```
38
+ */
11
39
  export declare function isDev(userDev: boolean | BooleanFunction | undefined, systemDev: boolean): boolean;
40
+ /**
41
+ * Check if a file matches the given condition
42
+ *
43
+ * Supports multiple condition types for flexible file matching:
44
+ * - String: Checks if file path contains the string
45
+ * - RegExp: Tests file path against the regular expression
46
+ * - Array: Recursively checks if file matches any condition in the array
47
+ *
48
+ * @param condition - The condition to match against:
49
+ * - `string`: File path must contain this string
50
+ * - `RegExp`: File path must match this pattern
51
+ * - `Array`: File path must match at least one condition
52
+ * @param file - The file path to check
53
+ * @returns `true` if the file matches the condition, `false` otherwise
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // String matching
58
+ * matchCondition('node_modules', '/path/to/node_modules/pkg') // Returns: true
59
+ *
60
+ * // RegExp matching
61
+ * matchCondition(/\.test\.ts$/, 'file.test.ts') // Returns: true
62
+ *
63
+ * // Array matching (OR logic)
64
+ * matchCondition(['src', /\.tsx$/], 'src/App.tsx') // Returns: true
65
+ * ```
66
+ */
12
67
  export declare function matchCondition(condition: Condition, file: string): boolean;
68
+ /**
69
+ * Get the mapped file path based on the provided mappings configuration
70
+ *
71
+ * This function resolves file paths by applying mapping rules, which is useful for:
72
+ * - Resolving module aliases (e.g., '@/components' -> 'src/components')
73
+ * - Mapping node_modules paths to local source paths
74
+ * - Handling monorepo package paths
75
+ *
76
+ * @param file - The original file path to map
77
+ * @param mappings - Path mapping configuration, can be either:
78
+ * - Object: `{ '@/': 'src/', '~': 'node_modules/' }`
79
+ * - Array: `[{ find: '@/', replacement: 'src/' }, { find: /^~/, replacement: 'node_modules/' }]`
80
+ * @returns The mapped file path if a mapping is found and the file exists, otherwise returns the original path
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // Object mapping
85
+ * getMappingFilePath('@/components/Button.tsx', { '@/': 'src/' })
86
+ * // Returns: 'src/components/Button.tsx' (if file exists)
87
+ *
88
+ * // Array mapping with RegExp
89
+ * getMappingFilePath('~/lodash/index.js', [
90
+ * { find: /^~/, replacement: 'node_modules/' }
91
+ * ])
92
+ * // Returns: 'node_modules/lodash/index.js' (if file exists)
93
+ * ```
94
+ */
13
95
  export declare function getMappingFilePath(file: string, mappings?: Record<string, string> | Array<{
14
96
  find: string | RegExp;
15
97
  replacement: string;
16
98
  }>): string;
99
+ /**
100
+ * Check if a file should be excluded from processing
101
+ *
102
+ * Determines if a file should be excluded based on exclude/include patterns.
103
+ * Files in node_modules are always excluded unless explicitly included.
104
+ *
105
+ * Logic:
106
+ * - If file matches exclude pattern AND NOT in include pattern → excluded
107
+ * - If file matches include pattern → NOT excluded (even if in node_modules)
108
+ * - node_modules is always in the exclude list by default
109
+ *
110
+ * @param file - The file path to check
111
+ * @param options - Code inspector options containing exclude/include patterns
112
+ * @returns `true` if the file should be excluded, `false` otherwise
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const options = {
117
+ * exclude: [/\.test\.ts$/, 'dist'],
118
+ * include: ['src']
119
+ * };
120
+ *
121
+ * isExcludedFile('src/App.test.ts', options) // Returns: true (matches exclude)
122
+ * isExcludedFile('node_modules/pkg/index.js', options) // Returns: true (node_modules)
123
+ * isExcludedFile('src/index.ts', options) // Returns: false (in include)
124
+ * ```
125
+ */
17
126
  export declare function isExcludedFile(file: string, options: CodeOptions): boolean;
18
127
  export declare function hasWritePermission(filePath: string): boolean;
128
+ /**
129
+ * Check if a file should be ignored based on special directives in comments
130
+ * @param content - The file content to check
131
+ * @param fileType - The type of file ('vue', 'jsx', 'svelte', or unknown)
132
+ * @returns true if the file should be ignored, false otherwise
133
+ */
134
+ export declare function isIgnoredFile({ content, fileType, }: {
135
+ content: string;
136
+ fileType: 'vue' | 'jsx' | 'svelte' | unknown;
137
+ }): boolean;
19
138
  export {};