Viewing version 0.4.27. Open the latest package page.

mojo

0.4.27

Dart files to support executing inside Mojo.

This package is discontinued upstream.

Download archive

Readme

Dart Mojo Applications

Mojo Application API

TODO(zra)

Application Packaging

All Dart sources for a Mojo application are collected in a specially formatted snapshot file, which is understood by Dart's content handler in the Mojo shell. This section describes what the various parts of that package are, and how they all make it to the right place.

GN Template

Dart Mojo applications are built with the GN template 'dart_pkg' defined in //mojo/public/dart/rules.gni. Here is an example:

dart_pkg("foo") {
  app_name_override = "dart_foo"
  app = "lib/main.dart"
  sources = [
    "lib/foo.dart",
    "pubspec.yaml",
  ]
  deps = [
    ":foo_mojom",
    "//third_party/dart-pkg",
  ]
}

mojom("foo_mojom") {
  sources = [
    "foo.mojom",
  ]
}

There are several parts. See the documentation in //mojo/public/dart/rules.gni for all the details.

pub packages

Dart Mojo applications may use packages from the pub package repository at pub.dartlang.org.

The "foo" example above has uses_pub set to true. Suppose the "foo" package's pubspec.yaml is as follows:

name: foo
version: 0.0.1
description: Foo
dependencies:
  crypto: ">=0.9.0 <0.10.0"

The script //mojo/public/tools/git/dart_pub_get.py should be run before build time, e.g. as a "runhooks" action during gclient sync. The script traverses a directory tree looking for pubspec.yaml files. On finding one, in the containing directory, it runs pub get. This creates a "packages/" directory in the source tree adjacent to the pubspec.yaml file containing the downloaded Dart packages. pub get also creates a pubspec.lock file that locks down pub packages to specific versions. This pubspec.lock file must be checked in in order to have hermetic builds.

During the build, The dart_pkg rule looks for a "packages/" directory, and ensures that its contents are available when running the application.

Generated bindings

The script //mojo/public/tools/bindings/generators/mojom_dart_generator.py and the templates under //mojo/public/tools/bindings/generators/dart_templates govern how .mojom files are compiled into Dart code.

Consider the foo.mojom file used by our example:

[DartPackage="foo"]
module foo;

struct Foo {
  int32 code;
  string? description;
};

This contents of this file are in the foo module. The Dart source generated for this file will end up under, e.g. //out/Debug/gen/dart- pkg/foo/lib/foo/network_error.mojom.dart, along with the other Dart sources generated for .mojom files with the "foo" DartPackage annotation in the foo module.

Resulting file

The dart_pkg rule has two results. The first result is a Dart snapshot file zipped up into a .mojo file in the build output directory---something like //out/Release/foo.mojo. This file is understood by the Dart content handler and is suitable for deployment. The second result is a directory layout of the "foo" app that can be served by a webserver. When the URL of lib/main.dart is given to the mojo_shell, the app will be run in the Dart content handler.

They layout for our "foo" example will be the following:

//lib/main.dart
//lib/foo.dart
//lib/foo/foo.mojom.dart
//packages/crypto/...  # Dart's crypto pub package.
//packages/mojo/...  # Mojo SDK Dart libraries.

Where //packages/mojo contains Dart's Mojo bindings, //packages/crypto contains the crypto pub package, and //lib/foo/ contains the bindings generated for foo.mojom.

Mojo's Dart content handler sets the package root for a Dart application to be the packages directory. Therefore, Dart sources in this application can use the following imports:

import 'package:crypto/crypto.dart';
import 'package:foo/foo/foo.mojom.dart';
import 'package:mojo/application.dart';
Changelog

0.4.27

MOJO_SDK: 9397aa588d55e96077c3859d4a136e4e6adf57ea

0.4.26

MOJO_SDK: 38c5dbd1426e105d42d6b070b8e4089c9db957eb

0.4.25

MOJO_SDK: ee5b33cba0face525d425d6bd8682e5de038ad73

0.4.24

MOJO_SDK: ff47297bfaed2660b106a67d6693343b0bc8356b

0.4.23

MOJO_SDK: ef5cd660ec6f1c50eaff62c81ea7662662d04e15

0.4.22

MOJO_SDK: f56fd59ec51e1ecdd52fb848ceff1b6b6fe7f7fa

0.4.21

MOJO_SDK: c200560ac45a79b61b8e8c0444af471789f5669f

0.4.20

MOJO_SDK: 705723c25a51b30a89b6431a6377b09e4069561e

0.4.19

MOJO_SDK: 7c72e53d105c346dd82cbdbeb12d9e3f0712093d

0.4.18

MOJO_SDK: 31c5037ab2c63649632c9f2d4227ebe6f22015a4

0.4.17

