compiler.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. """Compiler variables."""
  2. from enum import Enum
  3. from types import SimpleNamespace
  4. # The prefix used to create setters for state vars.
  5. SETTER_PREFIX = "set_"
  6. class Ext(SimpleNamespace):
  7. """Extension used in Reflex."""
  8. # The extension for JS files.
  9. JS = ".js"
  10. # The extension for python files.
  11. PY = ".py"
  12. # The extension for css files.
  13. CSS = ".css"
  14. # The extension for zip files.
  15. ZIP = ".zip"
  16. class CompileVars(SimpleNamespace):
  17. """The variables used during compilation."""
  18. # The expected variable name where the rx.App is stored.
  19. APP = "app"
  20. # The expected variable name where the API object is stored for deployment.
  21. API = "api"
  22. # The name of the router variable.
  23. ROUTER = "router"
  24. # The name of the socket variable.
  25. SOCKET = "socket"
  26. # The name of the variable to hold API results.
  27. RESULT = "result"
  28. # The name of the final variable.
  29. FINAL = "final"
  30. # The name of the process variable.
  31. PROCESSING = "processing"
  32. # The name of the state variable.
  33. STATE = "state"
  34. # The name of the events variable.
  35. EVENTS = "events"
  36. # The name of the initial hydrate event.
  37. HYDRATE = "hydrate"
  38. # The name of the is_hydrated variable.
  39. IS_HYDRATED = "is_hydrated"
  40. class PageNames(SimpleNamespace):
  41. """The name of basic pages deployed in NextJS."""
  42. # The name of the index page.
  43. INDEX_ROUTE = "index"
  44. # The name of the app root page.
  45. APP_ROOT = "_app"
  46. # The root stylesheet filename.
  47. STYLESHEET_ROOT = "styles"
  48. # The name of the document root page.
  49. DOCUMENT_ROOT = "_document"
  50. # The name of the theme page.
  51. THEME = "theme"
  52. class ComponentName(Enum):
  53. """Component names."""
  54. BACKEND = "Backend"
  55. FRONTEND = "Frontend"
  56. def zip(self):
  57. """Give the zip filename for the component.
  58. Returns:
  59. The lower-case filename with zip extension.
  60. """
  61. return self.value.lower() + Ext.ZIP