image-layout.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Image layout contract shared by the packer and the worker host: the virtual
  3. * root, where the composed config and the manifest sit inside the image, and
  4. * the working directories every image carries empty. One definition, two
  5. * consumers — the packer writes this layout, the worker host mounts it.
  6. */
  7. /** Default virtual root; the runtime mounts the image here unless told otherwise. */
  8. export const DEFAULT_ROOT = '/dsh'
  9. /**
  10. * Leaf name of the packed base image: one gzip member holding the ustar archive.
  11. * The app build writes it beside the page and the page's boot fetches it from
  12. * there, so the extension is part of what a deployment serves.
  13. */
  14. export const IMAGE_FILE_NAME = 'vfs-image.tar.gz'
  15. /** Image path the composed profile is written to; the runtime's Loader reads it. */
  16. export const IMAGE_CONFIG_PATH = 'config/cordis.yml'
  17. /** Image path of the manifest the runtime reads before it wraps a single module. */
  18. export const IMAGE_MANIFEST_PATH = 'config/vfs-manifest.json'
  19. /** Home directory under the root; the process shim's `DSH_HOME`/`HOME` default. */
  20. export const IMAGE_HOME_DIRECTORY = 'home'
  21. /** Working directories the host tree expects to exist, empty. */
  22. export const IMAGE_EMPTY_DIRECTORIES: readonly string[] = ['home/', 'workspace/', 'tmp/']
  23. /**
  24. * Top-level directories an overlay archive may populate. Runtime code,
  25. * configuration, and the lowering manifest remain owned by the base image.
  26. */
  27. export const IMAGE_OVERLAY_DIRECTORIES: readonly string[] = ['home', 'workspace']
  28. /**
  29. * Identity of the lowered code shape, recorded in the image manifest by the
  30. * packer and required by the worker host: an image lowered by an older transform
  31. * would otherwise run against newer wrapper semantics. Bump on any change to
  32. * emitted code or to {@link WRAPPER_PARAMS}.
  33. */
  34. export const LOWERING_VERSION = 'dsh-worker-transform/1'
  35. /**
  36. * Free variables a lowered body expects from its wrapper, in order.
  37. *
  38. * Part of the image layout rather than of the transform, because the loader
  39. * wraps bodies it never parses: the packer emits against these names and the
  40. * worker binds them, with no compiler in the worker bundle to agree with.
  41. */
  42. export const WRAPPER_PARAMS = [
  43. 'exports', 'require', 'module', '__filename', '__dirname', '__dsh$meta', '__als',
  44. ] as const