code: def SvelteComponent(name, path):
      """Display svelte components in iPython.
  
      Args:
        name: name of svelte component (must match component filename when built)
        path: path to compile svelte .js file or source svelte .html file.
          (If html file, we try to call svelte and build the file.)
  
      Returns:
        A function mapping data to a rendered svelte component in ipython.
      """
      if path[-3:] == ".js":
          js_path = path
      elif path[-5:] == ".html":
          print("Trying to build svelte component from html...")
          js_path = build_svelte(path)
      js_content = read(js_path, mode="r")
  
      def inner(data):
          id_str = js_id(name)
          html = (
              _template.replace("$js", js_content)
              .replace("$name", name)
              .replace("$data", json.dumps(data))
              .replace("$id", id_str)
          )
          _display_html(html)
  
      return inner
  
file_path: lucid/lucid/scratch/web/svelte.py
imports: import random
  import json
  import tempfile
  import subprocess
  import os.path
  import uuid
  from IPython.core.magic import register_cell_magic
  from lucid.misc.io.showing import _display_html
  from lucid.misc.io.reading import read
label_desc: Use image node_id 3 for calling a global function with example usage: SvelteComponent(name, path) and returns: inner