Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for generating Typescript definitions #1653

Merged
merged 3 commits into from Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -33,13 +33,15 @@
"fs-extra": "^3.0.1",
"google-closure-compiler": "^20190513.0.0",
"http-server": "^0.11.1",
"jsdoc": "^3.6.3",
"karma": "^4.2.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-spec-reporter": "0.0.32",
"mocha": "^5.2.0",
"preprocessor": "^1.4.0",
"sinon": "^5.1.1",
"tsd-jsdoc": "^2.3.1",
"uglify-js": "^3.6.0"
},
"optionalDependencies": {
Expand All @@ -59,6 +61,7 @@
"test:release": "karma start tests/karma.conf.js -- --single-run --release",
"test:watch": "karma start tests/karma.conf.js",
"test:debug": "karma start tests/karma.conf.js -- --single-run=false",
"tsd": "jsdoc -c tsd-jsdoc.conf",
"lint": "eslint extras src"
},
"engines": {
Expand Down
2 changes: 2 additions & 0 deletions src/asset/asset-list-loader.js
Expand Up @@ -55,6 +55,7 @@ Object.assign(pc, function () {
};

/**
* @private
* @function
* @name pc.AssetListLoader#load
* @description Start loading asset list, call done() when all assets have loaded or failed to load
Expand Down Expand Up @@ -87,6 +88,7 @@ Object.assign(pc, function () {
};

/**
* @private
* @function
* @name pc.AssetListLoader#ready
* @param {Function} done Callback called when all assets in the list are loaded
Expand Down
6 changes: 6 additions & 0 deletions src/core/indexed-list.js
Expand Up @@ -12,6 +12,7 @@ Object.assign(pc, (function () {

Object.assign(IndexedList.prototype, {
/**
* @private
* @function
* @name pc.IndexedList#push
* @description Add a new item into the list with a index key
Expand All @@ -27,6 +28,7 @@ Object.assign(pc, (function () {
},

/**
* @private
* @function
* @name pc.IndexedList#has
* @description Test whether a key has been added to the index
Expand All @@ -38,6 +40,7 @@ Object.assign(pc, (function () {
},

/**
* @private
* @function
* @name pc.IndexedList#get
* @description Return the item indexed by a key
Expand All @@ -53,6 +56,7 @@ Object.assign(pc, (function () {
},

/**
* @private
* @function
* @name pc.IndexedList#remove
* @description Remove the item indexed by key from the list
Expand All @@ -79,6 +83,7 @@ Object.assign(pc, (function () {
},

/**
* @private
* @function
* @name pc.IndexedList#list
* @description Returns the list of items
Expand All @@ -89,6 +94,7 @@ Object.assign(pc, (function () {
},

/**
* @private
* @function
* @name pc.IndexedList#clear
* @description Remove all items from the list
Expand Down
1 change: 1 addition & 0 deletions src/core/path.js
Expand Up @@ -7,6 +7,7 @@ pc.path = function () {
/**
* The character that separates path segments
* @name pc.path.delimiter
* @type String
*/
delimiter: "/",
/**
Expand Down
22 changes: 11 additions & 11 deletions src/core/platform.js
@@ -1,8 +1,8 @@
Object.assign(pc, function () {
/**
* @name pc.platform
* @namespace
* @description global namespace that stores flags regarding platform environment and features support
* @name pc.platform
* @description Global namespace that stores flags regarding platform environment and features support
* @example
* if (pc.platform.touch) {
* // touch is supported
Expand All @@ -12,60 +12,63 @@ Object.assign(pc, function () {
/**
* @name pc.platform.desktop
* @description is it a desktop or laptop device
* @type Boolean
*/
desktop: false,

/**
* @name pc.platform.mobile
* @description is it a mobile or tablet device
* @type Boolean
*/
mobile: false,

/**
* @name pc.platform.ios
* @description if it is iOS
* @type Boolean
*/
ios: false,

/**
* @name pc.platform.android
* @description if it is Android
* @type Boolean
*/
android: false,

/**
* @name pc.platform.windows
* @description if it is Windows
* @type Boolean
*/
windows: false,

/**
* @name pc.platform.cocoonjs
* @description if it is CocoonJS
*/
cocoonjs: false,

/**
* @name pc.platform.xbox
* @description if it is Xbox
* @type Boolean
*/
xbox: false,

/**
* @name pc.platform.gamepads
* @description if platform supports gamepads
* @type Boolean
*/
gamepads: false,

/**
* @name pc.platform.touch
* @description if platform supports touch input
* @type Boolean
*/
touch: false,

/**
* @name pc.platform.workers
* @description if the platform supports Web Workers
* @type Boolean
*/
workers: false
};
Expand All @@ -92,9 +95,6 @@ Object.assign(pc, function () {
platform.ios = true;
}

if (navigator.isCocoonJS)
platform.cocoonjs = true;

platform.touch = 'ontouchstart' in window || ('maxTouchPoints' in navigator && navigator.maxTouchPoints > 0);

platform.gamepads = 'getGamepads' in navigator;
Expand Down
13 changes: 13 additions & 0 deletions src/core/uri.js
Expand Up @@ -72,36 +72,47 @@ Object.assign(pc, function () {
result = uri.match(re);

/**
* @private
* @name pc.URI#scheme
* @description The scheme. (e.g. http)
* @type String
*/
this.scheme = result[2];

/**
* @private
* @name pc.URI#authority
* @description The authority. (e.g. www.example.com)
* @type String
*/
this.authority = result[4];

/**
* @private
* @name pc.URI#path
* @description The path. (e.g. /users/example)
* @type String
*/
this.path = result[5];

/**
* @private
* @name pc.URI#query
* @description The query, the section after a ?. (e.g. search=value)
* @type String
*/
this.query = result[7];

/**
* @private
* @name pc.URI#fragment
* @description The fragment, the section after a #
* @type String
*/
this.fragment = result[9];

/**
* @private
* @function
* @name pc.URI#toString
* @description Convert URI back to string
Expand Down Expand Up @@ -132,6 +143,7 @@ Object.assign(pc, function () {
};

/**
* @private
* @function
* @name pc.URI#getQuery
* @description Returns the query parameters as an Object.
Expand Down Expand Up @@ -161,6 +173,7 @@ Object.assign(pc, function () {
};

/**
* @private
* @function
* @name pc.URI#setQuery
* @description Set the query section of the URI from a Object
Expand Down
1 change: 1 addition & 0 deletions src/framework/components/element/element-drag-helper.js
Expand Up @@ -14,6 +14,7 @@ Object.assign(pc, function () {

/**
* @component
* @constructor
* @name pc.ElementDragHelper
* @description Create a new ElementDragHelper
* @classdesc Helper class that makes it easy to create Elements that can be dragged by the mouse or touch.
Expand Down
3 changes: 2 additions & 1 deletion src/framework/components/script/component.js
Expand Up @@ -391,7 +391,8 @@ Object.assign(pc, function () {

/**
* @private
* Inserts script instance into the scripts array at the specified index. Also inserts the script
* @function
* @description Inserts script instance into the scripts array at the specified index. Also inserts the script
* into the update list if it has an update method and the post update list if it has a postUpdate method.
* @param {Object} scriptInstance The script instance
* @param {Number} index The index where to insert the script at. If -1 then append it at the end.
Expand Down
15 changes: 11 additions & 4 deletions src/framework/utils/entity-reference.js
Expand Up @@ -220,8 +220,12 @@ Object.assign(pc, function () {
},

/**
* Must be called from the parent component's onEnable() method in order for entity
* references to be correctly resolved when {@link pc.Entity#clone} is called.
* @private
* @function
* @name pc.EntityReference#onParentComponentEnable
* @description Must be called from the parent component's onEnable() method in
* order for entity references to be correctly resolved when {@link pc.Entity#clone}
* is called.
*/
onParentComponentEnable: function () {
// When an entity is cloned via the JS API, we won't be able to resolve the
Expand Down Expand Up @@ -382,8 +386,11 @@ Object.assign(pc, function () {
},

/**
* Convenience method indicating whether the entity exists and has a component of the provided type.
*
* @private
* @function
* @name pc.EntityReference#hasComponent
* @description Convenience method indicating whether the entity exists and has a
* component of the provided type.
* @param {String} componentName Name of the component.
* @returns {Boolean} True if the entity exists and has a component of the provided type.
*/
Expand Down