agent-ide 0.1.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 +678 -0
- package/bin/agent-ide.js +19 -0
- package/bin/mcp-server.js +20 -0
- package/dist/application/events/event-bus.d.ts +107 -0
- package/dist/application/events/event-bus.d.ts.map +1 -0
- package/dist/application/events/event-bus.js +364 -0
- package/dist/application/events/event-bus.js.map +1 -0
- package/dist/application/events/event-types.d.ts +195 -0
- package/dist/application/events/event-types.d.ts.map +1 -0
- package/dist/application/events/event-types.js +36 -0
- package/dist/application/events/event-types.js.map +1 -0
- package/dist/application/events/index.d.ts +6 -0
- package/dist/application/events/index.d.ts.map +1 -0
- package/dist/application/events/index.js +6 -0
- package/dist/application/events/index.js.map +1 -0
- package/dist/application/index.d.ts +85 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +138 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/services/cache-coordinator.service.d.ts +69 -0
- package/dist/application/services/cache-coordinator.service.d.ts.map +1 -0
- package/dist/application/services/cache-coordinator.service.js +251 -0
- package/dist/application/services/cache-coordinator.service.js.map +1 -0
- package/dist/application/services/error-handler.service.d.ts +56 -0
- package/dist/application/services/error-handler.service.d.ts.map +1 -0
- package/dist/application/services/error-handler.service.js +273 -0
- package/dist/application/services/error-handler.service.js.map +1 -0
- package/dist/application/services/index.d.ts +8 -0
- package/dist/application/services/index.d.ts.map +1 -0
- package/dist/application/services/index.js +8 -0
- package/dist/application/services/index.js.map +1 -0
- package/dist/application/services/module-coordinator.service.d.ts +70 -0
- package/dist/application/services/module-coordinator.service.d.ts.map +1 -0
- package/dist/application/services/module-coordinator.service.js +418 -0
- package/dist/application/services/module-coordinator.service.js.map +1 -0
- package/dist/application/services/session-manager.service.d.ts +86 -0
- package/dist/application/services/session-manager.service.d.ts.map +1 -0
- package/dist/application/services/session-manager.service.js +318 -0
- package/dist/application/services/session-manager.service.js.map +1 -0
- package/dist/application/services/workflow-engine.service.d.ts +76 -0
- package/dist/application/services/workflow-engine.service.d.ts.map +1 -0
- package/dist/application/services/workflow-engine.service.js +405 -0
- package/dist/application/services/workflow-engine.service.js.map +1 -0
- package/dist/application/state/application-state.d.ts +164 -0
- package/dist/application/state/application-state.d.ts.map +1 -0
- package/dist/application/state/application-state.js +290 -0
- package/dist/application/state/application-state.js.map +1 -0
- package/dist/application/state/index.d.ts +15 -0
- package/dist/application/state/index.d.ts.map +1 -0
- package/dist/application/state/index.js +15 -0
- package/dist/application/state/index.js.map +1 -0
- package/dist/application/state/session-state.d.ts +114 -0
- package/dist/application/state/session-state.d.ts.map +1 -0
- package/dist/application/state/session-state.js +188 -0
- package/dist/application/state/session-state.js.map +1 -0
- package/dist/application/state/state-manager.d.ts +122 -0
- package/dist/application/state/state-manager.d.ts.map +1 -0
- package/dist/application/state/state-manager.js +234 -0
- package/dist/application/state/state-manager.js.map +1 -0
- package/dist/application/types.d.ts +280 -0
- package/dist/application/types.d.ts.map +1 -0
- package/dist/application/types.js +13 -0
- package/dist/application/types.js.map +1 -0
- package/dist/application/workflows/analysis-workflow.d.ts +239 -0
- package/dist/application/workflows/analysis-workflow.d.ts.map +1 -0
- package/dist/application/workflows/analysis-workflow.js +395 -0
- package/dist/application/workflows/analysis-workflow.js.map +1 -0
- package/dist/application/workflows/base-workflow.d.ts +108 -0
- package/dist/application/workflows/base-workflow.d.ts.map +1 -0
- package/dist/application/workflows/base-workflow.js +236 -0
- package/dist/application/workflows/base-workflow.js.map +1 -0
- package/dist/application/workflows/index.d.ts +115 -0
- package/dist/application/workflows/index.d.ts.map +1 -0
- package/dist/application/workflows/index.js +218 -0
- package/dist/application/workflows/index.js.map +1 -0
- package/dist/application/workflows/refactor-workflow.d.ts +107 -0
- package/dist/application/workflows/refactor-workflow.d.ts.map +1 -0
- package/dist/application/workflows/refactor-workflow.js +310 -0
- package/dist/application/workflows/refactor-workflow.js.map +1 -0
- package/dist/core/analysis/complexity-analyzer.d.ts +81 -0
- package/dist/core/analysis/complexity-analyzer.d.ts.map +1 -0
- package/dist/core/analysis/complexity-analyzer.js +254 -0
- package/dist/core/analysis/complexity-analyzer.js.map +1 -0
- package/dist/core/analysis/dead-code-detector.d.ts +123 -0
- package/dist/core/analysis/dead-code-detector.d.ts.map +1 -0
- package/dist/core/analysis/dead-code-detector.js +275 -0
- package/dist/core/analysis/dead-code-detector.js.map +1 -0
- package/dist/core/analysis/duplication-detector.d.ts +150 -0
- package/dist/core/analysis/duplication-detector.d.ts.map +1 -0
- package/dist/core/analysis/duplication-detector.js +433 -0
- package/dist/core/analysis/duplication-detector.js.map +1 -0
- package/dist/core/analysis/index.d.ts +9 -0
- package/dist/core/analysis/index.d.ts.map +1 -0
- package/dist/core/analysis/index.js +13 -0
- package/dist/core/analysis/index.js.map +1 -0
- package/dist/core/analysis/quality-metrics.d.ts +158 -0
- package/dist/core/analysis/quality-metrics.d.ts.map +1 -0
- package/dist/core/analysis/quality-metrics.js +442 -0
- package/dist/core/analysis/quality-metrics.js.map +1 -0
- package/dist/core/dependency/cycle-detector.d.ts +81 -0
- package/dist/core/dependency/cycle-detector.d.ts.map +1 -0
- package/dist/core/dependency/cycle-detector.js +300 -0
- package/dist/core/dependency/cycle-detector.js.map +1 -0
- package/dist/core/dependency/dependency-analyzer.d.ts +152 -0
- package/dist/core/dependency/dependency-analyzer.d.ts.map +1 -0
- package/dist/core/dependency/dependency-analyzer.js +458 -0
- package/dist/core/dependency/dependency-analyzer.js.map +1 -0
- package/dist/core/dependency/dependency-graph.d.ts +156 -0
- package/dist/core/dependency/dependency-graph.d.ts.map +1 -0
- package/dist/core/dependency/dependency-graph.js +371 -0
- package/dist/core/dependency/dependency-graph.js.map +1 -0
- package/dist/core/dependency/index.d.ts +27 -0
- package/dist/core/dependency/index.d.ts.map +1 -0
- package/dist/core/dependency/index.js +36 -0
- package/dist/core/dependency/index.js.map +1 -0
- package/dist/core/dependency/types.d.ts +168 -0
- package/dist/core/dependency/types.d.ts.map +1 -0
- package/dist/core/dependency/types.js +103 -0
- package/dist/core/dependency/types.js.map +1 -0
- package/dist/core/indexing/file-index.d.ts +117 -0
- package/dist/core/indexing/file-index.d.ts.map +1 -0
- package/dist/core/indexing/file-index.js +302 -0
- package/dist/core/indexing/file-index.js.map +1 -0
- package/dist/core/indexing/file-watcher.d.ts +110 -0
- package/dist/core/indexing/file-watcher.d.ts.map +1 -0
- package/dist/core/indexing/file-watcher.js +280 -0
- package/dist/core/indexing/file-watcher.js.map +1 -0
- package/dist/core/indexing/index-engine.d.ts +120 -0
- package/dist/core/indexing/index-engine.d.ts.map +1 -0
- package/dist/core/indexing/index-engine.js +445 -0
- package/dist/core/indexing/index-engine.js.map +1 -0
- package/dist/core/indexing/index.d.ts +25 -0
- package/dist/core/indexing/index.d.ts.map +1 -0
- package/dist/core/indexing/index.js +36 -0
- package/dist/core/indexing/index.js.map +1 -0
- package/dist/core/indexing/symbol-index.d.ts +107 -0
- package/dist/core/indexing/symbol-index.d.ts.map +1 -0
- package/dist/core/indexing/symbol-index.js +352 -0
- package/dist/core/indexing/symbol-index.js.map +1 -0
- package/dist/core/indexing/types.d.ts +222 -0
- package/dist/core/indexing/types.d.ts.map +1 -0
- package/dist/core/indexing/types.js +143 -0
- package/dist/core/indexing/types.js.map +1 -0
- package/dist/core/move/import-resolver.d.ts +54 -0
- package/dist/core/move/import-resolver.d.ts.map +1 -0
- package/dist/core/move/import-resolver.js +268 -0
- package/dist/core/move/import-resolver.js.map +1 -0
- package/dist/core/move/index.d.ts +10 -0
- package/dist/core/move/index.d.ts.map +1 -0
- package/dist/core/move/index.js +12 -0
- package/dist/core/move/index.js.map +1 -0
- package/dist/core/move/move-service.d.ts +67 -0
- package/dist/core/move/move-service.d.ts.map +1 -0
- package/dist/core/move/move-service.js +400 -0
- package/dist/core/move/move-service.js.map +1 -0
- package/dist/core/move/types.d.ts +266 -0
- package/dist/core/move/types.d.ts.map +1 -0
- package/dist/core/move/types.js +101 -0
- package/dist/core/move/types.js.map +1 -0
- package/dist/core/performance/analyzer.d.ts +62 -0
- package/dist/core/performance/analyzer.d.ts.map +1 -0
- package/dist/core/performance/analyzer.js +378 -0
- package/dist/core/performance/analyzer.js.map +1 -0
- package/dist/core/performance/cache-manager.d.ts +161 -0
- package/dist/core/performance/cache-manager.d.ts.map +1 -0
- package/dist/core/performance/cache-manager.js +375 -0
- package/dist/core/performance/cache-manager.js.map +1 -0
- package/dist/core/performance/index.d.ts +14 -0
- package/dist/core/performance/index.d.ts.map +1 -0
- package/dist/core/performance/index.js +17 -0
- package/dist/core/performance/index.js.map +1 -0
- package/dist/core/performance/interfaces.d.ts +188 -0
- package/dist/core/performance/interfaces.d.ts.map +1 -0
- package/dist/core/performance/interfaces.js +17 -0
- package/dist/core/performance/interfaces.js.map +1 -0
- package/dist/core/performance/memory-manager.d.ts +176 -0
- package/dist/core/performance/memory-manager.d.ts.map +1 -0
- package/dist/core/performance/memory-manager.js +364 -0
- package/dist/core/performance/memory-manager.js.map +1 -0
- package/dist/core/performance/monitor.d.ts +92 -0
- package/dist/core/performance/monitor.d.ts.map +1 -0
- package/dist/core/performance/monitor.js +228 -0
- package/dist/core/performance/monitor.js.map +1 -0
- package/dist/core/refactor/design-patterns.d.ts +178 -0
- package/dist/core/refactor/design-patterns.d.ts.map +1 -0
- package/dist/core/refactor/design-patterns.js +656 -0
- package/dist/core/refactor/design-patterns.js.map +1 -0
- package/dist/core/refactor/extract-function.d.ts +175 -0
- package/dist/core/refactor/extract-function.d.ts.map +1 -0
- package/dist/core/refactor/extract-function.js +478 -0
- package/dist/core/refactor/extract-function.js.map +1 -0
- package/dist/core/refactor/index.d.ts +8 -0
- package/dist/core/refactor/index.d.ts.map +1 -0
- package/dist/core/refactor/index.js +11 -0
- package/dist/core/refactor/index.js.map +1 -0
- package/dist/core/refactor/inline-function.d.ts +175 -0
- package/dist/core/refactor/inline-function.d.ts.map +1 -0
- package/dist/core/refactor/inline-function.js +425 -0
- package/dist/core/refactor/inline-function.js.map +1 -0
- package/dist/core/rename/index.d.ts +9 -0
- package/dist/core/rename/index.d.ts.map +1 -0
- package/dist/core/rename/index.js +13 -0
- package/dist/core/rename/index.js.map +1 -0
- package/dist/core/rename/reference-updater.d.ts +77 -0
- package/dist/core/rename/reference-updater.d.ts.map +1 -0
- package/dist/core/rename/reference-updater.js +400 -0
- package/dist/core/rename/reference-updater.js.map +1 -0
- package/dist/core/rename/rename-engine.d.ts +69 -0
- package/dist/core/rename/rename-engine.d.ts.map +1 -0
- package/dist/core/rename/rename-engine.js +350 -0
- package/dist/core/rename/rename-engine.js.map +1 -0
- package/dist/core/rename/scope-analyzer.d.ts +75 -0
- package/dist/core/rename/scope-analyzer.d.ts.map +1 -0
- package/dist/core/rename/scope-analyzer.js +269 -0
- package/dist/core/rename/scope-analyzer.js.map +1 -0
- package/dist/core/rename/types.d.ts +163 -0
- package/dist/core/rename/types.d.ts.map +1 -0
- package/dist/core/rename/types.js +80 -0
- package/dist/core/rename/types.js.map +1 -0
- package/dist/core/search/engines/text-engine.d.ts +52 -0
- package/dist/core/search/engines/text-engine.d.ts.map +1 -0
- package/dist/core/search/engines/text-engine.js +376 -0
- package/dist/core/search/engines/text-engine.js.map +1 -0
- package/dist/core/search/index.d.ts +10 -0
- package/dist/core/search/index.d.ts.map +1 -0
- package/dist/core/search/index.js +11 -0
- package/dist/core/search/index.js.map +1 -0
- package/dist/core/search/service.d.ts +105 -0
- package/dist/core/search/service.d.ts.map +1 -0
- package/dist/core/search/service.js +384 -0
- package/dist/core/search/service.js.map +1 -0
- package/dist/core/search/types.d.ts +357 -0
- package/dist/core/search/types.d.ts.map +1 -0
- package/dist/core/search/types.js +47 -0
- package/dist/core/search/types.js.map +1 -0
- package/dist/infrastructure/cache/cache-manager.d.ts +113 -0
- package/dist/infrastructure/cache/cache-manager.d.ts.map +1 -0
- package/dist/infrastructure/cache/cache-manager.js +279 -0
- package/dist/infrastructure/cache/cache-manager.js.map +1 -0
- package/dist/infrastructure/cache/index.d.ts +138 -0
- package/dist/infrastructure/cache/index.d.ts.map +1 -0
- package/dist/infrastructure/cache/index.js +266 -0
- package/dist/infrastructure/cache/index.js.map +1 -0
- package/dist/infrastructure/cache/memory-cache.d.ts +94 -0
- package/dist/infrastructure/cache/memory-cache.d.ts.map +1 -0
- package/dist/infrastructure/cache/memory-cache.js +327 -0
- package/dist/infrastructure/cache/memory-cache.js.map +1 -0
- package/dist/infrastructure/cache/strategies.d.ts +99 -0
- package/dist/infrastructure/cache/strategies.d.ts.map +1 -0
- package/dist/infrastructure/cache/strategies.js +230 -0
- package/dist/infrastructure/cache/strategies.js.map +1 -0
- package/dist/infrastructure/cache/types.d.ts +220 -0
- package/dist/infrastructure/cache/types.d.ts.map +1 -0
- package/dist/infrastructure/cache/types.js +42 -0
- package/dist/infrastructure/cache/types.js.map +1 -0
- package/dist/infrastructure/parser/base.d.ts +126 -0
- package/dist/infrastructure/parser/base.d.ts.map +1 -0
- package/dist/infrastructure/parser/base.js +269 -0
- package/dist/infrastructure/parser/base.js.map +1 -0
- package/dist/infrastructure/parser/factory.d.ts +141 -0
- package/dist/infrastructure/parser/factory.d.ts.map +1 -0
- package/dist/infrastructure/parser/factory.js +306 -0
- package/dist/infrastructure/parser/factory.js.map +1 -0
- package/dist/infrastructure/parser/index.d.ts +12 -0
- package/dist/infrastructure/parser/index.d.ts.map +1 -0
- package/dist/infrastructure/parser/index.js +12 -0
- package/dist/infrastructure/parser/index.js.map +1 -0
- package/dist/infrastructure/parser/interface.d.ts +108 -0
- package/dist/infrastructure/parser/interface.d.ts.map +1 -0
- package/dist/infrastructure/parser/interface.js +72 -0
- package/dist/infrastructure/parser/interface.js.map +1 -0
- package/dist/infrastructure/parser/registry.d.ts +141 -0
- package/dist/infrastructure/parser/registry.d.ts.map +1 -0
- package/dist/infrastructure/parser/registry.js +289 -0
- package/dist/infrastructure/parser/registry.js.map +1 -0
- package/dist/infrastructure/parser/types.d.ts +172 -0
- package/dist/infrastructure/parser/types.d.ts.map +1 -0
- package/dist/infrastructure/parser/types.js +147 -0
- package/dist/infrastructure/parser/types.js.map +1 -0
- package/dist/infrastructure/storage/file-system.d.ts +74 -0
- package/dist/infrastructure/storage/file-system.d.ts.map +1 -0
- package/dist/infrastructure/storage/file-system.js +334 -0
- package/dist/infrastructure/storage/file-system.js.map +1 -0
- package/dist/infrastructure/storage/file-watcher.d.ts +84 -0
- package/dist/infrastructure/storage/file-watcher.d.ts.map +1 -0
- package/dist/infrastructure/storage/file-watcher.js +249 -0
- package/dist/infrastructure/storage/file-watcher.js.map +1 -0
- package/dist/infrastructure/storage/index.d.ts +11 -0
- package/dist/infrastructure/storage/index.d.ts.map +1 -0
- package/dist/infrastructure/storage/index.js +16 -0
- package/dist/infrastructure/storage/index.js.map +1 -0
- package/dist/infrastructure/storage/path-utils.d.ts +96 -0
- package/dist/infrastructure/storage/path-utils.d.ts.map +1 -0
- package/dist/infrastructure/storage/path-utils.js +272 -0
- package/dist/infrastructure/storage/path-utils.js.map +1 -0
- package/dist/infrastructure/storage/types.d.ts +106 -0
- package/dist/infrastructure/storage/types.d.ts.map +1 -0
- package/dist/infrastructure/storage/types.js +53 -0
- package/dist/infrastructure/storage/types.js.map +1 -0
- package/dist/interfaces/cli/cli.d.ts +70 -0
- package/dist/interfaces/cli/cli.d.ts.map +1 -0
- package/dist/interfaces/cli/cli.js +1054 -0
- package/dist/interfaces/cli/cli.js.map +1 -0
- package/dist/interfaces/cli/index.d.ts +7 -0
- package/dist/interfaces/cli/index.d.ts.map +1 -0
- package/dist/interfaces/cli/index.js +22 -0
- package/dist/interfaces/cli/index.js.map +1 -0
- package/dist/interfaces/mcp/index.d.ts +7 -0
- package/dist/interfaces/mcp/index.d.ts.map +1 -0
- package/dist/interfaces/mcp/index.js +6 -0
- package/dist/interfaces/mcp/index.js.map +1 -0
- package/dist/interfaces/mcp/mcp-server.d.ts +34 -0
- package/dist/interfaces/mcp/mcp-server.d.ts.map +1 -0
- package/dist/interfaces/mcp/mcp-server.js +154 -0
- package/dist/interfaces/mcp/mcp-server.js.map +1 -0
- package/dist/interfaces/mcp/mcp.d.ts +44 -0
- package/dist/interfaces/mcp/mcp.d.ts.map +1 -0
- package/dist/interfaces/mcp/mcp.js +559 -0
- package/dist/interfaces/mcp/mcp.js.map +1 -0
- package/dist/plugins/javascript/index.d.ts +12 -0
- package/dist/plugins/javascript/index.d.ts.map +1 -0
- package/dist/plugins/javascript/index.js +16 -0
- package/dist/plugins/javascript/index.js.map +1 -0
- package/dist/plugins/javascript/parser.d.ts +81 -0
- package/dist/plugins/javascript/parser.d.ts.map +1 -0
- package/dist/plugins/javascript/parser.js +457 -0
- package/dist/plugins/javascript/parser.js.map +1 -0
- package/dist/plugins/javascript/types.d.ts +131 -0
- package/dist/plugins/javascript/types.d.ts.map +1 -0
- package/dist/plugins/javascript/types.js +366 -0
- package/dist/plugins/javascript/types.js.map +1 -0
- package/dist/plugins/swift/index.d.ts +11 -0
- package/dist/plugins/swift/index.d.ts.map +1 -0
- package/dist/plugins/swift/index.js +15 -0
- package/dist/plugins/swift/index.js.map +1 -0
- package/dist/plugins/swift/parser.d.ts +98 -0
- package/dist/plugins/swift/parser.d.ts.map +1 -0
- package/dist/plugins/swift/parser.js +612 -0
- package/dist/plugins/swift/parser.js.map +1 -0
- package/dist/plugins/swift/types.d.ts +196 -0
- package/dist/plugins/swift/types.d.ts.map +1 -0
- package/dist/plugins/swift/types.js +268 -0
- package/dist/plugins/swift/types.js.map +1 -0
- package/dist/plugins/typescript/dependency-analyzer.d.ts +78 -0
- package/dist/plugins/typescript/dependency-analyzer.d.ts.map +1 -0
- package/dist/plugins/typescript/dependency-analyzer.js +305 -0
- package/dist/plugins/typescript/dependency-analyzer.js.map +1 -0
- package/dist/plugins/typescript/index.d.ts +9 -0
- package/dist/plugins/typescript/index.d.ts.map +1 -0
- package/dist/plugins/typescript/index.js +8 -0
- package/dist/plugins/typescript/index.js.map +1 -0
- package/dist/plugins/typescript/parser.d.ts +117 -0
- package/dist/plugins/typescript/parser.d.ts.map +1 -0
- package/dist/plugins/typescript/parser.js +888 -0
- package/dist/plugins/typescript/parser.js.map +1 -0
- package/dist/plugins/typescript/symbol-extractor.d.ts +76 -0
- package/dist/plugins/typescript/symbol-extractor.d.ts.map +1 -0
- package/dist/plugins/typescript/symbol-extractor.js +339 -0
- package/dist/plugins/typescript/symbol-extractor.js.map +1 -0
- package/dist/plugins/typescript/types.d.ts +131 -0
- package/dist/plugins/typescript/types.d.ts.map +1 -0
- package/dist/plugins/typescript/types.js +331 -0
- package/dist/plugins/typescript/types.js.map +1 -0
- package/dist/shared/errors/base-error.d.ts +27 -0
- package/dist/shared/errors/base-error.d.ts.map +1 -0
- package/dist/shared/errors/base-error.js +58 -0
- package/dist/shared/errors/base-error.js.map +1 -0
- package/dist/shared/errors/config-error.d.ts +21 -0
- package/dist/shared/errors/config-error.d.ts.map +1 -0
- package/dist/shared/errors/config-error.js +34 -0
- package/dist/shared/errors/config-error.js.map +1 -0
- package/dist/shared/errors/file-error.d.ts +21 -0
- package/dist/shared/errors/file-error.d.ts.map +1 -0
- package/dist/shared/errors/file-error.js +34 -0
- package/dist/shared/errors/file-error.js.map +1 -0
- package/dist/shared/errors/index.d.ts +59 -0
- package/dist/shared/errors/index.d.ts.map +1 -0
- package/dist/shared/errors/index.js +114 -0
- package/dist/shared/errors/index.js.map +1 -0
- package/dist/shared/errors/parser-error.d.ts +72 -0
- package/dist/shared/errors/parser-error.d.ts.map +1 -0
- package/dist/shared/errors/parser-error.js +104 -0
- package/dist/shared/errors/parser-error.js.map +1 -0
- package/dist/shared/errors/validation-error.d.ts +21 -0
- package/dist/shared/errors/validation-error.d.ts.map +1 -0
- package/dist/shared/errors/validation-error.js +34 -0
- package/dist/shared/errors/validation-error.js.map +1 -0
- package/dist/shared/index.d.ts +11 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +22 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/types/ast.d.ts +78 -0
- package/dist/shared/types/ast.d.ts.map +1 -0
- package/dist/shared/types/ast.js +215 -0
- package/dist/shared/types/ast.js.map +1 -0
- package/dist/shared/types/core.d.ts +65 -0
- package/dist/shared/types/core.d.ts.map +1 -0
- package/dist/shared/types/core.js +114 -0
- package/dist/shared/types/core.js.map +1 -0
- package/dist/shared/types/index.d.ts +11 -0
- package/dist/shared/types/index.d.ts.map +1 -0
- package/dist/shared/types/index.js +12 -0
- package/dist/shared/types/index.js.map +1 -0
- package/dist/shared/types/symbol.d.ts +119 -0
- package/dist/shared/types/symbol.d.ts.map +1 -0
- package/dist/shared/types/symbol.js +197 -0
- package/dist/shared/types/symbol.js.map +1 -0
- package/dist/shared/utils/array.d.ts +68 -0
- package/dist/shared/utils/array.d.ts.map +1 -0
- package/dist/shared/utils/array.js +165 -0
- package/dist/shared/utils/array.js.map +1 -0
- package/dist/shared/utils/async.d.ts +87 -0
- package/dist/shared/utils/async.d.ts.map +1 -0
- package/dist/shared/utils/async.js +185 -0
- package/dist/shared/utils/async.js.map +1 -0
- package/dist/shared/utils/index.d.ts +32 -0
- package/dist/shared/utils/index.d.ts.map +1 -0
- package/dist/shared/utils/index.js +37 -0
- package/dist/shared/utils/index.js.map +1 -0
- package/dist/shared/utils/memory-monitor.d.ts +83 -0
- package/dist/shared/utils/memory-monitor.d.ts.map +1 -0
- package/dist/shared/utils/memory-monitor.js +168 -0
- package/dist/shared/utils/memory-monitor.js.map +1 -0
- package/dist/shared/utils/object.d.ts +71 -0
- package/dist/shared/utils/object.d.ts.map +1 -0
- package/dist/shared/utils/object.js +284 -0
- package/dist/shared/utils/object.js.map +1 -0
- package/dist/shared/utils/path.d.ts +59 -0
- package/dist/shared/utils/path.d.ts.map +1 -0
- package/dist/shared/utils/path.js +201 -0
- package/dist/shared/utils/path.js.map +1 -0
- package/dist/shared/utils/string.d.ts +74 -0
- package/dist/shared/utils/string.d.ts.map +1 -0
- package/dist/shared/utils/string.js +201 -0
- package/dist/shared/utils/string.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 深度複製物件
|
|
3
|
+
* @param obj 待複製的物件
|
|
4
|
+
* @param visited 已訪問的物件(用於處理循環引用)
|
|
5
|
+
* @returns 深度複製後的物件
|
|
6
|
+
*/
|
|
7
|
+
export function deepClone(obj, visited = new WeakMap()) {
|
|
8
|
+
// 處理基本型別
|
|
9
|
+
if (obj === null || typeof obj !== 'object') {
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
// 處理循環引用
|
|
13
|
+
if (visited.has(obj)) {
|
|
14
|
+
return visited.get(obj);
|
|
15
|
+
}
|
|
16
|
+
// 處理日期
|
|
17
|
+
if (obj instanceof Date) {
|
|
18
|
+
return new Date(obj.getTime());
|
|
19
|
+
}
|
|
20
|
+
// 處理正則表達式
|
|
21
|
+
if (obj instanceof RegExp) {
|
|
22
|
+
return new RegExp(obj.source, obj.flags);
|
|
23
|
+
}
|
|
24
|
+
// 處理陣列
|
|
25
|
+
if (Array.isArray(obj)) {
|
|
26
|
+
const clonedArray = [];
|
|
27
|
+
visited.set(obj, clonedArray);
|
|
28
|
+
for (let i = 0; i < obj.length; i++) {
|
|
29
|
+
clonedArray[i] = deepClone(obj[i], visited);
|
|
30
|
+
}
|
|
31
|
+
return clonedArray;
|
|
32
|
+
}
|
|
33
|
+
// 處理物件
|
|
34
|
+
const clonedObj = {};
|
|
35
|
+
visited.set(obj, clonedObj);
|
|
36
|
+
for (const key in obj) {
|
|
37
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
38
|
+
clonedObj[key] = deepClone(obj[key], visited);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return clonedObj;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 深度合併多個物件
|
|
45
|
+
* @param target 目標物件
|
|
46
|
+
* @param sources 來源物件
|
|
47
|
+
* @returns 合併後的物件
|
|
48
|
+
*/
|
|
49
|
+
export function deepMerge(target, ...sources) {
|
|
50
|
+
if (!sources.length) {
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
const result = deepClone(target);
|
|
54
|
+
for (const source of sources) {
|
|
55
|
+
mergeObjects(result, source);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 輔助函式:合併兩個物件
|
|
61
|
+
*/
|
|
62
|
+
function mergeObjects(target, source) {
|
|
63
|
+
for (const key in source) {
|
|
64
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
65
|
+
const sourceValue = source[key];
|
|
66
|
+
const targetValue = target[key];
|
|
67
|
+
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
68
|
+
mergeObjects(targetValue, sourceValue);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
target[key] = deepClone(sourceValue);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 檢查是否為純物件
|
|
78
|
+
*/
|
|
79
|
+
function isPlainObject(obj) {
|
|
80
|
+
return obj !== null &&
|
|
81
|
+
typeof obj === 'object' &&
|
|
82
|
+
!Array.isArray(obj) &&
|
|
83
|
+
!(obj instanceof Date) &&
|
|
84
|
+
!(obj instanceof RegExp);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 選取物件的指定屬性
|
|
88
|
+
* @param obj 來源物件
|
|
89
|
+
* @param keys 要選取的屬性鍵值
|
|
90
|
+
* @returns 包含指定屬性的新物件
|
|
91
|
+
*/
|
|
92
|
+
export function pick(obj, keys) {
|
|
93
|
+
const result = {};
|
|
94
|
+
for (const key of keys) {
|
|
95
|
+
if (key in obj) {
|
|
96
|
+
result[key] = obj[key];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 排除物件的指定屬性
|
|
103
|
+
* @param obj 來源物件
|
|
104
|
+
* @param keys 要排除的屬性鍵值
|
|
105
|
+
* @returns 排除指定屬性後的新物件
|
|
106
|
+
*/
|
|
107
|
+
export function omit(obj, keys) {
|
|
108
|
+
const result = { ...obj };
|
|
109
|
+
const keySet = new Set(keys);
|
|
110
|
+
for (const key in result) {
|
|
111
|
+
if (keySet.has(key)) {
|
|
112
|
+
delete result[key];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 檢查值是否為空
|
|
119
|
+
* @param value 待檢查的值
|
|
120
|
+
* @returns 是否為空
|
|
121
|
+
*/
|
|
122
|
+
export function isEmpty(value) {
|
|
123
|
+
if (value == null) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
if (typeof value === 'string' || Array.isArray(value)) {
|
|
127
|
+
return value.length === 0;
|
|
128
|
+
}
|
|
129
|
+
if (value instanceof Map || value instanceof Set) {
|
|
130
|
+
return value.size === 0;
|
|
131
|
+
}
|
|
132
|
+
if (typeof value === 'object') {
|
|
133
|
+
return Object.keys(value).length === 0;
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 深度比較兩個值是否相等
|
|
139
|
+
* @param a 第一個值
|
|
140
|
+
* @param b 第二個值
|
|
141
|
+
* @returns 是否相等
|
|
142
|
+
*/
|
|
143
|
+
export function isEqual(a, b) {
|
|
144
|
+
if (a === b) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
if (a == null || b == null) {
|
|
148
|
+
return a === b;
|
|
149
|
+
}
|
|
150
|
+
if (typeof a !== typeof b) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
// 處理日期
|
|
154
|
+
if (a instanceof Date && b instanceof Date) {
|
|
155
|
+
return a.getTime() === b.getTime();
|
|
156
|
+
}
|
|
157
|
+
// 處理正則表達式
|
|
158
|
+
if (a instanceof RegExp && b instanceof RegExp) {
|
|
159
|
+
return a.source === b.source && a.flags === b.flags;
|
|
160
|
+
}
|
|
161
|
+
// 處理陣列
|
|
162
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
163
|
+
if (a.length !== b.length) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
for (let i = 0; i < a.length; i++) {
|
|
167
|
+
if (!isEqual(a[i], b[i])) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
// 處理物件
|
|
174
|
+
if (typeof a === 'object' && typeof b === 'object') {
|
|
175
|
+
const keysA = Object.keys(a);
|
|
176
|
+
const keysB = Object.keys(b);
|
|
177
|
+
if (keysA.length !== keysB.length) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
for (const key of keysA) {
|
|
181
|
+
if (!keysB.includes(key)) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
if (!isEqual(a[key], b[key])) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 設定物件的深層屬性
|
|
194
|
+
* @param obj 目標物件
|
|
195
|
+
* @param path 屬性路徑(支援點記法和陣列索引)
|
|
196
|
+
* @param value 要設定的值
|
|
197
|
+
*/
|
|
198
|
+
export function set(obj, path, value) {
|
|
199
|
+
if (!path) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const keys = parsePath(path);
|
|
203
|
+
let current = obj;
|
|
204
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
205
|
+
const key = keys[i];
|
|
206
|
+
const nextKey = keys[i + 1];
|
|
207
|
+
if (!(key in current) || current[key] == null) {
|
|
208
|
+
// 如果下一個鍵是數字,建立陣列,否則建立物件
|
|
209
|
+
current[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
210
|
+
}
|
|
211
|
+
current = current[key];
|
|
212
|
+
}
|
|
213
|
+
if (keys.length > 0) {
|
|
214
|
+
current[keys[keys.length - 1]] = value;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* 取得物件的深層屬性
|
|
219
|
+
* @param obj 來源物件
|
|
220
|
+
* @param path 屬性路徑
|
|
221
|
+
* @param defaultValue 預設值
|
|
222
|
+
* @returns 屬性值或預設值
|
|
223
|
+
*/
|
|
224
|
+
export function get(obj, path, defaultValue) {
|
|
225
|
+
if (!path) {
|
|
226
|
+
return obj;
|
|
227
|
+
}
|
|
228
|
+
const keys = parsePath(path);
|
|
229
|
+
let current = obj;
|
|
230
|
+
for (const key of keys) {
|
|
231
|
+
if (current == null || !(key in current)) {
|
|
232
|
+
return defaultValue;
|
|
233
|
+
}
|
|
234
|
+
current = current[key];
|
|
235
|
+
}
|
|
236
|
+
return current;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 檢查物件是否有深層屬性
|
|
240
|
+
* @param obj 來源物件
|
|
241
|
+
* @param path 屬性路徑
|
|
242
|
+
* @returns 是否存在該屬性
|
|
243
|
+
*/
|
|
244
|
+
export function has(obj, path) {
|
|
245
|
+
if (!path) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
const keys = parsePath(path);
|
|
249
|
+
let current = obj;
|
|
250
|
+
for (const key of keys) {
|
|
251
|
+
if (current == null || !(key in current)) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
current = current[key];
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* 解析屬性路徑
|
|
260
|
+
* @param path 路徑字串
|
|
261
|
+
* @returns 路徑陣列
|
|
262
|
+
*/
|
|
263
|
+
function parsePath(path) {
|
|
264
|
+
return path
|
|
265
|
+
.replace(/\[(\d+)\]/g, '.$1') // 將 [0] 轉換為 .0
|
|
266
|
+
.split('.')
|
|
267
|
+
.filter(key => key !== '');
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* 映射物件的值
|
|
271
|
+
* @param obj 來源物件
|
|
272
|
+
* @param mapper 映射函式
|
|
273
|
+
* @returns 映射後的新物件
|
|
274
|
+
*/
|
|
275
|
+
export function mapValues(obj, mapper) {
|
|
276
|
+
const result = {};
|
|
277
|
+
for (const key in obj) {
|
|
278
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
279
|
+
result[key] = mapper(obj[key], key);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/shared/utils/object.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAI,GAAM,EAAE,OAAO,GAAG,IAAI,OAAO,EAAE;IAC1D,SAAS;IACT,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,SAAS;IACT,IAAI,OAAO,CAAC,GAAG,CAAC,GAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,GAAU,CAAC,CAAC;IACjC,CAAC;IAED,OAAO;IACP,IAAI,GAAG,YAAY,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAM,CAAC;IACtC,CAAC;IAED,UAAU;IACV,IAAI,GAAG,YAAY,MAAM,EAAE,CAAC;QAC1B,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAM,CAAC;IAChD,CAAC;IAED,OAAO;IACP,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,W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ExC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;YACnD,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 檢查路徑是否為絕對路徑
|
|
3
|
+
* @param path 待檢查的路徑
|
|
4
|
+
* @returns 是否為絕對路徑
|
|
5
|
+
*/
|
|
6
|
+
export declare function isAbsolute(path: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* 正規化路徑
|
|
9
|
+
* @param path 待正規化的路徑
|
|
10
|
+
* @returns 正規化後的路徑
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalize(path: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* 計算從一個路徑到另一個路徑的相對路徑
|
|
15
|
+
* @param from 起始路徑
|
|
16
|
+
* @param to 目標路徑
|
|
17
|
+
* @returns 相對路徑
|
|
18
|
+
*/
|
|
19
|
+
export declare function relative(from: string, to: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* 變更檔案的副檔名
|
|
22
|
+
* @param filePath 檔案路徑
|
|
23
|
+
* @param newExt 新的副檔名
|
|
24
|
+
* @returns 變更副檔名後的路徑
|
|
25
|
+
*/
|
|
26
|
+
export declare function changeExtension(filePath: string, newExt: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* 確保檔案有指定的副檔名
|
|
29
|
+
* @param filePath 檔案路徑
|
|
30
|
+
* @param ext 期望的副檔名
|
|
31
|
+
* @returns 確保有副檔名的路徑
|
|
32
|
+
*/
|
|
33
|
+
export declare function ensureExtension(filePath: string, ext: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* 取得檔名(不包含副檔名)
|
|
36
|
+
* @param filePath 檔案路徑
|
|
37
|
+
* @returns 不含副檔名的檔名
|
|
38
|
+
*/
|
|
39
|
+
export declare function getFileNameWithoutExt(filePath: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* 檢查一個路徑是否為另一個路徑的子路徑
|
|
42
|
+
* @param parent 父路徑
|
|
43
|
+
* @param child 子路徑
|
|
44
|
+
* @returns 是否為子路徑
|
|
45
|
+
*/
|
|
46
|
+
export declare function isSubPath(parent: string, child: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 將路徑轉換為 Unix 風格(使用正斜線)
|
|
49
|
+
* @param path 待轉換的路徑
|
|
50
|
+
* @returns Unix 風格的路徑
|
|
51
|
+
*/
|
|
52
|
+
export declare function toUnixPath(path: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* 將路徑轉換為 Windows 風格(使用反斜線)
|
|
55
|
+
* @param path 待轉換的路徑
|
|
56
|
+
* @returns Windows 風格的路徑
|
|
57
|
+
*/
|
|
58
|
+
export declare function toWindowsPath(path: string): string;
|
|
59
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/path.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAUhD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA2C9C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CA4BzD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAYxE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAarE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAuB9D;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAchE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlD"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 檢查路徑是否為絕對路徑
|
|
3
|
+
* @param path 待檢查的路徑
|
|
4
|
+
* @returns 是否為絕對路徑
|
|
5
|
+
*/
|
|
6
|
+
export function isAbsolute(path) {
|
|
7
|
+
if (!path) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
// Unix 絕對路徑以 / 開頭
|
|
11
|
+
if (path.startsWith('/')) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
// Windows 絕對路徑以磁碟機代號開頭,如 C:\
|
|
15
|
+
if (/^[A-Za-z]:[\/\\]/.test(path)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 正規化路徑
|
|
22
|
+
* @param path 待正規化的路徑
|
|
23
|
+
* @returns 正規化後的路徑
|
|
24
|
+
*/
|
|
25
|
+
export function normalize(path) {
|
|
26
|
+
if (!path) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
// 將所有反斜線替換為正斜線
|
|
30
|
+
let normalizedPath = path.replace(/\\/g, '/');
|
|
31
|
+
// 處理多個連續的斜線
|
|
32
|
+
normalizedPath = normalizedPath.replace(/\/+/g, '/');
|
|
33
|
+
// 分割路徑並處理 . 和 ..
|
|
34
|
+
const parts = normalizedPath.split('/');
|
|
35
|
+
const stack = [];
|
|
36
|
+
for (const part of parts) {
|
|
37
|
+
if (part === '' && stack.length === 0) {
|
|
38
|
+
// 保留根目錄的空字串
|
|
39
|
+
stack.push('');
|
|
40
|
+
}
|
|
41
|
+
else if (part === '..') {
|
|
42
|
+
// 回到上層目錄
|
|
43
|
+
if (stack.length > 0 && stack[stack.length - 1] !== '..') {
|
|
44
|
+
if (stack.length === 1 && stack[0] === '') {
|
|
45
|
+
// 不能回到根目錄之上
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
stack.pop();
|
|
49
|
+
}
|
|
50
|
+
else if (!isAbsolute(path)) {
|
|
51
|
+
// 相對路徑可以有 ..
|
|
52
|
+
stack.push('..');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (part !== '.' && part !== '') {
|
|
56
|
+
// 忽略 . 和空字串(除了根目錄)
|
|
57
|
+
stack.push(part);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const result = stack.join('/');
|
|
61
|
+
// 處理相對路徑的特殊情況
|
|
62
|
+
if (!isAbsolute(path) && !result) {
|
|
63
|
+
return '.';
|
|
64
|
+
}
|
|
65
|
+
return result || '/';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 計算從一個路徑到另一個路徑的相對路徑
|
|
69
|
+
* @param from 起始路徑
|
|
70
|
+
* @param to 目標路徑
|
|
71
|
+
* @returns 相對路徑
|
|
72
|
+
*/
|
|
73
|
+
export function relative(from, to) {
|
|
74
|
+
const normalizedFrom = normalize(from);
|
|
75
|
+
const normalizedTo = normalize(to);
|
|
76
|
+
if (normalizedFrom === normalizedTo) {
|
|
77
|
+
return '.';
|
|
78
|
+
}
|
|
79
|
+
const fromParts = normalizedFrom.split('/').filter(part => part !== '');
|
|
80
|
+
const toParts = normalizedTo.split('/').filter(part => part !== '');
|
|
81
|
+
// 找到共同的前綴
|
|
82
|
+
let commonLength = 0;
|
|
83
|
+
while (commonLength < fromParts.length &&
|
|
84
|
+
commonLength < toParts.length &&
|
|
85
|
+
fromParts[commonLength] === toParts[commonLength]) {
|
|
86
|
+
commonLength++;
|
|
87
|
+
}
|
|
88
|
+
// 計算需要回到上層的次數
|
|
89
|
+
const upCount = fromParts.length - commonLength;
|
|
90
|
+
// 建立相對路徑
|
|
91
|
+
const upParts = new Array(upCount).fill('..');
|
|
92
|
+
const downParts = toParts.slice(commonLength);
|
|
93
|
+
const result = [...upParts, ...downParts].join('/');
|
|
94
|
+
return result || '.';
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 變更檔案的副檔名
|
|
98
|
+
* @param filePath 檔案路徑
|
|
99
|
+
* @param newExt 新的副檔名
|
|
100
|
+
* @returns 變更副檔名後的路徑
|
|
101
|
+
*/
|
|
102
|
+
export function changeExtension(filePath, newExt) {
|
|
103
|
+
if (!filePath) {
|
|
104
|
+
return '';
|
|
105
|
+
}
|
|
106
|
+
const lastDotIndex = filePath.lastIndexOf('.');
|
|
107
|
+
const lastSlashIndex = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
|
|
108
|
+
// 如果點號在最後一個斜線之前,表示沒有副檔名
|
|
109
|
+
if (lastDotIndex <= lastSlashIndex) {
|
|
110
|
+
return filePath + newExt;
|
|
111
|
+
}
|
|
112
|
+
return filePath.slice(0, lastDotIndex) + newExt;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 確保檔案有指定的副檔名
|
|
116
|
+
* @param filePath 檔案路徑
|
|
117
|
+
* @param ext 期望的副檔名
|
|
118
|
+
* @returns 確保有副檔名的路徑
|
|
119
|
+
*/
|
|
120
|
+
export function ensureExtension(filePath, ext) {
|
|
121
|
+
if (!filePath) {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
const lastDotIndex = filePath.lastIndexOf('.');
|
|
125
|
+
const lastSlashIndex = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
|
|
126
|
+
// 如果沒有副檔名,添加指定的副檔名
|
|
127
|
+
if (lastDotIndex <= lastSlashIndex) {
|
|
128
|
+
return filePath + ext;
|
|
129
|
+
}
|
|
130
|
+
// 如果已經有副檔名,保持不變
|
|
131
|
+
return filePath;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 取得檔名(不包含副檔名)
|
|
135
|
+
* @param filePath 檔案路徑
|
|
136
|
+
* @returns 不含副檔名的檔名
|
|
137
|
+
*/
|
|
138
|
+
export function getFileNameWithoutExt(filePath) {
|
|
139
|
+
if (!filePath) {
|
|
140
|
+
return '';
|
|
141
|
+
}
|
|
142
|
+
// 取得檔名部分
|
|
143
|
+
const lastSlashIndex = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
|
|
144
|
+
const fileName = filePath.slice(lastSlashIndex + 1);
|
|
145
|
+
// 處理隱藏檔案(以點號開頭)
|
|
146
|
+
if (fileName.startsWith('.')) {
|
|
147
|
+
const dotIndex = fileName.indexOf('.', 1);
|
|
148
|
+
if (dotIndex === -1) {
|
|
149
|
+
return fileName; // 純隱藏檔案,如 .gitignore
|
|
150
|
+
}
|
|
151
|
+
return fileName.slice(0, dotIndex);
|
|
152
|
+
}
|
|
153
|
+
// 處理一般檔案
|
|
154
|
+
const lastDotIndex = fileName.lastIndexOf('.');
|
|
155
|
+
if (lastDotIndex === -1) {
|
|
156
|
+
return fileName;
|
|
157
|
+
}
|
|
158
|
+
return fileName.slice(0, lastDotIndex);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 檢查一個路徑是否為另一個路徑的子路徑
|
|
162
|
+
* @param parent 父路徑
|
|
163
|
+
* @param child 子路徑
|
|
164
|
+
* @returns 是否為子路徑
|
|
165
|
+
*/
|
|
166
|
+
export function isSubPath(parent, child) {
|
|
167
|
+
if (!parent || !child) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
const normalizedParent = normalize(parent);
|
|
171
|
+
const normalizedChild = normalize(child);
|
|
172
|
+
if (normalizedParent === normalizedChild) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
// 確保父路徑以斜線結尾,避免 /src 匹配 /source
|
|
176
|
+
const parentWithSlash = normalizedParent.endsWith('/') ? normalizedParent : normalizedParent + '/';
|
|
177
|
+
return normalizedChild.startsWith(parentWithSlash);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 將路徑轉換為 Unix 風格(使用正斜線)
|
|
181
|
+
* @param path 待轉換的路徑
|
|
182
|
+
* @returns Unix 風格的路徑
|
|
183
|
+
*/
|
|
184
|
+
export function toUnixPath(path) {
|
|
185
|
+
if (!path) {
|
|
186
|
+
return '';
|
|
187
|
+
}
|
|
188
|
+
return path.replace(/\\/g, '/');
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* 將路徑轉換為 Windows 風格(使用反斜線)
|
|
192
|
+
* @param path 待轉換的路徑
|
|
193
|
+
* @returns Windows 風格的路徑
|
|
194
|
+
*/
|
|
195
|
+
export function toWindowsPath(path) {
|
|
196
|
+
if (!path) {
|
|
197
|
+
return '';
|
|
198
|
+
}
|
|
199
|
+
return path.replace(/\//g, '\\');
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/shared/utils/path.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,CAAC,IAAI,EAAE,CAAC;QAAA,OAAO,KAAK,CAAC;IAAA,CAAC;IAE1B,kBAAkB;IAClB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAAA,OAAO,IAAI,CAAC;IAAA,CAAC;IAExC,6BAA6B;IAC7B,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAAA,OAAO,IAAI,CAAC;IAAA,CAAC;IAEjD,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IAEzC,IAAI,gBAAgB,KAAK,eAAe,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gCAAgC;IAChC,MAAM,eAAe,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,GAAG,GAAG,CAAC;IAEnG,OAAO,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,CAAC,IAAI,EAAE,CAAC;QAAA,OAAO,EAAE,CAAC;IAAA,CAAC;IACvB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,IAAI,CAAC,IAAI,EAAE,CAAC;QAAA,OAAO,EAAE,CAAC;IAAA,CAAC;IACvB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 將字串的首字母大寫
|
|
3
|
+
* @param str 待轉換的字串
|
|
4
|
+
* @returns 首字母大寫的字串
|
|
5
|
+
*/
|
|
6
|
+
export declare function capitalize(str: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* 將字串轉換為駝峰命名
|
|
9
|
+
* @param str 待轉換的字串
|
|
10
|
+
* @returns 駝峰命名格式的字串
|
|
11
|
+
*/
|
|
12
|
+
export declare function camelCase(str: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* 將字串轉換為蛇形命名
|
|
15
|
+
* @param str 待轉換的字串
|
|
16
|
+
* @returns 蛇形命名格式的字串
|
|
17
|
+
*/
|
|
18
|
+
export declare function snakeCase(str: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* 將字串轉換為短橫線命名
|
|
21
|
+
* @param str 待轉換的字串
|
|
22
|
+
* @returns 短橫線命名格式的字串
|
|
23
|
+
*/
|
|
24
|
+
export declare function kebabCase(str: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* 截斷字串並添加省略符
|
|
27
|
+
* @param str 待截斷的字串
|
|
28
|
+
* @param length 最大長度
|
|
29
|
+
* @param ellipsis 省略符,預設為 '...'
|
|
30
|
+
* @returns 截斷後的字串
|
|
31
|
+
*/
|
|
32
|
+
export declare function truncate(str: string, length: number, ellipsis?: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* 在字串開頭填充字元
|
|
35
|
+
* @param str 待填充的字串
|
|
36
|
+
* @param targetLength 目標長度
|
|
37
|
+
* @param padString 填充字元,預設為空格
|
|
38
|
+
* @returns 填充後的字串
|
|
39
|
+
*/
|
|
40
|
+
export declare function padStart(str: string, targetLength: number, padString?: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* 在字串結尾填充字元
|
|
43
|
+
* @param str 待填充的字串
|
|
44
|
+
* @param targetLength 目標長度
|
|
45
|
+
* @param padString 填充字元,預設為空格
|
|
46
|
+
* @returns 填充後的字串
|
|
47
|
+
*/
|
|
48
|
+
export declare function padEnd(str: string, targetLength: number, padString?: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* 移除字串的共同縮排
|
|
51
|
+
* @param str 待處理的字串
|
|
52
|
+
* @returns 移除縮排後的字串
|
|
53
|
+
*/
|
|
54
|
+
export declare function stripIndent(str: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* 跳脫正則表達式特殊字元
|
|
57
|
+
* @param str 待跳脫的字串
|
|
58
|
+
* @returns 跳脫後的字串
|
|
59
|
+
*/
|
|
60
|
+
export declare function escapeRegExp(str: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* 模板字串替換
|
|
63
|
+
* @param template 模板字串,使用 {{key}} 格式
|
|
64
|
+
* @param variables 變數物件
|
|
65
|
+
* @returns 替換後的字串
|
|
66
|
+
*/
|
|
67
|
+
export declare function template(template: string, variables: Record<string, any>): string;
|
|
68
|
+
/**
|
|
69
|
+
* 轉換為 URL 友好的字串
|
|
70
|
+
* @param str 待轉換的字串
|
|
71
|
+
* @returns URL 友好的字串
|
|
72
|
+
*/
|
|
73
|
+
export declare function slugify(str: string): string;
|
|
74
|
+
//# sourceMappingURL=string.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/string.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG9C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAa7C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU7C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAW7C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAc,GAAG,MAAM,CAMtF;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY,GAAG,MAAM,CAY3F;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY,GAAG,MAAM,CAYzF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA0B/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAajF;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU3C"}
|