NUCLO / 12

भाषा

Nuclo v0.3.39 · zero dependencies

Nuclo से बनाइए
explicit
interfaces।

छोटा सा, type-safe DOM framework। State बस एक plain variable है, जिसे आप सीधे बदल सकते हैं, और DOM तभी बदलता है जब आप कहें। न proxy, न signals, न virtual DOM।

$npm create nuclo@latest
0
Dependencies
175
Typed HTML और SVG builders
~18.9KB
Core runtime, gzipped
01/09 · update()
पहले रंगिए, फिर patch कीजिए
stateplain array · tap or dragupdate()domreal nodes
0 mutations · 0 update() · 0 patched
01/09 · update()
पहले रंगिए, फिर patch कीजिए

एक साफ़, explicit cycle।

State पर निर्भर values, बिना dependency graph या scheduler के। वे कब चलें, ये आप तय करते हैं: data से screen तक एक predictable रास्ता।

  1. 01बदलें

    अपना data बदलिए

    State बस plain JavaScript है: variables, arrays, objects। जैसे चाहें, जितनी बार चाहें बदलिए।

    todos.push(newTodo) user.name = 'Ada'
  2. 02लागू करें

    update() call कीजिए

    एक global function आपके changes apply करता है। कई changes करके सबको एक साथ apply कीजिए। जब तक आप न कहें, कुछ render नहीं होता।

    update()
  3. 03Patch करें

    Nuclo DOM को sync करता है

    हर dynamic expression दोबारा चलता है, और Nuclo DOM में सिर्फ़ बदली हुई values लिखता है। न tree diff, न re-render।

    // 2 nodes patch हुए, // बाकी सब जैसा था वैसा
State बदलने से कुछ नहीं होता। update() call कीजिए, और Nuclo ठीक वही करेगा जो आपने कहा। न कम, न ज़्यादा।
  1. Implicit से बेहतर है explicit

    कोई proxy पर्दे के पीछे आपकी हर हरकत track नहीं करती। आप state बदलते हैं, फिर update() call करते हैं। Cause और effect साफ़ दिखते हैं, और behavior predictable रहता है।

  2. जितने चाहें changes, update बस एक बार

    दस changes कीजिए, फिर update() एक बार चलाइए। DOM सिर्फ़ final state देखता है, इसलिए बेकार के re-renders नहीं होते।

  3. Components नहीं, बस functions

    Plain JavaScript functions से बनाइए। Nuclo को classes, decorators या कोई special syntax नहीं चाहिए। हर function एक DOM node return करता है, और ज़रूरत पड़ने पर ही onMount और onDestroy को आम modifiers की तरह जोड़ दीजिए।

सब कुछ साफ़-साफ़।

न कोई magic, न surprises। हर update सोच-समझकर होता है।

  • 01Explicit

    Update cycle आपके हाथ में

    जितने चाहें changes कीजिए, फिर update() एक बार call कीजिए। न subscriptions, न schedulers, और tree diff का कोई surprise भी नहीं। DOM उसी वक़्त sync होता है जब आप तय करते हैं।

  • 02Lightweight

    Zero dependencies

    Core runtime gzip के बाद करीब 18.9 KB का है। न compiler चाहिए, न build plugin। बस एक import और आप शुरू।

  • 03Typed

    TypeScript-first

    175 fully typed HTML और SVG builders, हर attribute, style property और event के लिए autocomplete के साथ।

  • 04Precise

    DOM में सिर्फ़ वही बदलता है जो बदला

    update() पर हर dynamic expression दोबारा evaluate होता है, और DOM को सिर्फ़ वही values छूती हैं जो सच में बदली हैं।

जहाँ speed मायने रखती है, वहाँ तेज़।

ये js-framework-benchmark के independent results हैं: हज़ारों rows को create, update, swap और remove करना।

js-framework-benchmark · keyedजितना कम, उतना बेहतर
  1. Nuclo0.2.24
    1.12
  2. Solid1.9.3
    1.13
  3. Svelte5.42.1
    1.17
  4. Vue3.5.39
    1.31
  5. Riot10.1.2
    1.54
  6. React19.2.0
    1.58
  7. Angular22.0.0
    1.58
  8. Stencil4.23.0
    1.81
  9. Ember7.3.0-alpha.5
    2.06
  10. Knockout3.5.1
    2.26
  11. Qwik1.11.0
    3.29
Score यानी सबसे तेज़ implementation की तुलना में कितना धीमा (duration slowdown)। ये सभी keyed benchmarks का weighted geometric mean है।Source: js-framework-benchmark

तैयार हैं? शुरू करते हैं।

Nuclo install कीजिए, एक बार import कीजिए और ऐसा UI बनाइए जो आपके कहने पर ही update हो। पूरा API एक दोपहर में सीखा जा सकता है।

$npm create nuclo@latest