diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..a0f24c9 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,4 @@ +{ + "singleQuote": true, + "bracketSpacing": false +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a10d9b2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +// Copyright (c) 2019 The Polymer Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..1aad43a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,352 @@ +{ + "name": "custom-elements-json", + "version": "0.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/json-schema": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.3.tgz", + "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==", + "dev": true + }, + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "prettier": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz", + "integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", + "dev": true + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "typescript": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", + "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", + "dev": true + }, + "typescript-json-schema": { + "version": "0.40.0", + "resolved": "https://registry.npmjs.org/typescript-json-schema/-/typescript-json-schema-0.40.0.tgz", + "integrity": "sha512-C8D3Ca6+1x3caWOR+u45Shn3KqkRZi5M3+E8ePpEmYMqOh3xhhLdq+39pqT0Bf8+fCgAmpTFSJMT6Xwqbm0Tkw==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "glob": "~7.1.4", + "json-stable-stringify": "^1.0.1", + "typescript": "^3.5.3", + "yargs": "^14.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.0.tgz", + "integrity": "sha512-/is78VKbKs70bVZH7w4YaZea6xcJWOAwkhbR0CFuZBmYtfTYF0xjGJF43AYd8g2Uii1yJwmS5GR2vBmrc32sbg==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^15.0.0" + } + }, + "yargs-parser": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.0.tgz", + "integrity": "sha512-xLTUnCMc4JhxrPEPUYD5IBR1mWCK/aT6+RJ/K29JY2y1vD+FhtgKK0AXRWvI262q3QSffAQuTouFIKUuHX89wQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b51d9de --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "custom-elements-json", + "version": "0.0.0", + "description": "A file format for describing custom elements", + "main": "index.js", + "scripts": { + "format": "prettier schema.ts --write", + "generate-json-schema": "typescript-json-schema --required --ignoreErrors schema.ts -o schema.json Package" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/webcomponents/custom-elements-json.git" + }, + "keywords": [], + "author": "", + "license": "BSD-3-Clause", + "bugs": { + "url": "https://github.com/webcomponents/custom-elements-json/issues" + }, + "homepage": "https://github.com/webcomponents/custom-elements-json#readme", + "devDependencies": { + "prettier": "^2.1.2", + "typescript": "^3.7.2", + "typescript-json-schema": "^0.40.0" + } +} diff --git a/schema.json b/schema.json new file mode 100644 index 0000000..9869918 --- /dev/null +++ b/schema.json @@ -0,0 +1,679 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "Attribute": { + "properties": { + "defaultValue": { + "description": "The default value of the attribute, if any.\n\nAs attributes are always strings, this is the actual value, not a human\nreadable description.", + "type": "string" + }, + "description": { + "description": "A markdown description.", + "type": "string" + }, + "fieldName": { + "description": "The name of the field this attribute is associated with, if any.", + "type": "string" + }, + "name": { + "type": "string" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + }, + "type": { + "$ref": "#/definitions/Type", + "description": "The type that the attribute will be serialized/deserialized as." + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "ClassDeclaration": { + "properties": { + "description": { + "description": "A markdown description of the class.", + "type": "string" + }, + "kind": { + "enum": [ + "class" + ], + "type": "string" + }, + "members": { + "items": { + "anyOf": [ + { + "$ref": "#/definitions/ClassField" + }, + { + "$ref": "#/definitions/ClassMethod" + } + ] + }, + "type": "array" + }, + "mixins": { + "items": { + "$ref": "#/definitions/Reference" + }, + "type": "array" + }, + "name": { + "type": "string" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + }, + "superclass": { + "$ref": "#/definitions/Reference" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, + "ClassField": { + "properties": { + "default": { + "type": "string" + }, + "description": { + "description": "A markdown description of the field.", + "type": "string" + }, + "inheritedFrom": { + "$ref": "#/definitions/Reference" + }, + "kind": { + "enum": [ + "field" + ], + "type": "string" + }, + "name": { + "type": "string" + }, + "privacy": { + "$ref": "#/definitions/Privacy" + }, + "static": { + "type": "boolean" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + }, + "type": { + "$ref": "#/definitions/Type" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, + "ClassMethod": { + "properties": { + "description": { + "description": "A markdown description.", + "type": "string" + }, + "inheritedFrom": { + "$ref": "#/definitions/Reference" + }, + "kind": { + "enum": [ + "method" + ], + "type": "string" + }, + "name": { + "type": "string" + }, + "parameters": { + "items": { + "$ref": "#/definitions/Parameter" + }, + "type": "array" + }, + "privacy": { + "$ref": "#/definitions/Privacy" + }, + "return": { + "properties": { + "description": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/Type" + } + }, + "type": "object" + }, + "static": { + "type": "boolean" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, + "CssCustomProperty": { + "properties": { + "defaultValue": { + "type": "string" + }, + "description": { + "description": "A markdown description.", + "type": "string" + }, + "name": { + "description": "The name of the property, including leading `--`.", + "type": "string" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "CssPart": { + "description": "The description of a CSS Part", + "properties": { + "description": { + "description": "A markdown description.", + "type": "string" + }, + "name": { + "type": "string" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "CustomElement": { + "description": "Description of a custom element class.\n\nCustom elements are JavaScript classes, so this extends from\n`ClassDeclaration` and adds custom-element-specific features like\nattributes, events, and slots.\n\nNote that `tagName` in this interface is optional. Tag names are not\nneccessarily part of a custom element class, but belong to the definition\n(often called the \"registration\") or the `customElements.define()` call.\n\nBecause classes and tag anmes can only be registered once, there's a\none-to-one relationship between classes and tag names. For ease of use,\nwe allow the tag name here.\n\nSome packages define and register custom elements in separate modules. In\nthese cases one `Module` should contain the `CustomElement` without a\ntagName, and another `Module` should contain the\n`CustomElement`.", + "properties": { + "attributes": { + "description": "The attributes that this element is known to understand.", + "items": { + "$ref": "#/definitions/Attribute" + }, + "type": "array" + }, + "cssProperties": { + "items": { + "$ref": "#/definitions/CssCustomProperty" + }, + "type": "array" + }, + "demos": { + "items": { + "$ref": "#/definitions/Demo" + }, + "type": "array" + }, + "description": { + "description": "A markdown description of the class.", + "type": "string" + }, + "events": { + "description": "The events that this element fires.", + "items": { + "$ref": "#/definitions/Event" + }, + "type": "array" + }, + "kind": { + "enum": [ + "class" + ], + "type": "string" + }, + "members": { + "items": { + "anyOf": [ + { + "$ref": "#/definitions/ClassField" + }, + { + "$ref": "#/definitions/ClassMethod" + } + ] + }, + "type": "array" + }, + "mixins": { + "items": { + "$ref": "#/definitions/Reference" + }, + "type": "array" + }, + "name": { + "type": "string" + }, + "parts": { + "items": { + "$ref": "#/definitions/CssPart" + }, + "type": "array" + }, + "slots": { + "description": "The shadow dom content slots that this element accepts.", + "items": { + "$ref": "#/definitions/Slot" + }, + "type": "array" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + }, + "superclass": { + "$ref": "#/definitions/Reference" + }, + "tagName": { + "description": "An optional tag name that should be specified if this is a\nself-registering element.\n\nSelf-registering elements must also include a CustomElementExport\nin the module's exports.", + "type": "string" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, + "CustomElementExport": { + "description": "A global custom element defintion, ie the result of a\n`customElements.define()` call.\n\nThis is represented as an export because a definition makes the element\navailable outside of the module it's defined it.", + "properties": { + "declaration": { + "$ref": "#/definitions/Reference", + "description": "A reference to the class or other declaration that implements the\ncustom element." + }, + "kind": { + "enum": [ + "custom-element-definition" + ], + "type": "string" + }, + "name": { + "description": "The tag name of the custom element.", + "type": "string" + } + }, + "required": [ + "declaration", + "kind", + "name" + ], + "type": "object" + }, + "Demo": { + "properties": { + "description": { + "description": "A markdown description of the demo.", + "type": "string" + }, + "url": { + "description": "Relative URL of the demo if it's published with the package. Absolute URL\nif it's hosted.", + "type": "string" + } + }, + "required": [ + "url" + ], + "type": "object" + }, + "Event": { + "properties": { + "description": { + "description": "A markdown description.", + "type": "string" + }, + "name": { + "type": "string" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + }, + "type": { + "$ref": "#/definitions/Type", + "description": "The type of the event object that's fired." + } + }, + "required": [ + "name", + "type" + ], + "type": "object" + }, + "FunctionDeclaration": { + "properties": { + "description": { + "description": "A markdown description.", + "type": "string" + }, + "kind": { + "enum": [ + "function" + ], + "type": "string" + }, + "name": { + "type": "string" + }, + "parameters": { + "items": { + "$ref": "#/definitions/Parameter" + }, + "type": "array" + }, + "return": { + "properties": { + "description": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/Type" + } + }, + "type": "object" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, + "JavaScriptExport": { + "properties": { + "declaration": { + "$ref": "#/definitions/Reference", + "description": "A reference to the exported declaration.\n\nIn the case of aggregating exports, the reference's `module` field must be\ndefined and the `name` field must be `\"*\"`." + }, + "kind": { + "enum": [ + "js" + ], + "type": "string" + }, + "name": { + "description": "The name of the exported symbol.\n\nJavaScript has a number of ways to export objects which determine the\ncorrect name to use.\n\n- Default exports must use the name \"default\".\n- Named exports use the name that is exported. If the export is renamed\n with the \"as\" clause, use the exported name.\n- Aggregating exports (`* from`) should use the name `*`", + "type": "string" + } + }, + "required": [ + "declaration", + "kind", + "name" + ], + "type": "object" + }, + "JavaScriptModule": { + "properties": { + "declarations": { + "description": "The declarations of a module.\n\nFor documentation purposes, all declarations that are reachable from\nexports should be described here. Ie, functions and objects that may be\nproperties of exported objects, or passed as arguments to functions.", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/ClassDeclaration" + }, + { + "$ref": "#/definitions/FunctionDeclaration" + }, + { + "$ref": "#/definitions/VariableDeclaration" + }, + { + "$ref": "#/definitions/CustomElement" + } + ] + }, + "type": "array" + }, + "description": { + "description": "A markdown description of the module.", + "type": "string" + }, + "exports": { + "description": "The exports of a module. This includes JavaScript exports and\ncustom element definitions.", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/JavaScriptExport" + }, + { + "$ref": "#/definitions/CustomElementExport" + } + ] + }, + "type": "array" + }, + "kind": { + "enum": [ + "javascript-module" + ], + "type": "string" + }, + "path": { + "type": "string" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + } + }, + "required": [ + "declarations", + "kind", + "path" + ], + "type": "object" + }, + "Parameter": { + "properties": { + "default": { + "type": "string" + }, + "description": { + "description": "A markdown description of the field.", + "type": "string" + }, + "name": { + "type": "string" + }, + "optional": { + "description": "Whether the parameter is optional. Undefined implies non-optional.", + "type": "boolean" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + }, + "type": { + "$ref": "#/definitions/Type" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "Privacy": { + "enum": [ + "private", + "protected", + "public" + ], + "type": "string" + }, + "Reference": { + "description": "A reference to an export of a module.\n\nAll references are required to be publically accessible, so the canonical\nrepresentation of a reference is the export it's available from.\n\nReferrences to global symbols like `Array`, `HTMLElement`, or `Event`", + "properties": { + "module": { + "type": "string" + }, + "name": { + "type": "string" + }, + "package": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "Slot": { + "properties": { + "description": { + "description": "A markdown description.", + "type": "string" + }, + "name": { + "description": "The slot name, or the empty string for an unnamed slot.", + "type": "string" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "Type": { + "properties": { + "references": { + "description": "An array of references to the types in the type string.\n\nThese references have optional indices into the type string so that tools\ncan understand the references in the type string independently of the type\nsystem and syntax. For example, a documentation viewer could display the\ntype `Array` with cross-references to `FooElement`\nand `BarElement` without understanding arrays, generics, or union types.", + "items": { + "$ref": "#/definitions/TypeReference" + }, + "type": "array" + }, + "type": { + "description": "The full string representation of the type, in whatever type syntax is\nused, such as JSDoc, Closure, or TypeScript.", + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "TypeReference": { + "description": "A reference that is associated with a type string and optionally a range\nwithin the string.\n\nStart and end must both be present or not present. If they're present, they\nare indices into the associated type string. If they are missing, the entire\ntype string is the symbol referenced and the name should match the type\nstring.", + "properties": { + "end": { + "type": "number" + }, + "module": { + "type": "string" + }, + "name": { + "type": "string" + }, + "package": { + "type": "string" + }, + "start": { + "type": "number" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "VariableDeclaration": { + "properties": { + "default": { + "type": "string" + }, + "description": { + "description": "A markdown description of the field.", + "type": "string" + }, + "kind": { + "enum": [ + "variable" + ], + "type": "string" + }, + "name": { + "type": "string" + }, + "summary": { + "description": "A markdown summary suitable for display in a listing.", + "type": "string" + }, + "type": { + "$ref": "#/definitions/Type" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + } + }, + "description": "The top-level interface of a custom-elements.json file.\n\nBecause custom elements are JavaScript classes, describing a custom element\nmay require describing arbitrary JavaScript concepts like modules, classes,\nfunctions, etc. So custom-elements.json documents are capable of documenting\nthe elements in a package, as well as those JavaScript concepts.\n\nThe modules described in a package should be the public entrypoints that\nother packages may import from. Multiple modules may export the same object\nvia re-exports, but in most cases a package should document the single\ncanonical export that should be used.", + "properties": { + "modules": { + "description": "An array of the modules this package contains.", + "items": { + "$ref": "#/definitions/JavaScriptModule" + }, + "type": "array" + }, + "readme": { + "description": "The Markdown to use for the main readme of this package.\n\nThis can be used to override the readme used by Github or npm if that\nfile contains information irrelevant to custom element catalogs and\ndocumentation viewers.", + "type": "string" + }, + "schemaVersion": { + "description": "The version of the custom-elements.json schema used in this file.", + "type": "string" + } + }, + "required": [ + "modules", + "schemaVersion" + ], + "type": "object" +} + diff --git a/schema.ts b/schema.ts new file mode 100644 index 0000000..8369cd1 --- /dev/null +++ b/schema.ts @@ -0,0 +1,462 @@ +/** + * @license + * Copyright (c) 2019 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt + */ + +/** + * The top-level interface of a custom-elements.json file. + * + * Because custom elements are JavaScript classes, describing a custom element + * may require describing arbitrary JavaScript concepts like modules, classes, + * functions, etc. So custom-elements.json documents are capable of documenting + * the elements in a package, as well as those JavaScript concepts. + * + * The modules described in a package should be the public entrypoints that + * other packages may import from. Multiple modules may export the same object + * via re-exports, but in most cases a package should document the single + * canonical export that should be used. + */ +export interface Package { + /** + * The version of the custom-elements.json schema used in this file. + */ + schemaVersion: string; + + /** + * The Markdown to use for the main readme of this package. + * + * This can be used to override the readme used by Github or npm if that + * file contains information irrelevant to custom element catalogs and + * documentation viewers. + */ + readme?: string; + + /** + * An array of the modules this package contains. + */ + modules: Array; +} + +// This type may expand in the future to include JSON, CSS, or HTML +// modules. +type Module = JavaScriptModule; + +export interface JavaScriptModule { + kind: 'javascript-module'; + + path: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description of the module. + */ + description?: string; + + /** + * The declarations of a module. + * + * For documentation purposes, all declarations that are reachable from + * exports should be described here. Ie, functions and objects that may be + * properties of exported objects, or passed as arguments to functions. + */ + declarations: Array; + + /** + * The exports of a module. This includes JavaScript exports and + * custom element definitions. + */ + exports?: Array; +} + +export type Export = JavaScriptExport | CustomElementExport; + +export interface JavaScriptExport { + kind: 'js'; + + /** + * The name of the exported symbol. + * + * JavaScript has a number of ways to export objects which determine the + * correct name to use. + * + * - Default exports must use the name "default". + * - Named exports use the name that is exported. If the export is renamed + * with the "as" clause, use the exported name. + * - Aggregating exports (`* from`) should use the name `*` + */ + name: string; + + /** + * A reference to the exported declaration. + * + * In the case of aggregating exports, the reference's `module` field must be + * defined and the `name` field must be `"*"`. + */ + declaration: Reference; +} + +/** + * A global custom element defintion, ie the result of a + * `customElements.define()` call. + * + * This is represented as an export because a definition makes the element + * available outside of the module it's defined it. + */ +export interface CustomElementExport { + kind: 'custom-element-definition'; + + /** + * The tag name of the custom element. + */ + name: string; + + /** + * A reference to the class or other declaration that implements the + * custom element. + */ + declaration: Reference; +} + +export type Declaration = + | ClassDeclaration + | FunctionDeclaration + | MixinDeclaration + | VariableDeclaration + | CustomElement; + +/** + * A reference to an export of a module. + * + * All references are required to be publically accessible, so the canonical + * representation of a reference is the export it's available from. + * + * Referrences to global symbols like `Array`, `HTMLElement`, or `Event` + * + */ +export interface Reference { + name: string; + package?: string; + module?: string; +} + +/** + * Description of a custom element class. + * + * Custom elements are JavaScript classes, so this extends from + * `ClassDeclaration` and adds custom-element-specific features like + * attributes, events, and slots. + * + * Note that `tagName` in this interface is optional. Tag names are not + * neccessarily part of a custom element class, but belong to the definition + * (often called the "registration") or the `customElements.define()` call. + * + * Because classes and tag anmes can only be registered once, there's a + * one-to-one relationship between classes and tag names. For ease of use, + * we allow the tag name here. + * + * Some packages define and register custom elements in separate modules. In + * these cases one `Module` should contain the `CustomElement` without a + * tagName, and another `Module` should contain the + * `CustomElement`. + */ +export interface CustomElement extends ClassDeclaration { + /** + * An optional tag name that should be specified if this is a + * self-registering element. + * + * Self-registering elements must also include a CustomElementExport + * in the module's exports. + */ + tagName?: string; + + /** + * The attributes that this element is known to understand. + */ + attributes?: Attribute[]; + + /** + * The events that this element fires. + */ + events?: Event[]; + + /** + * The shadow dom content slots that this element accepts. + */ + slots?: Slot[]; + + parts?: CssPart[]; + + cssProperties?: CssCustomProperty[]; + + demos?: Demo[]; +} + +export interface Attribute { + name: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description. + */ + description?: string; + + inheritedFrom?: Reference; + + /** + * The type that the attribute will be serialized/deserialized as. + */ + type?: Type; + + /** + * The default value of the attribute, if any. + * + * As attributes are always strings, this is the actual value, not a human + * readable description. + */ + defaultValue?: string; + + /** + * The name of the field this attribute is associated with, if any. + */ + fieldName?: string; +} + +export interface Event { + name: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description. + */ + description?: string; + + /** + * The type of the event object that's fired. + */ + type: Type; + + inheritedFrom?: Reference; +} + +export interface Slot { + /** + * The slot name, or the empty string for an unnamed slot. + */ + name: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description. + */ + description?: string; +} + +/** + * The description of a CSS Part + */ +export interface CssPart { + name: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description. + */ + description?: string; +} + +export interface CssCustomProperty { + /** + * The name of the property, including leading `--`. + */ + name: string; + + defaultValue?: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description. + */ + description?: string; +} + +export interface Type { + /** + * The full string representation of the type, in whatever type syntax is + * used, such as JSDoc, Closure, or TypeScript. + */ + type: string; + + /** + * An array of references to the types in the type string. + * + * These references have optional indices into the type string so that tools + * can understand the references in the type string independently of the type + * system and syntax. For example, a documentation viewer could display the + * type `Array` with cross-references to `FooElement` + * and `BarElement` without understanding arrays, generics, or union types. + */ + references?: TypeReference[]; +} + +/** + * A reference that is associated with a type string and optionally a range + * within the string. + * + * Start and end must both be present or not present. If they're present, they + * are indices into the associated type string. If they are missing, the entire + * type string is the symbol referenced and the name should match the type + * string. + */ +export interface TypeReference extends Reference { + start?: number; + end?: number; +} + +/** + * The common interface of classes and mixins. + */ +export interface ClassLike { + name: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description of the class. + */ + description?: string; + superclass?: Reference; + mixins?: Array; + members?: Array; +} + +export interface ClassDeclaration extends ClassLike { + kind: 'class'; +} + +export type ClassMember = ClassField | ClassMethod; + +/** + * The common interface of variables, class fields, and function + * parameters. + */ +export interface PropertyLike { + name: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description of the field. + */ + description?: string; + + type?: Type; + + default?: string; +} + +export interface ClassField extends PropertyLike { + kind: 'field'; + static?: boolean; + privacy?: Privacy; + inheritedFrom?: Reference; +} + +export interface ClassMethod extends FunctionLike { + kind: 'method'; + static?: boolean; + privacy?: Privacy; + inheritedFrom?: Reference; +} + +/** + * + */ +export interface MixinDeclaration extends ClassLike, FunctionLike { + kind: 'mixin'; +} + +export interface VariableDeclaration extends PropertyLike { + kind: 'variable'; +} + +export interface FunctionDeclaration extends FunctionLike { + kind: 'function'; +} + +export interface Parameter extends PropertyLike { + /** + * Whether the parameter is optional. Undefined implies non-optional. + */ + optional?: boolean; +} + +export interface FunctionLike { + name: string; + + /** + * A markdown summary suitable for display in a listing. + */ + summary?: string; + + /** + * A markdown description. + */ + description?: string; + + parameters?: Parameter[]; + + return?: { + type?: Type; + description?: string; + }; +} + +export type Privacy = 'public' | 'private' | 'protected'; + +export interface Demo { + /** + * A markdown description of the demo. + */ + description?: string; + + /** + * Relative URL of the demo if it's published with the package. Absolute URL + * if it's hosted. + */ + url: string; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..6a4fd2e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "es2017", + "module": "esnext", + "lib": ["es2017"], + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "./", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + }, + "include": ["*.ts"], + "exclude": [] +}