Radu Matei
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Distributing Wasm components using OCI registries ## Wasm components > See the [_Component Model Explainer_](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md) from the specification repository. > For a deep dive into the motivation and progress for the component model, see [Luke Wagner's WasmDay keynote: _The Path to Components_](https://youtu.be/phodPLY8zNE). > Read [Dan Gohman's _What is a Wasm component_](https://blog.sunfishcode.online/what-is-a-wasm-component/) and Joel Dice's [_The Wasm component model_](https://www.fermyon.com/blog/webassembly-component-model) articles. The core [WebAssembly specification](https://webassembly.github.io/spec/core) defines a portable binary format and compilation target for representing executable code. A core Wasm module can import functions, linear memories, or global variables from the host, or it can export them to the underlying execution environment. However, the Wasm MVP specification does not address how core modules can be composed, how higher-level types could be shared across module or host boundaries, nor does it define the surrounding environment in which such a _unit of code_ needs to be executed. This is what the new [Wasm component model specification](https://github.com/WebAssembly/component-model) is addressing by introducing the new concept of [_components_](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#component-definitions). A Wasm component is a self-contained object. Its dependencies are objects (such as nested components, core modules, or instances) that are described within the root component itself, and can be composed at development time _or_ at deployment time to create new components. An example of a component (in its textual format) that takes a string, then logs it: ```wat (component (import "wasi:logging" (instance $logging ...logging interface) (import "libc" (core module $libc ...libc interface)) (core module $main ...all the compiled wasm code for our component ) ...component-model definitions to link all these up ) ``` The example above showcases how components can contain reusable language runtime modules (in this example `libc`, but language runtimes for languages such as JavaScript or Python could be reused in similar ways) or implementations for standard interfaces (such as `wasi:logging`), as well as non-reusable modules (`main`). (At deployment time, all dependencies should be resolved and all imports should either be present in the component definition itself or satisfied by the host execution context.) > Read about [the relationship between WASI and the component model](https://github.com/WebAssembly/component-model/blob/main/design/high-level/FAQ.md). ## Deploying Wasm components Depending on the intended usage of a given component, we could distinguish between two types of registries, together with two types of artifacts for components: - development registries - similar to NPM or Crates.io, the components pulled from such a registry are primarily used in the process of developing new components. The components in this type of registry are _unlocked packages_, their dependencies being semantic version (semver) queries for other packages that can be found in the registry. - deployment registries - similar to how OCI registries are used today in the process of deploying software. The components in this type of registry are _locked packages_ (or [bundled components](https://github.com/bytecodealliance/SIG-Registries/blob/main/glossary.md#bundled-component-and-bundling)), their dependencies being exact versions and content hashes of packages from the registry. Regardless of the registry type, we can distinguish five main artifact types: components, interfaces, [worlds](https://blog.sunfishcode.online/what-is-a-world), core modules, and general-purpose binary objects that a component needs at runtime. For this document, we are only interested in using OCI registries as _deployment registries_, with the _primary_ artifact type distributed being a _bundled or locked component_. Finally, there are two ways in which such a component could be represented at distribution time: - compact - the component is a single `.wasm` file, which has the constituent nested components, core modules, and data segments as sections in the Wasm binary, which is then distributed as a single blob - expanded - the root component references its nested components, core modules, and data segments by their content digest. They are all distributed as individual blobs, and hosts are expected to reconstruct them at runtime. (This maximizes deduplication of artifacts and optimizes distribution.) ## Distributing Wasm packages using OCI artifacts The [OCI Artifacts](https://github.com/opencontainers/artifacts) specification describes how to define new artifact types that can be distributed by reusing the existing OCI registry infrastructure. The next section proposes the media types used for distributing an _expanded component_ - a root component whose nested components, core modules, and data segments are resolved and referenced by their content digest. > See [this section](https://github.com/opencontainers/artifacts/blob/main/artifact-authors.md#defining-a-unique-artifact-type) in the Artifacts specification for more information on choosing unique media types. ### Distributing Wasm components - media type: `application/vnd.w3c.wasm.component.v1+json` - plus _optional_ JSON file containing _metadata_ (that does not impact runtime behavior) associated with the component (authors, license, imports, exports) - layers: - one root component: `application/vnd.w3c.wasm.component.v1+wasm` - this is always the first layer in a component and contains the root component for the package that is fully resolved and its dependencies are all resolved and present in the subsequent layers - any number of: - nested components: `application/vnd.w3c.wasm.component.v1+wasm` - core modules: `application/vnd.w3c.wasm.module.v1+wasm` - data blobs: `application/vnd.w3c.wasm.data.v1+data` - data segment If no additional layers are present, the root component should be a well-formed component with no external dependencies of references. Example: - top-level manifest for a reference pointing to a component: ```json { "schemaVersion": 2, "config": { "mediaType": "application/vnd.w3c.wasm.component.v1+json", "digest": "sha256:e89acb10dee2fec22203f25b734510940419d8f3e4a292ed3d4d104e614551f4", "size": 331 }, "layers": [ { "mediaType": "application/vnd.w3c.wasm.component.v1+wasm", "digest": "sha256:db7ca53ddfc81dc58032553ce90859e2ed2fe458febc84536a894585bfb59b1f", "size": 2087464, "annotations": { "org.opencontainers.image.title": "optional-annotation-for-my-root-component" } }, { "mediaType": "application/vnd.w3c.wasm.module.v1+wasm", "digest": "sha256:8c69a84ec5adec97e47d4250410a7689046762aaa8e89f82ddbb4a89acb7388e", "size": 96 }, { "mediaType": "application/vnd.w3c.wasm.module.v1+wasm", "digest": "sha256:2e5ac59e65b6c3dfe0b322c80215cd6f18c28818053ad876ec4760dfe3527dc5", "size": 404 } ] } ``` For the example above, the root component is now referencing the core modules by digest: ```wat (component (import "wasi:logging" (instance $logging ...logging interface)) (import "libc@sha256:8c69a84ec5adec" (core module $Libc ...libc interface)) (import "main@sha256:2e5ac59e65b6c3" (core module $Main ...main interface)) ...component-model definitions to link all these up ) ``` ### Distributing core modules - media type: `application/vnd.w3c.wasm.module.v1+json` - _optional_ JSON file containing metadata associated with the component (authors, license, layout configuration, environment variables, files) - layers: - one core module: `application/vnd.w3c.wasm.module.v1+wasm` - any number of data blobs: `application/vnd.w3c.wasm.data.v1+data` - if present, data blobs are configured according to the `files` section in the configuration object. Layers that are not present in the `files` section from the configuration object are ignored. Example: - top-level manifest for a core module: ```json { "schemaVersion": 2, "config": { "mediaType": "application/vnd.w3c.wasm.module.v1+json", "digest": "sha256:f90acb10dee2fec22203f25b734510940419d8f3e4a292ed3apfio04e614551f4", "size": 331 }, "layers": [ { "mediaType": "application/vnd.w3c.wasm.module.v1+wasm", "digest": "sha256:bn8gjca53ddfc81dc58032553ce90859e2ed2fe458febc84536a894585bfbsdfj", "size": 2087464 }, { "mediaType": "application/vnd.w3c.wasm.data.v1+data", "digest": "sha256:8c69a84ec5adec97e47d4250410a7689046762aaa8e89f82ddbb4a89acb7388e", "size": 46123 }, { "mediaType": "application/vnd.w3c.wasm.data.v1+data", "digest": "sha256:2e5ac59e65b6c3dfe0b322c80215cd6f18c28818053ad876ec4760dfe3527dc5", "size": 9912 } ] } ``` ## Additional media types that are reserved by this proposal, but not fully specified: ### Interfaces - media type: `application/vnd.w3c.wasm.interface.v1+json` - plus _optional_ JSON configuration file - layers: `application/vnd.w3c.wasm.interface.v1+wasm` OR `application/vnd.w3c.wasm.interface.v1+wit` ### Worlds - media type: `application.vnd.w3c.wasm.world.v1+json` - plus _optional_ JSON configuration file - layers: `application/vnd.w3c.wasm.world.v1+wasm` OR `application/vnd.w3c.wasm.interface.v1+world` ### Data - media type: `application/vnd.w3c.wasm.data.v1+json` - plus JSON configuration file - layers: `application/vnd.w3c.wasm.data.v1+data` TODO: define the configuration files and instances where they are required vs. optional

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully