How souhait0614/submarin-converter works
Project Type and Purpose
• This is a TypeScript‑based monorepo library (“submarin-converter”) that provides a core text‐conversion engine plus a variety of plug‑in modules (cjp, genhera, nomlish).
• It’s not a web app or microservice but a pluggable library targeting multiple JavaScript runtimes (Deno, Node, Bun).
File Structure Analysis
• Top‑level config: deno.json, deno.lock, package.json (npm publish), CI workflows (.github/workflows).
• /packages/core: The Converter class, plugin interface types, logger, constants.
• /packages/plugin‑…: Each plugin implements the Plugin interface, supplies conversion functions.
• /runtime‑tests: Three subdirs (bun, deno, node) verifying cross‑runtime compatibility using Vitest and native test runners.
• /scripts: Helpers to build/test and synchronize package versions across the monorepo.
Key Architectural Patterns
• Plugin architecture: Core defines a Plugin interface, dynamic loading / registration of plugins via a map of names to modules.
• Pipeline pattern: Converter.convert() runs a sequence of conversion functions chained in order.
• Polyglot packaging: Each package includes its own deno.json for Deno support and publishes via npm (package.json in root).
Main Components & Interactions
a. Converter Core
• Exposes Converter class and Plugin<T> interface.
• Maintains a registry of named plugins.
• Orchestrates conversion pipeline: input text → plugin1 → plugin2 → … → output text & detailed results.
b. Plugin Modules
• plugin-cjp, plugin-genhera, plugin-nomlish each implement Plugin and export convertFunctions (functions(text, option) ⇒ text).
• May include internal constants and helper modules (e.g., genhera/dict).
c. Runtime Adapters / Tests
• For each runtime (Deno, Node, Bun) there is a test harness invoking the core + selected plugins to validate behavior.
d. Build & Release
• CI pipelines run tests, build artifacts, and publish to npm/JSR.
• Scripts to keep version alignment and pre-test builds.
• PluginManager (register, resolve by name)
• ConversionPipeline (sequential execution of convertFunctions)