Skip to content

Teardown Architecture ​

Welcome to the Cooling Engineering Bay: pop off the plastic cover to see how four platforms share one compressor core.

Air Conditioner uses a monorepo structure that separates framework-agnostic AC logic from UI adapters.

text
packages/
├── core/    # State, reducer, storage, notifications, and audio controller
├── react/   # React library (src/lib) and ac.yunyoujun.cn web app
├── vue/     # Vue Provider, composables, components, and demo entry
└── widget/  # Native Web Component

All three web targets (Vue, React library, and Web Component) share a single style.css (authored in packages/vue, synced to React and Widget and verified by tests). The main website (ac.yunyoujun.cn) renders the React library's AirConditioner (size="wide") with decorative stickers as children and loads the 3D mode on demand.

Core ​

@yunlefun-home/air-conditioner-core is the single source of truth, exporting:

  • AcState, AcMode, AcAction
  • defaultAcState
  • minTemperature, maxTemperature
  • acReducer(state, action)
  • createAirConditionerStore(options)

Core never touches the DOM at module import time, so it works seamlessly in React, Vue, Web Components, SSR, and tests.

Framework Adapters ​

React and Vue adapters stay intentionally thin:

  • Connect the core store to each framework's reactivity system.
  • Expose ergonomic components and hooks/composables.
  • Render UI and dispatch user input.

Reusable library components remain free of site routing, analytics, ads, or deployment config.

Web Component ​

@yunlefun-home/air-conditioner-widget uses native Custom Elements and Shadow DOM:

  • Custom element: air-conditioner-widget
  • Attributes: storage-key, mode, status, temperature, title, placement
  • Events: ac-change, ac-notify

It depends only on @yunlefun-home/air-conditioner-core, with zero React or Vue runtime.

Released under the MIT License · The only catch is no actual wind