chromium/mojo/public/tools/bindings/generators/js_templates/lite/mojom.m.js.tmpl

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

{% if not for_bindings_internals -%}
import {mojo} from '{{bindings_library_path}}';
{%- endif %}

{% for path, kinds in js_module_imports.items()|sort -%}
import {
{%- for kind in kinds|sort %}
{%-   for item in kind|imports_for_kind %}
  {{item.name}} as {{item.alias}}
{%-     if not loop.last -%},{% endif -%}
{%-   endfor %}
{%- if not loop.last -%},{% endif -%}
{%- endfor %}
} from '{{path}}';

{% endfor -%}

{#--- Constants #}
{%- for constant in module.constants %}
/**
 * @const { {{constant.kind|type_in_js_module_with_nullability}} }
 */
export const {{constant.name}} = {{constant|constant_value_in_js_module}};

{% endfor -%}

{#--- Enums #}
{%- from "lite/enum_definition_for_module.tmpl" import enum_def with context %}
{%- for enum in enums %}
{{enum_def(enum)}}
{%  endfor -%}

{#--- Interfaces #}
{%- for interface in interfaces %}
{%   include "lite/interface_definition_for_module.tmpl" %}
{%- endfor %}

{#--- Struct and Union forward declarations #}
{%  for struct in structs %}
/**
 * @const { {$:!mojo.internal.MojomType}}
 */
export const {{struct.name}}Spec =
    { $: /** @type {!mojo.internal.MojomType} */ ({}) };
{% endfor %}
{%- for union in unions %}
/**
 * @const { {$:!mojo.internal.MojomType} }
 */
export const {{union.name}}Spec =
    { $: /** @type {!mojo.internal.MojomType} */ ({}) };
{% endfor %}

{#--- Struct definitions #}
{%  for struct in structs %}
{%-   include "lite/struct_definition_for_module.tmpl" %}
{% endfor -%}

{#--- Union definitions #}
{%  for union in unions %}
{%-   include "lite/union_definition_for_module.tmpl" %}
{% endfor %}