diff --git a/README.md b/README.md index 155e078afa..9fa2d1b502 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,6 @@ If you want to file an issue for the Chrome DevTools Protocol, please open an is Use the [protocol viewer](https://chromedevtools.github.io/devtools-protocol/) for navigating the protocol. -TypeScript definitions for the protocol's types are available in ['types/protocol.d.ts'](https://github.com/ChromeDevTools/devtools-protocol/tree/master/types). Mappings from Commands and events to these types are available in either generated `DomainApi` style in [`types/protocol-proxy-api.d.ts`](https://github.com/ChromeDevTools/devtools-protocol/blob/master/types/protocol-proxy-api.d.ts) or in simple name-to-type-interface style in [`types/protocol-mapping.d.ts`](https://github.com/ChromeDevTools/devtools-protocol/blob/master/types/protocol-mapping.d.ts). +TypeScript definitions for the protocol's types are available in ['types/protocol.d.ts'](https://github.com/ChromeDevTools/devtools-protocol/tree/master/types). Mappings from Commands and events to these types are available in either generated `DomainApi` style in [`types/protocol-proxy-api.d.ts`](https://github.com/ChromeDevTools/devtools-protocol/blob/master/types/protocol-proxy-api.d.ts) or in simple name-to-type-interface style in [`types/protocol-mapping.d.ts`](https://github.com/ChromeDevTools/devtools-protocol/blob/master/types/protocol-mapping.d.ts). Definitions for the protocol JSON schema itself are available in [`types/protocol-schema.d.ts`](https://github.com/ChromeDevTools/devtools-protocol/blob/master/types/protocol-schema.d.ts). Also, this repo is published as the [`devtools-protocol`](https://www.npmjs.com/package/devtools-protocol) npm module. diff --git a/scripts/.gitignore b/scripts/.gitignore index 4707f5d1b9..3c3629e647 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1,2 +1 @@ -stubprotocolrepo node_modules diff --git a/scripts/protocol-dts-generator.ts b/scripts/protocol-dts-generator.ts index 16b7bf7c6b..0eb08f6e09 100644 --- a/scripts/protocol-dts-generator.ts +++ b/scripts/protocol-dts-generator.ts @@ -1,6 +1,6 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; -import type { IProtocol, Protocol as P } from './protocol-schema.d.ts'; +import type { IProtocol, ProtocolSchema as P } from '../types/protocol-schema.d.ts'; // TODO: @noj validate this via https://github.com/andischerer/typescript-json-typesafe against protocol-schema.d.ts diff --git a/scripts/update-n-publish-docs.sh b/scripts/update-n-publish-docs.sh deleted file mode 100755 index 12e0dd308e..0000000000 --- a/scripts/update-n-publish-docs.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# This script updates and publishes the protocol API documentation -# This script is intended to be run on a regular schedule, e.g. via cron. - -set -x - -# These locations are very machine specific. -# https://github.com/ChromeDevTools/debugger-protocol-viewer -viewer_repo_path="$HOME/code/pristine/debugger-protocol-viewer-pristine" -local_script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -cd "$viewer_repo_path" || exit -viewer_repo="origin master" - -git checkout master -git pull $viewer_repo - -# generate latest docs on updated protocol -npm i && npm run prep && npm run build; - -git commit --author="DevTools Bot <24444246+devtools-bot@users.noreply.github.com>" -am "bump protocol" -# git config user.name "devtools-bot" -# git config user.email "24444246+devtools-bot@users.noreply.github.com" - -# push protocol bump commit back to viewer repo -git pull $viewer_repo && git push $viewer_repo - -# publish to https://chromedevtools.github.io/devtools-protocol/ -npm run deploy diff --git a/scripts/protocol-schema.d.ts b/types/protocol-schema.d.ts similarity index 80% rename from scripts/protocol-schema.d.ts rename to types/protocol-schema.d.ts index 1acb96510c..5d64da452f 100644 --- a/scripts/protocol-schema.d.ts +++ b/types/protocol-schema.d.ts @@ -1,10 +1,17 @@ /** Definition for protocol.json types */ export interface IProtocol { - version: Protocol.Version - domains: Protocol.Domain[] + version: ProtocolSchema.Version + domains: ProtocolSchema.Domain[] } -export namespace Protocol { +export type ProtocolSchema = ProtocolSchema.Schema; + +export namespace ProtocolSchema { + export interface Schema { + version: Version + domains: Domain[] + } + export interface Version { major: string minor: string @@ -77,7 +84,7 @@ export namespace Protocol { $ref: string } - export interface PropertyBaseType { + export interface PropertyBaseType extends ExtraInformation { /** Name of param */ name: string /** Is the property optional ? */ @@ -86,14 +93,18 @@ export namespace Protocol { description?: string } - type DomainType = { + export type DomainType = { /** Name of property */ id: string /** Description of the type */ description?: string } & (StringType | ObjectType | ArrayType | PrimitiveType) & ExtraInformation; - type ProtocolType = StringType | ObjectType | ArrayType | PrimitiveType | RefType | AnyType; + export type ProtocolType = StringType | ObjectType | ArrayType | PrimitiveType | RefType | AnyType; - type PropertyType = PropertyBaseType & ProtocolType; + export type PropertyType = PropertyBaseType & ProtocolType; } + +export import Protocol = ProtocolSchema; + +