compiler.py 2.0 KB

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