| // Copyright 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| {# Changes to the externs must be reflected in the generated API too. #} |
| |
| /** |
| * Experimental bindings for the {{domain.domain}} DevTools Domain. Note these |
| * are subject to change without warning. Use at your own risk. |
| * @param {!chromium.DevTools.Connection} connection The DevTools connection. |
| * @constructor |
| */ |
| chromium.DevTools.Experimental{{domain.domain}} = function(connection) {}; |
| |
| /** |
| * Removes an event listener. |
| * |
| * @param {number} id The id of the event listener to remove. |
| * @return {boolean} Whether the event listener was actually removed. |
| */ |
| chromium.DevTools.Experimental{{domain.domain}}.prototype.removeEventListener = function(id) {}; |
| |
| /** |
| * Bindings for the {{domain.domain}} DevTools Domain. |
| * @param {!chromium.DevTools.Connection} connection The DevTools connection. |
| * @constructor |
| */ |
| chromium.DevTools.{{domain.domain}} = function(connection) {}; |
| |
| /** @type {!chromium.DevTools.Experimental{{domain.domain}}} */ |
| chromium.DevTools.{{domain.domain}}.prototype.experimental; |
| |
| /** |
| * Removes an event listener. |
| * |
| * @param {number} id The id of the event listener to remove. |
| * @return {boolean} Whether the event listener was actually removed. |
| */ |
| chromium.DevTools.{{domain.domain}}.prototype.removeEventListener = function(id) {}; |
| |
| {# Generate enums. #} |
| {% for type in domain.types %} |
| {% if not "enum" in type %}{% continue %}{% endif %} |
| /** |
| {% if type.description %} |
| * {{type.description.replace('\n', '\n * ')}} |
| * |
| {% endif %} |
| * @enum {string} |
| */ |
| chromium.DevTools.{{domain.domain}}.{{type.id}} = { |
| {% for literal in type.enum %} |
| {{ literal | sanitize_literal | dash_to_camelcase | camelcase_to_hacker_style | upper }}: "{{ literal }}"{{',' if not loop.last}} |
| {% endfor %} |
| }; |
| |
| {% endfor %} |
| |
| {# Generate types. #} |
| {% for type in domain.types %} |
| {% if not (type.type == "object") or not ("properties" in type) %}{% continue %}{% endif %} |
| /** |
| {% if type.description %} |
| * {{type.description.replace('\n', '\n * ')}} |
| * |
| {% endif %} |
| {% for property in type.properties %} |
| {% if property.description %} |
| * {{property.name}}: {{property.description.replace('\n', '\n * ')}} |
| {% endif %} |
| {% endfor %} |
| * |
| {% if type.properties %} |
| * @typedef {{ '{{' }} |
| {% for property in type.properties %} |
| {% if property.optional %} |
| * {{property.name}}: ({{ resolve_type(property).js_type }}|undefined){{',' if not loop.last}} |
| {% else %} |
| * {{property.name}}: {{ resolve_type(property).js_type }}{{',' if not loop.last}} |
| {% endif %} |
| {% endfor %} |
| * {{ '}}' }} |
| {% else %} |
| * @typedef {undefined} |
| {% endif %} |
| */ |
| chromium.DevTools.{{domain.domain}}.{{type.id}}; |
| |
| {% endfor %} |
| |
| {# Generate all commands for Experimental Domain. #} |
| {% for command in domain.commands %} |
| {% set method_name = command.name | sanitize_literal %} |
| {% set title_case_method_name = method_name | to_title_case %} |
| {% set result_type = '{!Promise<chromium.DevTools.' + domain.domain + '.' + title_case_method_name + 'Result>}' %} |
| |
| /** |
| {% if command.description %} |
| * {{ command.description.replace('\n', '\n * ') }} |
| * |
| {% endif %} |
| {% if command.parameters|length > 0 %} |
| {% if command.parameters_required %} |
| * @param {{ '{chromium.DevTools.' + domain.domain + '.' + title_case_method_name + 'Params}' }} params |
| {% else %} |
| * @param {{ '{chromium.DevTools.' + domain.domain + '.' + title_case_method_name + 'Params=}' }} opt_params |
| {% endif %} |
| {% endif %} |
| * @return {{result_type}} |
| */ |
| {% if command.parameters|length > 0 %} |
| {% if command.parameters_required %} |
| chromium.DevTools.Experimental{{domain.domain}}.prototype.{{method_name}} = function(params) {}; |
| {% else %} |
| chromium.DevTools.Experimental{{domain.domain}}.prototype.{{method_name}} = function(opt_params) {}; |
| {% endif %} |
| {% else %} |
| chromium.DevTools.Experimental{{domain.domain}}.prototype.{{method_name}} = function() {}; |
| {% endif %} |
| {% endfor %} |
| |
| {# Generate all events Experimental Domain. #} |
| {% for event in domain.events %} |
| {% if event.parameters|length > 0 %} |
| {% set param_type = '{!function(!chromium.DevTools.' + domain.domain + '.' + event.name | to_title_case + 'Params)}' %} |
| {% else %} |
| {% set param_type = '{!function()}' %} |
| {% endif %} |
| |
| /** |
| {% if event.description %} |
| * {{ event.description.replace('\n', '\n * ') }} |
| * |
| {% endif %} |
| * @param {{param_type}} listener |
| * @return {number} The id of this event listener. |
| */ |
| chromium.DevTools.Experimental{{domain.domain}}.prototype.on{{event.name | to_title_case}} = function(listener) {}; |
| {% endfor %} |
| |
| |
| {# Generate non-Experimental commands. #} |
| {% for command in domain.commands %} |
| {% if command.Experimental %}{% continue %}{% endif %} |
| {% set method_name = command.name | sanitize_literal %} |
| {% set title_case_method_name = method_name | to_title_case %} |
| {% set result_type = '{!Promise<chromium.DevTools.' + domain.domain + '.' + title_case_method_name + 'Result>}' %} |
| |
| /** |
| {% if command.description %} |
| * {{ command.description.replace('\n', '\n * ') }} |
| * |
| {% endif %} |
| {% if command.parameters|length > 0 %} |
| {% if command.parameters_required %} |
| * @param {{ '{chromium.DevTools.' + domain.domain + '.' + title_case_method_name + 'Params}' }} params |
| {% else %} |
| * @param {{ '{chromium.DevTools.' + domain.domain + '.' + title_case_method_name + 'Params=}' }} opt_params |
| {% endif %} |
| {% endif %} |
| * @return {{result_type}} |
| */ |
| {% if command.parameters|length > 0 %} |
| {% if command.parameters_required %} |
| chromium.DevTools.{{domain.domain}}.prototype.{{method_name}} = function(params) {}; |
| {% else %} |
| chromium.DevTools.{{domain.domain}}.prototype.{{method_name}} = function(opt_params) {}; |
| {% endif %} |
| {% else %} |
| chromium.DevTools.{{domain.domain}}.prototype.{{method_name}} = function() {}; |
| {% endif %} |
| {% endfor %} |
| |
| {# Generate non-Experimental events. #} |
| {% for event in domain.events %} |
| {% if event.Experimental %}{% continue %}{% endif %} |
| {% if event.parameters|length > 0 %} |
| {% set param_type = '{!function(!chromium.DevTools.' + domain.domain + '.' + event.name | to_title_case + 'Params)}' %} |
| {% else %} |
| {% set param_type = '{!function()}' %} |
| {% endif %} |
| |
| /** |
| {% if event.description %} |
| * {{ event.description.replace('\n', '\n * ') }} |
| * |
| {% endif %} |
| * @param {{param_type}} listener |
| * @return {number} The id of this event listener. |
| */ |
| chromium.DevTools.{{domain.domain}}.prototype.on{{event.name | to_title_case}} = function(listener) {}; |
| {% endfor %} |