Merge pull request #8167 from tschaub/goodbye-oli

Remove externs/oli.js
This commit is contained in:
Tim Schaub
2018-05-08 12:37:26 -07:00
committed by GitHub
26 changed files with 4 additions and 515 deletions
+1 -2
View File
@@ -10,8 +10,7 @@
"includePattern": ".+\\.js(doc)?$", "includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_", "excludePattern": "(^|\\/|\\\\)_",
"include": [ "include": [
"src", "src"
"externs/oli.js"
] ]
}, },
"plugins": [ "plugins": [
+2 -4
View File
@@ -57,10 +57,8 @@ function includeAugments(doclet) {
} }
}); });
} }
if (cls.longname.indexOf('oli.') !== 0) { cls._hideConstructor = true;
cls._hideConstructor = true; delete cls.undocumented;
delete cls.undocumented;
}
} }
} }
} }
-15
View File
@@ -47,21 +47,6 @@ ol.MapBrowserEventType = {
``` ```
Note the value of the `@event` annotation. The text before the hash refers to the event class that the event belongs to, and the text after the hash is the type of the event. Note the value of the `@event` annotation. The text before the hash refers to the event class that the event belongs to, and the text after the hash is the type of the event.
To export event properties, they need to be defined in `externs/oli.js` (also see `readme.md` in `externs/`) and marked with an @api annotation:
```js
/** @interface */
oli.MapBrowserEvent;
/**
* @type {ol.Coordinate}
* @api
*/
oli.MapBrowserEvent.prototype.coordinate;
// ...
};
```
To document which events are fired by a class or method, the `@fires` annotation is used: To document which events are fired by a class or method, the `@fires` annotation is used:
```js ```js
/** /**
-6
View File
@@ -175,9 +175,6 @@ The minimum config file looks like this:
"define": [ "define": [
"ol.ENABLE_WEBGL=false" "ol.ENABLE_WEBGL=false"
], ],
"js": [
"node_modules/openlayers/externs/oli.js"
],
"extra_annotation_name": [ "extra_annotation_name": [
"api", "observable" "api", "observable"
], ],
@@ -225,9 +222,6 @@ Here is a version of `config.json` with more compilation checks enabled:
"define": [ "define": [
"ol.ENABLE_WEBGL=false" "ol.ENABLE_WEBGL=false"
], ],
"js": [
"node_modules/openlayers/externs/oli.js"
],
"jscomp_error": [ "jscomp_error": [
"*" "*"
], ],
-2
View File
@@ -55,7 +55,6 @@ Creating a custom build requires writing a build configuration file. The format
"externs/closure-compiler.js", "externs/closure-compiler.js",
"externs/esrijson.js", "externs/esrijson.js",
"externs/geojson.js", "externs/geojson.js",
"externs/oli.js",
"externs/proj4js.js", "externs/proj4js.js",
"externs/tilejson.js", "externs/tilejson.js",
"externs/topojson.js" "externs/topojson.js"
@@ -205,7 +204,6 @@ Now let's try a more complicated example: [`heatmaps-earthquakes`](https://openl
"externs/closure-compiler.js", "externs/closure-compiler.js",
"externs/esrijson.js", "externs/esrijson.js",
"externs/geojson.js", "externs/geojson.js",
"externs/oli.js",
"externs/proj4js.js", "externs/proj4js.js",
"externs/tilejson.js", "externs/tilejson.js",
"externs/topojson.js" "externs/topojson.js"
-385
View File
@@ -1,385 +0,0 @@
/**
* @externs
*/
/**
* @type {Object}
*/
let oli;
/**
* @interface
*/
oli.AssertionError = function() {};
/**
* @type {number}
*/
oli.AssertionError.prototype.code;
/**
* @interface
*/
oli.events.Event = function() {};
/**
* @type {Object}
*/
oli.events.Event.prototype.target;
/**
* @type {string}
*/
oli.events.Event.prototype.type;
/**
*/
oli.events.Event.prototype.preventDefault = function() {};
/**
*/
oli.events.Event.prototype.stopPropagation = function() {};
/**
* @interface
*/
oli.Collection.Event = function() {};
/**
* @type {*}
*/
oli.Collection.Event.prototype.element;
/**
* @interface
*/
oli.DragBoxEvent = function() {};
/**
* @type {ol.Coordinate}
*/
oli.DragBoxEvent.prototype.coordinate;
/**
* @type {module:ol/MapBrowserEvent~MapBrowserEvent}
*/
oli.DragBoxEvent.prototype.mapBrowserEvent;
/**
* @interface
*/
oli.DrawEvent = function() {};
/**
* @type {module:ol/Feature~Feature}
*/
oli.DrawEvent.prototype.feature;
/**
* @interface
*/
oli.ExtentEvent = function() {};
/**
* @type {ol.Extent}
*/
oli.ExtentEvent.prototype.extent;
/**
* @interface
*/
oli.ModifyEvent = function() {};
/**
* @type {ol.Collection.<module:ol/Feature~Feature>}
*/
oli.ModifyEvent.prototype.features;
/**
* @type {module:ol/MapBrowserEvent~MapBrowserEvent}
*/
oli.ModifyEvent.prototype.mapBrowserEvent;
/**
* @type {Object}
*/
oli.Object;
/**
* @interface
*/
oli.Object.Event = function() {};
/**
* @type {string}
*/
oli.Object.Event.prototype.key;
/**
* @type {*}
*/
oli.Object.Event.prototype.oldValue;
/**
* @interface
*/
oli.MapBrowserEvent = function() {};
/**
* @type {ol.Coordinate}
*/
oli.MapBrowserEvent.prototype.coordinate;
/**
* @type {Event}
*/
oli.MapBrowserEvent.prototype.originalEvent;
/**
* @type {ol.Pixel}
*/
oli.MapBrowserEvent.prototype.pixel;
/**
* @type {boolean}
*/
oli.MapBrowserEvent.prototype.dragging;
/**
* @interface
*/
oli.MapEvent = function() {};
/**
* @type {ol.PluggableMap}
*/
oli.MapEvent.prototype.map;
/**
* @type {module:ol/PluggableMap~FrameState}
*/
oli.MapEvent.prototype.frameState;
/**
* @interface
*/
oli.SelectEvent = function() {};
/**
* @type {Array.<module:ol/Feature~Feature>}
*/
oli.SelectEvent.prototype.deselected;
/**
* @type {Array.<module:ol/Feature~Feature>}
*/
oli.SelectEvent.prototype.selected;
/**
* @type {module:ol/MapBrowserEvent~MapBrowserEvent}
*/
oli.SelectEvent.prototype.mapBrowserEvent;
/**
* @type {Object}
*/
oli.control;
/**
* @interface
*/
oli.control.Control = function() {};
/**
* @param {ol.PluggableMap} map Map.
* @return {undefined} Undefined.
*/
oli.control.Control.prototype.setMap = function(map) {};
/**
* @type {Object}
*/
oli.interaction;
/**
* @interface
*/
oli.interaction.DragAndDropEvent = function() {};
/**
* @type {Array.<module:ol/Feature~Feature>|undefined}
*/
oli.interaction.DragAndDropEvent.prototype.features;
/**
* @type {module:ol/proj/Projection~Projection|undefined}
*/
oli.interaction.DragAndDropEvent.prototype.projection;
/**
* @type {File}
*/
oli.interaction.DragAndDropEvent.prototype.file;
/**
* @interface
*/
oli.interaction.TranslateEvent = function() {};
/**
* @type {ol.Collection.<module:ol/Feature~Feature>}
*/
oli.interaction.TranslateEvent.prototype.features;
/**
* @type {ol.Coordinate}
*/
oli.interaction.TranslateEvent.prototype.coordinate;
/**
* @type {Object}
*/
oli.render;
/**
* @interface
*/
oli.render.Event = function() {};
/**
* @type {CanvasRenderingContext2D|null|undefined}
*/
oli.render.Event.prototype.context;
/**
* @type {module:ol/PluggableMap~FrameState|undefined}
*/
oli.render.Event.prototype.frameState;
/**
* @type {ol.webgl.Context|null|undefined}
*/
oli.render.Event.prototype.glContext;
/**
* @type {ol.render.VectorContext|undefined}
*/
oli.render.Event.prototype.vectorContext;
/**
* @type {Object}
*/
oli.source;
/**
* @interface
*/
oli.source.ImageEvent = function() {};
/**
* @type {ol.Image}
*/
oli.source.ImageEvent.prototype.image;
/**
* @interface
*/
oli.source.RasterEvent = function() {};
/**
* @type {ol.Extent}
*/
oli.source.RasterEvent.prototype.extent;
/**
* @type {number}
*/
oli.source.RasterEvent.prototype.resolution;
/**
* @type {Object}
*/
oli.source.RasterEvent.prototype.data;
/**
* @interface
*/
oli.source.Tile.Event = function() {};
/**
* @type {ol.Tile}
*/
oli.source.Tile.Event.prototype.tile;
/**
* @interface
*/
oli.source.Vector.Event = function() {};
/**
* @type {module:ol/Feature~Feature|undefined}
*/
oli.source.Vector.Event.prototype.feature;
+1 -82
View File
@@ -1,84 +1,3 @@
# Externs # Externs
This directory contains externs files, which tell the Closure compiler about symbols and properties that it should not rename. TODO: remove this directory
## oli.js
These are special externs that belong to OpenLayers, and this document explains their purpose and how they are used.
### Prevent class properties from being renamed
For events, we make properties available to the application. Methods can be made available by just marking them with the `@api` annotation directly where they are defined; properties should also be added to `oli.js`:
```js
/**
* @interface
*/
oli.MapBrowserEvent = function() {};
/**
* @type {ol.Coordinate}
*/
oli.MapBrowserEvent.prototype.coordinate;
```
In the source file (`src/ol/MapBrowserEvent.js`), the class needs to implement this interface:
```js
/**
* ...
* @constructor
* @implements {oli.MapBrowserEvent}
*/
ol.MapBrowserEvent = function(type, map, originalEvent, opt_frameState) {
// ...
/**
* @type {ol.Coordinate}
* @api
*/
this.coordinate = map.getEventCoordinate(this.originalEvent);
// ...
};
```
### Override methods in custom classes
For custom subclasses in applications, which can be created using `ol.inherits`, the API may want to make certain methods available to override. In addition to marking such methods as `@api`, they should also be added to an interface in `oli.js`:
```js
/**
* @interface
*/
oli.control.Control = function() {};
/**
* @param {ol.PluggableMap} map Map.
* @return {undefined} Undefined.
*/
oli.control.Control.prototype.setMap = function(map) {};
```
This interface must be implemented by the class in the source file (`src/ol/control/control.js`):
```js
/**
* ...
* @constructor
* @implements {oli.control.Control}
*/
ol.control.Control = function(options) {
// ...
};
// ...
/**
* Application subclasses may override this.
* @param {ol.PluggableMap} map Map.
* @api
*/
ol.control.Control.prototype.setMap = function(map) {
// ...
};
```
See Custom controls example for an example of how this can be used.
-1
View File
@@ -9,7 +9,6 @@ import {VERSION, inherits} from './index.js';
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error} * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
* @constructor * @constructor
* @extends {Error} * @extends {Error}
* @implements {oli.AssertionError}
* @param {number} code Error code. * @param {number} code Error code.
*/ */
const AssertionError = function(code) { const AssertionError = function(code) {
-1
View File
@@ -24,7 +24,6 @@ const Property = {
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.CollectionEvent}
* @param {module:ol/CollectionEventType} type Type. * @param {module:ol/CollectionEventType} type Type.
* @param {*=} opt_element Element. * @param {*=} opt_element Element.
*/ */
-1
View File
@@ -11,7 +11,6 @@ import MapEvent from './MapEvent.js';
* *
* @constructor * @constructor
* @extends {module:ol/MapEvent} * @extends {module:ol/MapEvent}
* @implements {oli.MapBrowserEvent}
* @param {string} type Event type. * @param {string} type Event type.
* @param {module:ol/PluggableMap} map Map. * @param {module:ol/PluggableMap} map Map.
* @param {Event} browserEvent Browser event. * @param {Event} browserEvent Browser event.
-1
View File
@@ -11,7 +11,6 @@ import Event from './events/Event.js';
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.MapEvent}
* @param {string} type Event type. * @param {string} type Event type.
* @param {module:ol/PluggableMap} map Map. * @param {module:ol/PluggableMap} map Map.
* @param {?module:ol/PluggableMap~FrameState=} opt_frameState Frame state. * @param {?module:ol/PluggableMap~FrameState=} opt_frameState Frame state.
-1
View File
@@ -17,7 +17,6 @@ import {assign} from './obj.js';
* @param {string} key The property name. * @param {string} key The property name.
* @param {*} oldValue The old value for `key`. * @param {*} oldValue The old value for `key`.
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.Object.Event}
* @constructor * @constructor
*/ */
const ObjectEvent = function(type, key, oldValue) { const ObjectEvent = function(type, key, oldValue) {
-1
View File
@@ -46,7 +46,6 @@ import {listen, unlistenByKey} from '../events.js';
* *
* @constructor * @constructor
* @extends {module:ol/Object} * @extends {module:ol/Object}
* @implements {oli.control.Control}
* @param {module:ol/control/Control~Options} options Control options. * @param {module:ol/control/Control~Options} options Control options.
* @api * @api
*/ */
-1
View File
@@ -12,7 +12,6 @@
* {@link module:ol/events/EventTarget~EventTarget}. * {@link module:ol/events/EventTarget~EventTarget}.
* *
* @constructor * @constructor
* @implements {oli.events.Event}
* @param {string} type Type. * @param {string} type Type.
*/ */
const Event = function(type) { const Event = function(type) {
-1
View File
@@ -45,7 +45,6 @@ const DragAndDropEventType = {
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.interaction.DragAndDropEvent}
* @param {module:ol/interaction/DragAndDrop~DragAndDropEventType} type Type. * @param {module:ol/interaction/DragAndDrop~DragAndDropEventType} type Type.
* @param {File} file File. * @param {File} file File.
* @param {Array.<module:ol/Feature>=} opt_features Features. * @param {Array.<module:ol/Feature>=} opt_features Features.
-1
View File
@@ -69,7 +69,6 @@ const DragBoxEventType = {
* @param {module:ol/MapBrowserEvent} mapBrowserEvent Originating event. * @param {module:ol/MapBrowserEvent} mapBrowserEvent Originating event.
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @constructor * @constructor
* @implements {oli.DragBoxEvent}
*/ */
const DragBoxEvent = function(type, coordinate, mapBrowserEvent) { const DragBoxEvent = function(type, coordinate, mapBrowserEvent) {
Event.call(this, type); Event.call(this, type);
-1
View File
@@ -131,7 +131,6 @@ const DrawEventType = {
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.DrawEvent}
* @param {module:ol/interaction/Draw~DrawEventType} type Type. * @param {module:ol/interaction/Draw~DrawEventType} type Type.
* @param {module:ol/Feature} feature The feature drawn. * @param {module:ol/Feature} feature The feature drawn.
*/ */
-1
View File
@@ -53,7 +53,6 @@ const ExtentEventType = {
* instances of this type. * instances of this type.
* *
* @constructor * @constructor
* @implements {oli.ExtentEvent}
* @param {module:ol/extent~Extent} extent the new extent * @param {module:ol/extent~Extent} extent the new extent
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
*/ */
-1
View File
@@ -93,7 +93,6 @@ const ModifyEventType = {
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.ModifyEvent}
* @param {ModifyEventType} type Type. * @param {ModifyEventType} type Type.
* @param {module:ol/Collection.<module:ol/Feature>} features * @param {module:ol/Collection.<module:ol/Feature>} features
* The features modified. * The features modified.
-1
View File
@@ -107,7 +107,6 @@ const SelectEventType = {
* @param {Array.<module:ol/Feature>} deselected Deselected features. * @param {Array.<module:ol/Feature>} deselected Deselected features.
* @param {module:ol/MapBrowserEvent} mapBrowserEvent Associated * @param {module:ol/MapBrowserEvent} mapBrowserEvent Associated
* {@link module:ol/MapBrowserEvent}. * {@link module:ol/MapBrowserEvent}.
* @implements {oli.SelectEvent}
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @constructor * @constructor
*/ */
-1
View File
@@ -59,7 +59,6 @@ const TranslateEventType = {
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.interaction.TranslateEvent}
* @param {module:ol/interaction/Translate~TranslateEventType} type Type. * @param {module:ol/interaction/Translate~TranslateEventType} type Type.
* @param {module:ol/Collection.<module:ol/Feature>} features The features translated. * @param {module:ol/Collection.<module:ol/Feature>} features The features translated.
* @param {module:ol/coordinate~Coordinate} coordinate The event coordinate. * @param {module:ol/coordinate~Coordinate} coordinate The event coordinate.
-1
View File
@@ -7,7 +7,6 @@ import Event from '../events/Event.js';
/** /**
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.render.Event}
* @param {module:ol/render/EventType~EventType} type Type. * @param {module:ol/render/EventType~EventType} type Type.
* @param {module:ol/render/VectorContext=} opt_vectorContext Vector context. * @param {module:ol/render/VectorContext=} opt_vectorContext Vector context.
* @param {module:ol/PluggableMap~FrameState=} opt_frameState Frame state. * @param {module:ol/PluggableMap~FrameState=} opt_frameState Frame state.
-1
View File
@@ -48,7 +48,6 @@ const ImageSourceEventType = {
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.source.ImageEvent}
* @param {string} type Type. * @param {string} type Type.
* @param {module:ol/Image~Image} image The image. * @param {module:ol/Image~Image} image The image.
*/ */
-1
View File
@@ -77,7 +77,6 @@ const RasterOperationType = {
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.source.RasterEvent}
* @param {string} type Type. * @param {string} type Type.
* @param {module:ol/PluggableMap~FrameState} frameState The frame state. * @param {module:ol/PluggableMap~FrameState} frameState The frame state.
* @param {Object} data An object made available to operations. * @param {Object} data An object made available to operations.
-1
View File
@@ -329,7 +329,6 @@ TileSource.prototype.useTile = UNDEFINED;
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.source.Tile.Event}
* @param {string} type Type. * @param {string} type Type.
* @param {module:ol/Tile} tile The tile. * @param {module:ol/Tile} tile The tile.
*/ */
-1
View File
@@ -38,7 +38,6 @@ import RBush from '../structs/RBush.js';
* *
* @constructor * @constructor
* @extends {module:ol/events/Event} * @extends {module:ol/events/Event}
* @implements {oli.source.Vector.Event}
* @param {string} type Type. * @param {string} type Type.
* @param {module:ol/Feature=} opt_feature Feature. * @param {module:ol/Feature=} opt_feature Feature.
*/ */