MOJO_SDK: 1484e831758d05c7af0f27c199d24e3bbdc6383f

0.4.16

MOJO_SDK: 1308cd12434c9536a28592ff09399a57ef7f4f77

0.4.15

MOJO_SDK: c9e15130499cc859050668ea6f78485001c96251

0.4.14

MOJO_SDK: b3aaccc8d9408bc645ee633e7030c605f333be95

0.4.13

MOJO_SDK: 2ae2bccb82f37947c69ab5d6e06c2d109690a394

0.4.12

MOJO_SDK: ebf435275996a69482ea342aa3ae881aecd6c90e

0.4.11

MOJO_SDK: 3f50c60f8af5bb485f248ceea2407a59f09caad5

0.4.10

0.4.9

0.4.8

0.4.7

0.4.6

0.4.5

0.4.4

0.4.3

0.4.2

0.4.1

0.3.2

0.3.1

0.3.0

0.2.1

0.2.0

0.1.0

0.0.25

0.0.23

0.0.22

0.0.18

0.0.17

0.0.16

0.0.15

0.0.14

0.0.13

0.0.12

0.0.11

0.0.10

0.0.8

  • Update version to match sky package. 0.0.7 was skipped.

0.0.6

  • Fix interface name capitalization bug in Dart bindings
  • Add support for interface control messages (queryVersion, requireVersion)

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'mojo:0.4.27'
pubspec.yaml
author: Chromium Authors <mojo-dev@googlegroups.com>
description: Dart files to support executing inside Mojo.
homepage: https://github.com/domokit/mojo
name: mojo
version: 0.4.27

Version history

VersionPublishedArchiveSHA-256
0.1.0Cached · Upstream SHA-256 matchedDownload8dda1c60…5e73e5
0.2.0Cached · Upstream SHA-256 matchedDownload40219174…5bde0f
0.2.1Cached · Upstream SHA-256 matchedDownload9aad9e1c…1b0284
0.3.0Cached · Upstream SHA-256 matchedDownload450bf765…366d02
0.3.1Cached · Upstream SHA-256 matchedDownload55e77256…83e414
0.3.2Cached · Upstream SHA-256 matchedDownload9c5db7f1…74e25e
0.4.1Cached · Upstream SHA-256 matchedDownload471d70e3…71dac4
0.4.2Cached · Upstream SHA-256 matchedDownloadb5e13302…e9fbbc
0.4.3Cached · Upstream SHA-256 matchedDownload22d8478d…5a9781
0.4.4Cached · Upstream SHA-256 matchedDownloadd8184f22…0094b3
0.4.5Cached · Upstream SHA-256 matchedDownload969bab9f…b51dc7
0.4.6Cached · Upstream SHA-256 matchedDownload6a79f4e5…783405
0.4.7Cached · Upstream SHA-256 matchedDownloadb19ea3c5…048e18
0.4.8Cached · Upstream SHA-256 matchedDownloade872b826…2ef028
0.4.9Cached · Upstream SHA-256 matchedDownloadbf0ece6c…66eebf
0.4.10Cached · Upstream SHA-256 matchedDownloada44e81da…0ed592
0.4.11Cached · Upstream SHA-256 matchedDownloadb4eb9ff5…06a8f8
0.4.12Cached · Upstream SHA-256 matchedDownloade387c9c1…6995a2
0.4.13Cached · Upstream SHA-256 matchedDownload1b0594e8…e34a03
0.4.14Cached · Upstream SHA-256 matchedDownload0c8f05d0…603e29
0.4.15Cached · Upstream SHA-256 matchedDownload10ecd28d…109c0c
0.4.16Cached · Upstream SHA-256 matchedDownload11096f16…ae8850
0.4.17Cached · Upstream SHA-256 matchedDownloade0209708…282337
0.4.18Cached · Upstream SHA-256 matchedDownload85c63150…3f4988
0.4.19Cached · Upstream SHA-256 matchedDownload819efac3…142200
0.4.20Cached · Upstream SHA-256 matchedDownload1968b510…6b1e82
0.4.21Cached · Upstream SHA-256 matchedDownload6e851cde…59ba04
0.4.22Cached · Upstream SHA-256 matchedDownloadeaa2de5e…c3bd5f
0.4.23Cached · Upstream SHA-256 matchedDownloadd06bc0f9…3aa6bd
0.4.24Cached · Upstream SHA-256 matchedDownload71301984…150a01
0.4.25Cached · Upstream SHA-256 matchedDownloadb8092d1d…282167
0.4.26Cached · Upstream SHA-256 matchedDownload8458edfd…b81ac2
0.4.27Cached · Upstream SHA-256 matchedDownloadfa997122…9d0a27
0.4.28Cached · Upstream SHA-256 matchedDownload55a4af48…71e85b

Dependencies

No direct dependencies declared.