diff --git a/.eslintignore b/.eslintignore index d6f9d6349f..dcc754f246 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ examples/Jugl.js examples/resources/ build/package/**/*webgl* +config/jsdoc/api/template/static/scripts/ \ No newline at end of file diff --git a/config/jsdoc/api/conf.json b/config/jsdoc/api/conf.json index c710dd9453..7b44b8f119 100644 --- a/config/jsdoc/api/conf.json +++ b/config/jsdoc/api/conf.json @@ -11,8 +11,7 @@ "excludePattern": "(^|\\/|\\\\)_", "include": [ "src", - "externs/oli.js", - "externs/olx.js" + "externs/oli.js" ] }, "plugins": [ diff --git a/config/jsdoc/api/plugins/api.js b/config/jsdoc/api/plugins/api.js index c0e795eff2..fbb26b0a37 100644 --- a/config/jsdoc/api/plugins/api.js +++ b/config/jsdoc/api/plugins/api.js @@ -1,5 +1,6 @@ /** * Define an @api tag + * @param {Object} dictionary The tag dictionary. */ exports.defineTags = function(dictionary) { dictionary.defineTag('api', { @@ -8,32 +9,31 @@ exports.defineTags = function(dictionary) { canHaveName: false, onTagged: function(doclet, tag) { includeTypes(doclet); - doclet.stability = "stable"; + doclet.stability = 'stable'; } }); }; - /* * Based on @api annotations, and assuming that items with no @api annotation * should not be documented, this plugin removes undocumented symbols * from the documentation. */ -var api = []; -var classes = {}; -var types = {}; +const api = []; +const classes = {}; +const types = {}; function hasApiMembers(doclet) { return doclet.longname.split('#')[0] == this.longname; } function includeAugments(doclet) { - var augments = doclet.augments; + const augments = doclet.augments; if (augments) { - var cls; - for (var i = augments.length - 1; i >= 0; --i) { + let cls; + for (let i = augments.length - 1; i >= 0; --i) { cls = classes[augments[i]]; if (cls) { includeAugments(cls); @@ -68,7 +68,7 @@ function includeAugments(doclet) { function extractTypes(item) { item.type.names.forEach(function(type) { - var match = type.match(/^(.*<)?([^>]*)>?$/); + const match = type.match(/^(.*<)?([^>]*)>?$/); if (match) { types[match[2]] = true; } @@ -86,7 +86,6 @@ function includeTypes(doclet) { types[doclet.meta.code.name] = true; } if (doclet.type && doclet.meta.code.type == 'MemberExpression') { - // types in olx.js extractTypes(doclet); } } @@ -94,12 +93,7 @@ function includeTypes(doclet) { exports.handlers = { newDoclet: function(e) { - var doclet = e.doclet; - // Keep track of api items - needed in parseComplete to determine classes - // with api members. - if (doclet.meta.filename == 'olx.js' && doclet.kind == 'typedef') { - doclet.undocumented = false; - } + const doclet = e.doclet; if (doclet.stability) { api.push(doclet); } @@ -114,9 +108,9 @@ exports.handlers = { }, parseComplete: function(e) { - var doclets = e.doclets; - for (var i = doclets.length - 1; i >= 0; --i) { - var doclet = doclets[i]; + const doclets = e.doclets; + for (let i = doclets.length - 1; i >= 0; --i) { + const doclet = doclets[i]; if (doclet.stability || doclet.namespace_) { if (doclet.kind == 'class') { includeAugments(doclet); diff --git a/config/jsdoc/api/plugins/events.js b/config/jsdoc/api/plugins/events.js index 52141b2427..b1ffa9dfba 100644 --- a/config/jsdoc/api/plugins/events.js +++ b/config/jsdoc/api/plugins/events.js @@ -1,11 +1,11 @@ -var events = {}; -var classes = {}; +const events = {}; +const classes = {}; exports.handlers = { newDoclet: function(e) { - var doclet = e.doclet; - var cls; + const doclet = e.doclet; + let cls; if (doclet.kind == 'event') { cls = doclet.longname.split('#')[0]; if (!(cls in events)) { @@ -18,8 +18,8 @@ exports.handlers = { }, parseComplete: function(e) { - var doclets = e.doclets; - var doclet, i, ii, j, jj, event, fires; + const doclets = e.doclets; + let doclet, i, ii, j, jj, event, fires; for (i = 0, ii = doclets.length - 1; i < ii; ++i) { doclet = doclets[i]; if (doclet.fires) { @@ -28,7 +28,7 @@ exports.handlers = { for (j = 0, jj = doclet.fires.length; j < jj; ++j) { event = doclet.fires[j].replace('event:', ''); if (events[event]) { - fires.push.apply(fires, events[event]); + fires.push.apply(fires, events[event]); } else { fires.push(doclet.fires[j]); } diff --git a/config/jsdoc/api/plugins/inheritdoc.js b/config/jsdoc/api/plugins/inheritdoc.js index 04397af7c6..e252269bcc 100644 --- a/config/jsdoc/api/plugins/inheritdoc.js +++ b/config/jsdoc/api/plugins/inheritdoc.js @@ -19,16 +19,16 @@ exports.defineTags = function(dictionary) { }; -var lookup = {}; -var incompleteByClass = {}; -var keepKeys = ['comment', 'meta', 'name', 'memberof', 'longname', 'augment', - 'stability']; +const lookup = {}; +const incompleteByClass = {}; +const keepKeys = ['comment', 'meta', 'name', 'memberof', 'longname', 'augment', + 'stability']; exports.handlers = { newDoclet: function(e) { - var doclet = e.doclet; - var incompletes; + const doclet = e.doclet; + let incompletes; if (!(doclet.longname in lookup)) { lookup[doclet.longname] = []; } @@ -45,9 +45,9 @@ exports.handlers = { }, parseComplete: function(e) { - var ancestors, candidate, candidates, doclet, i, j, k, l, key; - var incompleteDoclet, stability, incomplete, incompletes; - var doclets = e.doclets; + let ancestors, candidate, candidates, doclet, i, j, k, l, key; + let incompleteDoclet, stability, incomplete, incompletes; + const doclets = e.doclets; for (i = doclets.length - 1; i >= 0; --i) { doclet = doclets[i]; if (doclet.augments) { diff --git a/config/jsdoc/api/plugins/observable.js b/config/jsdoc/api/plugins/observable.js index 99b87e50a0..4622987d07 100644 --- a/config/jsdoc/api/plugins/observable.js +++ b/config/jsdoc/api/plugins/observable.js @@ -1,25 +1,25 @@ -var classes = {}; -var observables = {}; +const classes = {}; +const observables = {}; exports.handlers = { newDoclet: function(e) { - var doclet = e.doclet; + const doclet = e.doclet; if (doclet.kind == 'class') { classes[doclet.longname] = doclet; } }, parseComplete: function(e) { - var doclets = e.doclets; - var cls, doclet, event, i, ii, observable; + const doclets = e.doclets; + let cls, doclet, event, i, ii, observable; for (i = 0, ii = doclets.length - 1; i < ii; ++i) { doclet = doclets[i]; cls = classes[doclet.longname.split('#')[0]]; if (typeof doclet.observable == 'string' && cls) { - var name = doclet.name.replace(/^[sg]et/, ''); + let name = doclet.name.replace(/^[sg]et/, ''); name = name.substr(0, 1).toLowerCase() + name.substr(1); - var key = doclet.longname.split('#')[0] + '#' + name; + const key = doclet.longname.split('#')[0] + '#' + name; doclet.observable = key; if (!observables[key]) { observables[key] = {}; @@ -27,7 +27,7 @@ exports.handlers = { observable = observables[key]; observable.name = name; observable.readonly = typeof observable.readonly == 'boolean' ? - observable.readonly : true; + observable.readonly : true; if (doclet.name.indexOf('get') === 0) { observable.type = doclet.returns[0].type; observable.description = doclet.returns[0].description; diff --git a/config/jsdoc/api/plugins/typedefs.js b/config/jsdoc/api/plugins/typedefs.js index 67fe8ad4df..66227c3c04 100644 --- a/config/jsdoc/api/plugins/typedefs.js +++ b/config/jsdoc/api/plugins/typedefs.js @@ -1,49 +1,27 @@ /* - * Converts olx.js @type annotations into properties of the previous @typedef. * Changes @enum annotations into @typedef. */ -var lastOlxTypedef = null; -var olxTypes = {}; -// names of the olx typenames -var olxTypeNames = []; // types that are undefined or typedefs containing undefined -var undefinedLikes = null; - -function addSubparams(params) { - for (var j = 0, jj = params.length; j < jj; ++j) { - var param = params[j]; - var types = param.type.names; - for (var k = 0, kk = types.length; k < kk; ++k) { - var name = types[k]; - if (name in olxTypes) { - param.subparams = olxTypes[name]; - // TODO addSubparams(param.subparams); - // TODO Do we need to support multiple object literal types per - // param? - break; - } - } - } -} +let undefinedLikes = null; /** - * Changes the description of the param, if it is found to be a required - * option of an olxTypeName. + * Changes the description of the param if it is required. + * @param {Object} doclet The doclet. + * @returns {Object} The modified doclet. */ -function markRequiredIfNeeded(doclet){ - var memberof = doclet.memberof; - // only check doclets that belong to an olxTypeName - if (!memberof || olxTypeNames.indexOf(memberof) == -1) { +function markRequiredIfNeeded(doclet) { + const memberof = doclet.memberof; + if (!memberof) { return doclet; } - var types = doclet.type.names; - var isRequiredParam = true; + const types = doclet.type.names; + let isRequiredParam = true; // iterate over all types that are like-undefined (see above for explanation) - for (var idx = undefinedLikes.length - 1; idx >= 0; idx--) { - var undefinedLike = undefinedLikes[idx]; + for (let idx = undefinedLikes.length - 1; idx >= 0; idx--) { + const undefinedLike = undefinedLikes[idx]; // … if the current types contains a type that is undefined-like, // it is not required. if (types.indexOf(undefinedLike) != -1) { @@ -52,9 +30,9 @@ function markRequiredIfNeeded(doclet){ } if (isRequiredParam) { - var reqSnippet = 'Required.

'; - var endsWithP = /<\/p>$/i; - var description = doclet.description; + const reqSnippet = 'Required.

'; + const endsWithP = /<\/p>$/i; + let description = doclet.description; if (description && endsWithP.test(description)) { description = description.replace(endsWithP, ' ' + reqSnippet); } else if (doclet.description === undefined) { @@ -69,13 +47,14 @@ function markRequiredIfNeeded(doclet){ * Iterates over all doclets and finds the names of types that contain * undefined. Stores the names in the global variable undefinedLikes, so * that e.g. markRequiredIfNeeded can use these. + * @param {Array} doclets The doclets. */ function findTypesLikeUndefined(doclets) { undefinedLikes = ['undefined']; // include type 'undefined' explicitly - for (var i = doclets.length - 1; i >= 0; --i) { - var doclet = doclets[i]; - if(doclet.kind === 'typedef') { - var types = doclet.type.names; + for (let i = doclets.length - 1; i >= 0; --i) { + const doclet = doclets[i]; + if (doclet.kind === 'typedef') { + const types = doclet.type.names; if (types.indexOf('undefined') !== -1) { // the typedef contains 'undefined', so it self is undefinedLike. undefinedLikes.push(doclet.longname); @@ -87,20 +66,8 @@ function findTypesLikeUndefined(doclets) { exports.handlers = { newDoclet: function(e) { - var doclet = e.doclet; - if (doclet.meta.filename == 'olx.js') { - if (doclet.kind == 'typedef') { - lastOlxTypedef = doclet; - olxTypeNames.push(doclet.longname); - olxTypes[doclet.longname] = []; - doclet.properties = []; - } else if (lastOlxTypedef && doclet.memberof == lastOlxTypedef.longname) { - lastOlxTypedef.properties.push(doclet); - olxTypes[lastOlxTypedef.longname].push(doclet); - } else { - lastOlxTypedef = null; - } - } else if (doclet.isEnum) { + const doclet = e.doclet; + if (doclet.isEnum) { // We never export enums, so we document them like typedefs doclet.kind = 'typedef'; delete doclet.isEnum; @@ -108,15 +75,10 @@ exports.handlers = { }, parseComplete: function(e) { - var doclets = e.doclets; + const doclets = e.doclets; findTypesLikeUndefined(doclets); - for (var i = doclets.length - 1; i >= 0; --i) { - var doclet = doclets[i]; - var params = doclet.params; - if (params) { - addSubparams(params); - } - markRequiredIfNeeded(doclet); + for (let i = doclets.length - 1; i >= 0; --i) { + markRequiredIfNeeded(doclets[i]); } } diff --git a/config/jsdoc/api/template/publish.js b/config/jsdoc/api/template/publish.js index c98be1de77..a5d5de68b1 100644 --- a/config/jsdoc/api/template/publish.js +++ b/config/jsdoc/api/template/publish.js @@ -1,152 +1,152 @@ /*global env: true */ -var template = require('jsdoc/lib/jsdoc/template'), - fs = require('jsdoc/lib/jsdoc/fs'), - path = require('jsdoc/lib/jsdoc/path'), - taffy = require('taffydb').taffy, - handle = require('jsdoc/lib/jsdoc/util/error').handle, - helper = require('jsdoc/lib/jsdoc/util/templateHelper'), - _ = require('underscore'), - htmlsafe = helper.htmlsafe, - linkto = helper.linkto, - resolveAuthorLinks = helper.resolveAuthorLinks, - scopeToPunc = helper.scopeToPunc, - hasOwnProp = Object.prototype.hasOwnProperty, - data, - view, - outdir = env.opts.destination; +const template = require('jsdoc/lib/jsdoc/template'); +const fs = require('jsdoc/lib/jsdoc/fs'); +const path = require('jsdoc/lib/jsdoc/path'); +const taffy = require('taffydb').taffy; +const handle = require('jsdoc/lib/jsdoc/util/error').handle; +const helper = require('jsdoc/lib/jsdoc/util/templateHelper'); +const _ = require('underscore'); +const htmlsafe = helper.htmlsafe; +const linkto = helper.linkto; +const resolveAuthorLinks = helper.resolveAuthorLinks; +const hasOwnProp = Object.prototype.hasOwnProperty; +const outdir = env.opts.destination; + +let view; +let data; function find(spec) { - return helper.find(data, spec); + return helper.find(data, spec); } function tutoriallink(tutorial) { - return helper.toTutorial(tutorial, null, { tag: 'em', classname: 'disabled', prefix: 'Tutorial: ' }); + return helper.toTutorial(tutorial, null, {tag: 'em', classname: 'disabled', prefix: 'Tutorial: '}); } function getAncestorLinks(doclet) { - return helper.getAncestorLinks(data, doclet); + return helper.getAncestorLinks(data, doclet); } function hashToLink(doclet, hash) { - if ( !/^(#.+)/.test(hash) ) { return hash; } + if (!/^(#.+)/.test(hash)) { + return hash; + } - var url = helper.createLink(doclet); + let url = helper.createLink(doclet); - url = url.replace(/(#.+|$)/, hash); - return '' + hash + ''; + url = url.replace(/(#.+|$)/, hash); + return '' + hash + ''; } function needsSignature(doclet) { - var needsSig = false; + let needsSig = false; - // function and class definitions always get a signature - if (doclet.kind === 'function' || doclet.kind === 'class') { - needsSig = true; - } + // function and class definitions always get a signature + if (doclet.kind === 'function' || doclet.kind === 'class') { + needsSig = true; + } else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names && + doclet.type.names.length) { // typedefs that contain functions get a signature, too - else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names && - doclet.type.names.length) { - for (var i = 0, l = doclet.type.names.length; i < l; i++) { - if (doclet.type.names[i].toLowerCase() === 'function') { - needsSig = true; - break; - } - } + for (let i = 0, l = doclet.type.names.length; i < l; i++) { + if (doclet.type.names[i].toLowerCase() === 'function') { + needsSig = true; + break; + } } + } - return needsSig; + return needsSig; } function addSignatureParams(f) { - var params = helper.getSignatureParams(f, 'optional'); + const params = helper.getSignatureParams(f, 'optional'); - f.signature = (f.signature || '') + '('+params.join(', ')+')'; + f.signature = (f.signature || '') + '(' + params.join(', ') + ')'; } function addSignatureReturns(f) { - var returnTypes = helper.getSignatureReturns(f); + const returnTypes = helper.getSignatureReturns(f); - f.signature = ''+(f.signature || '') + ''; + f.signature = '' + (f.signature || '') + ''; - if (returnTypes.length) { - f.signature += ''+(returnTypes.length ? '{'+returnTypes.join('|')+'}' : '')+''; - } + if (returnTypes.length) { + f.signature += '' + (returnTypes.length ? '{' + returnTypes.join('|') + '}' : '') + ''; + } } function addSignatureTypes(f) { - var types = helper.getSignatureTypes(f); + const types = helper.getSignatureTypes(f); - f.signature = (f.signature || '') + ''+(types.length? ' :'+types.join('|') : '')+' '; + f.signature = (f.signature || '') + '' + (types.length ? ' :' + types.join('|') : '') + ' '; } function shortenPaths(files, commonPrefix) { - // always use forward slashes - var regexp = new RegExp('\\\\', 'g'); + // always use forward slashes + const regexp = new RegExp('\\\\', 'g'); - Object.keys(files).forEach(function(file) { - files[file].shortened = files[file].resolved.replace(commonPrefix, '') - .replace(regexp, '/'); - }); + Object.keys(files).forEach(function(file) { + files[file].shortened = files[file].resolved.replace(commonPrefix, '') + .replace(regexp, '/'); + }); - return files; + return files; } function resolveSourcePath(filepath) { - return path.resolve(process.cwd(), filepath); + return path.resolve(process.cwd(), filepath); } function getPathFromDoclet(doclet) { - if (!doclet.meta) { - return; - } + if (!doclet.meta) { + return; + } - var filepath = doclet.meta.path && doclet.meta.path !== 'null' ? - doclet.meta.path + '/' + doclet.meta.filename.split(/[\/\\]/).pop() : - doclet.meta.filename; + const filepath = doclet.meta.path && doclet.meta.path !== 'null' ? + doclet.meta.path + '/' + doclet.meta.filename.split(/[\/\\]/).pop() : + doclet.meta.filename; - return filepath; + return filepath; } function generate(title, docs, filename, resolveLinks) { - resolveLinks = resolveLinks === false ? false : true; + resolveLinks = resolveLinks === false ? false : true; - var docData = { - filename: filename, - title: title, - docs: docs, - packageInfo: ( find({kind: 'package'}) || [] ) [0] - }; + const docData = { + filename: filename, + title: title, + docs: docs, + packageInfo: (find({kind: 'package'}) || []) [0] + }; - var outpath = path.join(outdir, filename), - html = view.render('container.tmpl', docData); + const outpath = path.join(outdir, filename); + let html = view.render('container.tmpl', docData); - if (resolveLinks) { - html = helper.resolveLinks(html); // turn {@link foo} into foo - } + if (resolveLinks) { + html = helper.resolveLinks(html); // turn {@link foo} into foo + } - fs.writeFileSync(outpath, html, 'utf8'); + fs.writeFileSync(outpath, html, 'utf8'); } function generateSourceFiles(sourceFiles) { - Object.keys(sourceFiles).forEach(function(file) { - var source; - // links are keyed to the shortened path in each doclet's `meta.filename` property - var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened); - helper.registerLink(sourceFiles[file].shortened, sourceOutfile); + Object.keys(sourceFiles).forEach(function(file) { + let source; + // links are keyed to the shortened path in each doclet's `meta.filename` property + const sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened); + helper.registerLink(sourceFiles[file].shortened, sourceOutfile); - try { - source = { - kind: 'source', - code: helper.htmlsafe( fs.readFileSync(sourceFiles[file].resolved, 'utf8') ) - }; - } - catch(e) { - handle(e); - } + try { + source = { + kind: 'source', + code: helper.htmlsafe(fs.readFileSync(sourceFiles[file].resolved, 'utf8')) + }; + } catch (e) { + handle(e); + } - generate('Source: ' + sourceFiles[file].shortened, [source], sourceOutfile, - false); - }); + generate('Source: ' + sourceFiles[file].shortened, [source], sourceOutfile, + false); + }); } /** @@ -161,346 +161,348 @@ function generateSourceFiles(sourceFiles) { * @param {Array.} modules - The array of module doclets to search. */ function attachModuleSymbols(doclets, modules) { - var symbols = {}; + const symbols = {}; - // build a lookup table - doclets.forEach(function(symbol) { - symbols[symbol.longname] = symbol; - }); + // build a lookup table + doclets.forEach(function(symbol) { + symbols[symbol.longname] = symbol; + }); - return modules.map(function(module) { - if (symbols[module.longname]) { - module.module = symbols[module.longname]; - module.module.name = module.module.name.replace('module:', 'require("') + '")'; - } - }); + modules.forEach(function(module) { + if (symbols[module.longname]) { + module.module = symbols[module.longname]; + module.module.name = module.module.name.replace('module:', 'require("') + '")'; + } + }); } /** * Create the navigation sidebar. * @param {object} members The members that will be used to create the sidebar. - * @param {array} members.classes - * @param {array} members.externals - * @param {array} members.globals - * @param {array} members.mixins - * @param {array} members.modules - * @param {array} members.namespaces - * @param {array} members.tutorials - * @param {array} members.events + * @param {Array} members.classes Classes. + * @param {Array} members.externals Externals. + * @param {Array} members.globals Globals. + * @param {Array} members.mixins Mixins. + * @param {Array} members.modules Modules. + * @param {Array} members.namespaces Namespaces. + * @param {Array} members.tutorials Tutorials. + * @param {Array} members.events Events. * @return {string} The HTML for the navigation sidebar. */ function buildNav(members) { - var nav = []; - // merge namespaces and classes, then sort - var merged = members.namespaces.concat(members.classes); - merged.sort(function (a, b) { - if (a.longname > b.longname) - return 1; - if (a.longname < b.longname) - return -1; - return 0; - }); - _.each(merged, function (v) { - // exclude 'olx' and interfaces from sidebar - if (v.longname.indexOf('olx') !== 0 && v.interface !== true) { - if (v.kind == 'namespace') { - nav.push({ - type: 'namespace', - longname: v.longname, - name: v.name, - members: find({ - kind: 'member', - memberof: v.longname - }), - methods: find({ - kind: 'function', - memberof: v.longname - }), - typedefs: find({ - kind: 'typedef', - memberof: v.longname - }), - events: find({ - kind: 'event', - memberof: v.longname - }) - }); - } - if (v.kind == 'class') { - nav.push({ - type: 'class', - longname: v.longname, - name: v.name, - members: find({ - kind: 'member', - memberof: v.longname - }), - methods: find({ - kind: 'function', - memberof: v.longname - }), - typedefs: find({ - kind: 'typedef', - memberof: v.longname - }), - fires: v.fires, - events: find({ - kind: 'event', - memberof: v.longname - }) - }); - } + const nav = []; + // merge namespaces and classes, then sort + const merged = members.namespaces.concat(members.classes); + merged.sort(function(a, b) { + if (a.longname > b.longname) { + return 1; + } + if (a.longname < b.longname) { + return -1; + } + return 0; + }); + _.each(merged, function(v) { + // exclude interfaces from sidebar + if (v.interface !== true) { + if (v.kind == 'namespace') { + nav.push({ + type: 'namespace', + longname: v.longname, + name: v.name, + members: find({ + kind: 'member', + memberof: v.longname + }), + methods: find({ + kind: 'function', + memberof: v.longname + }), + typedefs: find({ + kind: 'typedef', + memberof: v.longname + }), + events: find({ + kind: 'event', + memberof: v.longname + }) + }); } - }); - return nav; + if (v.kind == 'class') { + nav.push({ + type: 'class', + longname: v.longname, + name: v.name, + members: find({ + kind: 'member', + memberof: v.longname + }), + methods: find({ + kind: 'function', + memberof: v.longname + }), + typedefs: find({ + kind: 'typedef', + memberof: v.longname + }), + fires: v.fires, + events: find({ + kind: 'event', + memberof: v.longname + }) + }); + } + } + }); + return nav; } /** - @param {TAFFY} taffyData See . - @param {object} opts - @param {Tutorial} tutorials + * @param {Object} taffyData See . + * @param {Object} opts Options. + * @param {Object} tutorials Tutorials. */ exports.publish = function(taffyData, opts, tutorials) { - data = taffyData; + data = taffyData; - var conf = env.conf.templates || {}; - conf['default'] = conf['default'] || {}; + const conf = env.conf.templates || {}; + conf['default'] = conf['default'] || {}; - var templatePath = opts.template; - view = new template.Template(templatePath + '/tmpl'); + const templatePath = opts.template; + view = new template.Template(templatePath + '/tmpl'); - // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness - // doesn't try to hand them out later - var indexUrl = helper.getUniqueFilename('index'); - // don't call registerLink() on this one! 'index' is also a valid longname + // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness + // doesn't try to hand them out later + const indexUrl = helper.getUniqueFilename('index'); + // don't call registerLink() on this one! 'index' is also a valid longname - var globalUrl = helper.getUniqueFilename('global'); - helper.registerLink('global', globalUrl); + const globalUrl = helper.getUniqueFilename('global'); + helper.registerLink('global', globalUrl); - // set up templating - view.layout = 'layout.tmpl'; + // set up templating + view.layout = 'layout.tmpl'; - // set up tutorials for helper - helper.setTutorials(tutorials); + // set up tutorials for helper + helper.setTutorials(tutorials); - data = helper.prune(data); - data.sort('longname, version, since'); - helper.addEventListeners(data); + data = helper.prune(data); + data.sort('longname, version, since'); + helper.addEventListeners(data); - var sourceFiles = {}; - var sourceFilePaths = []; - data().each(function(doclet) { - doclet.attribs = ''; + let sourceFiles = {}; + const sourceFilePaths = []; + data().each(function(doclet) { + doclet.attribs = ''; - if (doclet.examples) { - doclet.examples = doclet.examples.map(function(example) { - var caption, code; + if (doclet.examples) { + doclet.examples = doclet.examples.map(function(example) { + let caption, code; - if (example.match(/^\s*([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) { - caption = RegExp.$1; - code = RegExp.$3; - } - - return { - caption: caption || '', - code: code || example - }; - }); - } - if (doclet.see) { - doclet.see.forEach(function(seeItem, i) { - doclet.see[i] = hashToLink(doclet, seeItem); - }); + if (example.match(/^\s*([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) { + caption = RegExp.$1; + code = RegExp.$3; } - // build a list of source files - var sourcePath; - var resolvedSourcePath; - if (doclet.meta) { - sourcePath = getPathFromDoclet(doclet); - resolvedSourcePath = resolveSourcePath(sourcePath); - sourceFiles[sourcePath] = { - resolved: resolvedSourcePath, - shortened: null - }; - sourceFilePaths.push(resolvedSourcePath); - } - }); + return { + caption: caption || '', + code: code || example + }; + }); + } + if (doclet.see) { + doclet.see.forEach(function(seeItem, i) { + doclet.see[i] = hashToLink(doclet, seeItem); + }); + } - fs.mkPath(outdir); + // build a list of source files + let sourcePath; + let resolvedSourcePath; + if (doclet.meta) { + sourcePath = getPathFromDoclet(doclet); + resolvedSourcePath = resolveSourcePath(sourcePath); + sourceFiles[sourcePath] = { + resolved: resolvedSourcePath, + shortened: null + }; + sourceFilePaths.push(resolvedSourcePath); + } + }); - // copy the template's static files to outdir - var fromDir = path.join(templatePath, 'static'); - var staticFiles = fs.ls(fromDir, 3); + fs.mkPath(outdir); - staticFiles.forEach(function(fileName) { - var toDir = fs.toDir( fileName.replace(fromDir, outdir) ); + // copy the template's static files to outdir + const fromDir = path.join(templatePath, 'static'); + const staticFiles = fs.ls(fromDir, 3); + + staticFiles.forEach(function(fileName) { + const toDir = fs.toDir(fileName.replace(fromDir, outdir)); + fs.mkPath(toDir); + fs.copyFileSync(fileName, toDir); + }); + + // copy user-specified static files to outdir + let staticFilePaths; + let staticFileFilter; + let staticFileScanner; + if (conf['default'].staticFiles) { + staticFilePaths = conf['default'].staticFiles.paths || []; + staticFileFilter = new (require('jsdoc/lib/jsdoc/src/filter')).Filter(conf['default'].staticFiles); + staticFileScanner = new (require('jsdoc/lib/jsdoc/src/scanner')).Scanner(); + + staticFilePaths.forEach(function(filePath) { + const extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter); + + extraStaticFiles.forEach(function(fileName) { + const sourcePath = fs.statSync(filePath).isDirectory() ? filePath : + path.dirname(filePath); + const toDir = fs.toDir(fileName.replace(sourcePath, outdir)); fs.mkPath(toDir); fs.copyFileSync(fileName, toDir); + }); }); + } - // copy user-specified static files to outdir - var staticFilePaths; - var staticFileFilter; - var staticFileScanner; - if (conf['default'].staticFiles) { - staticFilePaths = conf['default'].staticFiles.paths || []; - staticFileFilter = new (require('jsdoc/lib/jsdoc/src/filter')).Filter(conf['default'].staticFiles); - staticFileScanner = new (require('jsdoc/lib/jsdoc/src/scanner')).Scanner(); + if (sourceFilePaths.length) { + sourceFiles = shortenPaths(sourceFiles, path.commonPrefix(sourceFilePaths)); + } + data().each(function(doclet) { + const url = helper.createLink(doclet); + helper.registerLink(doclet.longname, url); - staticFilePaths.forEach(function(filePath) { - var extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter); + // replace the filename with a shortened version of the full path + let docletPath; + if (doclet.meta) { + docletPath = getPathFromDoclet(doclet); + docletPath = sourceFiles[docletPath].shortened; + if (docletPath) { + doclet.meta.filename = docletPath; + } + } + }); - extraStaticFiles.forEach(function(fileName) { - var sourcePath = fs.statSync(filePath).isDirectory() ? filePath : - path.dirname(filePath); - var toDir = fs.toDir( fileName.replace(sourcePath, outdir) ); - fs.mkPath(toDir); - fs.copyFileSync(fileName, toDir); - }); - }); + data().each(function(doclet) { + const url = helper.longnameToUrl[doclet.longname]; + + if (url.indexOf('#') > -1) { + doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop(); + } else { + doclet.id = doclet.name; } - if (sourceFilePaths.length) { - sourceFiles = shortenPaths( sourceFiles, path.commonPrefix(sourceFilePaths) ); + if (needsSignature(doclet)) { + addSignatureParams(doclet); + addSignatureReturns(doclet); } - data().each(function(doclet) { - var url = helper.createLink(doclet); - helper.registerLink(doclet.longname, url); + }); - // replace the filename with a shortened version of the full path - var docletPath; - if (doclet.meta) { - docletPath = getPathFromDoclet(doclet); - docletPath = sourceFiles[docletPath].shortened; - if (docletPath) { - doclet.meta.filename = docletPath; - } - } - }); + // do this after the urls have all been generated + data().each(function(doclet) { + doclet.ancestors = getAncestorLinks(doclet); - data().each(function(doclet) { - var url = helper.longnameToUrl[doclet.longname]; - - if (url.indexOf('#') > -1) { - doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop(); - } - else { - doclet.id = doclet.name; - } - - if ( needsSignature(doclet) ) { - addSignatureParams(doclet); - addSignatureReturns(doclet); - } - }); - - // do this after the urls have all been generated - data().each(function(doclet) { - doclet.ancestors = getAncestorLinks(doclet); - - if (doclet.kind === 'member') { - addSignatureTypes(doclet); - } - - if (doclet.kind === 'constant') { - addSignatureTypes(doclet); - doclet.kind = 'member'; - } - }); - - var members = helper.getMembers(data); - members.tutorials = tutorials.children; - - // add template helpers - view.find = find; - view.linkto = linkto; - view.resolveAuthorLinks = resolveAuthorLinks; - view.tutoriallink = tutoriallink; - view.htmlsafe = htmlsafe; - view.members = members; //@davidshimjs: To make navigation for customizing - - // once for all - view.nav = buildNav(members); - attachModuleSymbols( find({ kind: ['class', 'function'], longname: {left: 'module:'} }), - members.modules ); - - // only output pretty-printed source files if requested; do this before generating any other - // pages, so the other pages can link to the source files - if (conf['default'].outputSourceFiles) { - generateSourceFiles(sourceFiles); + if (doclet.kind === 'member') { + addSignatureTypes(doclet); } - if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); } + if (doclet.kind === 'constant') { + addSignatureTypes(doclet); + doclet.kind = 'member'; + } + }); - // index page displays information from package.json and lists files - var files = find({kind: 'file'}); + const members = helper.getMembers(data); + members.tutorials = tutorials.children; - generate('Index', - [{kind: 'mainpage', readme: opts.readme, longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'}].concat(files), + // add template helpers + view.find = find; + view.linkto = linkto; + view.resolveAuthorLinks = resolveAuthorLinks; + view.tutoriallink = tutoriallink; + view.htmlsafe = htmlsafe; + view.members = members; //@davidshimjs: To make navigation for customizing + + // once for all + view.nav = buildNav(members); + attachModuleSymbols(find({kind: ['class', 'function'], longname: {left: 'module:'}}), + members.modules); + + // only output pretty-printed source files if requested; do this before generating any other + // pages, so the other pages can link to the source files + if (conf['default'].outputSourceFiles) { + generateSourceFiles(sourceFiles); + } + + if (members.globals.length) { + generate('Global', [{kind: 'globalobj'}], globalUrl); + } + + // index page displays information from package.json and lists files + const files = find({kind: 'file'}); + + generate('Index', + [{kind: 'mainpage', readme: opts.readme, longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'}].concat(files), indexUrl); - // set up the lists that we'll use to generate pages - var classes = taffy(members.classes); - var modules = taffy(members.modules); - var namespaces = taffy(members.namespaces); - var mixins = taffy(members.mixins); - var externals = taffy(members.externals); + // set up the lists that we'll use to generate pages + const classes = taffy(members.classes); + const modules = taffy(members.modules); + const namespaces = taffy(members.namespaces); + const mixins = taffy(members.mixins); + const externals = taffy(members.externals); - for (var longname in helper.longnameToUrl) { - if ( hasOwnProp.call(helper.longnameToUrl, longname) ) { - var myClasses = helper.find(classes, {longname: longname}); - if (myClasses.length) { - generate('Class: ' + myClasses[0].name, myClasses, helper.longnameToUrl[longname]); - } + for (const longname in helper.longnameToUrl) { + if (hasOwnProp.call(helper.longnameToUrl, longname)) { + const myClasses = helper.find(classes, {longname: longname}); + if (myClasses.length) { + generate('Class: ' + myClasses[0].name, myClasses, helper.longnameToUrl[longname]); + } - var myModules = helper.find(modules, {longname: longname}); - if (myModules.length) { - generate('Module: ' + myModules[0].name, myModules, helper.longnameToUrl[longname]); - } + const myModules = helper.find(modules, {longname: longname}); + if (myModules.length) { + generate('Module: ' + myModules[0].name, myModules, helper.longnameToUrl[longname]); + } - var myNamespaces = helper.find(namespaces, {longname: longname}); - if (myNamespaces.length) { - generate('Namespace: ' + myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname]); - } + const myNamespaces = helper.find(namespaces, {longname: longname}); + if (myNamespaces.length) { + generate('Namespace: ' + myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname]); + } - var myMixins = helper.find(mixins, {longname: longname}); - if (myMixins.length) { - generate('Mixin: ' + myMixins[0].name, myMixins, helper.longnameToUrl[longname]); - } + const myMixins = helper.find(mixins, {longname: longname}); + if (myMixins.length) { + generate('Mixin: ' + myMixins[0].name, myMixins, helper.longnameToUrl[longname]); + } - var myExternals = helper.find(externals, {longname: longname}); - if (myExternals.length) { - generate('External: ' + myExternals[0].name, myExternals, helper.longnameToUrl[longname]); - } - } + const myExternals = helper.find(externals, {longname: longname}); + if (myExternals.length) { + generate('External: ' + myExternals[0].name, myExternals, helper.longnameToUrl[longname]); + } } + } - // TODO: move the tutorial functions to templateHelper.js - function generateTutorial(title, tutorial, filename) { - var tutorialData = { - title: title, - header: tutorial.title, - content: tutorial.parse(), - children: tutorial.children - }; + // TODO: move the tutorial functions to templateHelper.js + function generateTutorial(title, tutorial, filename) { + const tutorialData = { + title: title, + header: tutorial.title, + content: tutorial.parse(), + children: tutorial.children + }; - var tutorialPath = path.join(outdir, filename), - html = view.render('tutorial.tmpl', tutorialData); + let html = view.render('tutorial.tmpl', tutorialData); + // yes, you can use {@link} in tutorials too! + html = helper.resolveLinks(html); // turn {@link foo} into foo - // yes, you can use {@link} in tutorials too! - html = helper.resolveLinks(html); // turn {@link foo} into foo + const tutorialPath = path.join(outdir, filename); + fs.writeFileSync(tutorialPath, html, 'utf8'); + } - fs.writeFileSync(tutorialPath, html, 'utf8'); - } - - // tutorials can have only one parent so there is no risk for loops - function saveChildren(node) { - node.children.forEach(function(child) { - generateTutorial('Tutorial: ' + child.title, child, helper.tutorialToUrl(child.name)); - saveChildren(child); - }); - } - saveChildren(tutorials); + // tutorials can have only one parent so there is no risk for loops + function saveChildren(node) { + node.children.forEach(function(child) { + generateTutorial('Tutorial: ' + child.title, child, helper.tutorialToUrl(child.name)); + saveChildren(child); + }); + } + saveChildren(tutorials); }; diff --git a/config/jsdoc/info/define-plugin.js b/config/jsdoc/info/define-plugin.js index 57c4e355f2..78634499ba 100644 --- a/config/jsdoc/info/define-plugin.js +++ b/config/jsdoc/info/define-plugin.js @@ -6,7 +6,7 @@ */ -var DEFAULT_VALUE = /default\s+is\s+`?(true|false)`?/i; +const DEFAULT_VALUE = /default\s+is\s+`?(true|false)`?/i; /** @@ -19,9 +19,9 @@ exports.defineTags = function(dictionary) { canHaveType: true, mustHaveValue: true, onTagged: function(doclet, tag) { - var types = tag.value.type.names; + const types = tag.value.type.names; if (types.length === 1 && types[0] === 'boolean') { - var match = tag.value.description.match(DEFAULT_VALUE); + const match = tag.value.description.match(DEFAULT_VALUE); if (match) { doclet.define = { default: match[1] === 'true' diff --git a/config/jsdoc/info/publish.js b/config/jsdoc/info/publish.js index e1d514265c..bc01c31f89 100644 --- a/config/jsdoc/info/publish.js +++ b/config/jsdoc/info/publish.js @@ -22,8 +22,7 @@ exports.publish = function(data, opts) { return types; } - // get all doclets with the "api" property or define (excluding events) or - // with olx namespace + // get all doclets with the "api" property or define (excluding events) const classes = {}; const docs = data( [ @@ -61,24 +60,7 @@ exports.publish = function(data, opts) { return include; }).forEach(function(doc) { const isExterns = (/[\\\/]externs$/).test(doc.meta.path); - if (isExterns && doc.longname.indexOf('olx.') === 0) { - if (doc.kind == 'typedef') { - typedefs.push({ - name: doc.longname, - types: ['{}'] - }); - } else { - const typedef = typedefs[typedefs.length - 1]; - if (!typedef) { - throw new Error(`Expected to see a typedef before ${doc.longname} at ${doc.meta.filename}:${doc.meta.lineno}`); - } - const type = typedef.types[0]; - typedef.types[0] = type - .replace(/\}$/, ', ' + doc.longname.split('#')[1] + - ': (' + getTypes(doc.type.names).join('|') + ')}') - .replace('{, ', '{'); - } - } else if (doc.define) { + if (doc.define) { defines.push({ name: doc.longname, description: doc.description, diff --git a/config/jsdoc/info/virtual-plugin.js b/config/jsdoc/info/virtual-plugin.js index 52cc894cef..9209724c27 100644 --- a/config/jsdoc/info/virtual-plugin.js +++ b/config/jsdoc/info/virtual-plugin.js @@ -4,7 +4,7 @@ */ exports.defineTags = function(dictionary) { - var classTag = dictionary.lookUp('class'); + const classTag = dictionary.lookUp('class'); dictionary.defineTag('interface', { mustHaveValue: false, onTagged: function(doclet, tag) { diff --git a/doc/tutorials/closure.md b/doc/tutorials/closure.md index f1c56d62ac..500c6e2ccc 100644 --- a/doc/tutorials/closure.md +++ b/doc/tutorials/closure.md @@ -176,8 +176,6 @@ The minimum config file looks like this: "ol.ENABLE_WEBGL=false" ], "js": [ - "node_modules/openlayers/src/ol/typedefs.js", - "node_modules/openlayers/externs/olx.js", "node_modules/openlayers/externs/oli.js" ], "extra_annotation_name": [ @@ -228,8 +226,6 @@ Here is a version of `config.json` with more compilation checks enabled: "ol.ENABLE_WEBGL=false" ], "js": [ - "node_modules/openlayers/src/ol/typedefs.js", - "node_modules/openlayers/externs/olx.js", "node_modules/openlayers/externs/oli.js" ], "jscomp_error": [ diff --git a/doc/tutorials/custom-builds.md b/doc/tutorials/custom-builds.md index 13b09d8ee3..adc3195811 100644 --- a/doc/tutorials/custom-builds.md +++ b/doc/tutorials/custom-builds.md @@ -56,7 +56,6 @@ Creating a custom build requires writing a build configuration file. The format "externs/esrijson.js", "externs/geojson.js", "externs/oli.js", - "externs/olx.js", "externs/proj4js.js", "externs/tilejson.js", "externs/topojson.js" @@ -169,8 +168,6 @@ and re-run the build script. The build size should now be smaller. The Closure documentation explains that "externs" are for external names used in the code being compiled. The compiler includes externs for built-ins such as `document`. The `externs` directory of the OpenLayers code includes files for all those used in some part of the library. For example, if you use Bing Maps, you should include the Bing externs file in the `externs` section of the config file. -`oli.js` and `olx.js` are externs files for the OpenLayers API. For example `olx.js` includes extern definitions for OpenLayers's constructor options. `closure-compiler.js` fixes any issues that may arise with a specific compiler version. You should always use these three files as externs when creating custom builds. - ### Other compiler options There are a couple of other compiler options in the config file above. `manage_closure_dependencies` and `rewrite_polyfills` should always be used. @@ -208,7 +205,6 @@ Now let's try a more complicated example: [`heatmaps-earthquakes`](https://openl "externs/closure-compiler.js", "externs/esrijson.js", "externs/geojson.js", - "externs/olx.js", "externs/oli.js", "externs/proj4js.js", "externs/tilejson.js", diff --git a/examples/custom-interactions.js b/examples/custom-interactions.js index b051076246..0bffd948ed 100644 --- a/examples/custom-interactions.js +++ b/examples/custom-interactions.js @@ -157,7 +157,7 @@ const map = new Map({ features: [pointFeature, lineFeature, polygonFeature] }), style: new Style({ - image: new Icon(/** @type {olx.style.IconOptions} */ ({ + image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({ anchor: [0.5, 46], anchorXUnits: 'fraction', anchorYUnits: 'pixels', diff --git a/examples/icon-color.js b/examples/icon-color.js index edb046729f..6fe97ff803 100644 --- a/examples/icon-color.js +++ b/examples/icon-color.js @@ -24,7 +24,7 @@ const madrid = new Feature({ }); rome.setStyle(new Style({ - image: new Icon(/** @type {olx.style.IconOptions} */ ({ + image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({ color: '#8959A8', crossOrigin: 'anonymous', src: 'data/dot.png' @@ -32,7 +32,7 @@ rome.setStyle(new Style({ })); london.setStyle(new Style({ - image: new Icon(/** @type {olx.style.IconOptions} */ ({ + image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({ color: '#4271AE', crossOrigin: 'anonymous', src: 'data/dot.png' @@ -40,7 +40,7 @@ london.setStyle(new Style({ })); madrid.setStyle(new Style({ - image: new Icon(/** @type {olx.style.IconOptions} */ ({ + image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({ color: [113, 140, 0], crossOrigin: 'anonymous', src: 'data/dot.png' diff --git a/examples/icon-negative.js b/examples/icon-negative.js index e1c2482f9d..94f7ea3633 100644 --- a/examples/icon-negative.js +++ b/examples/icon-negative.js @@ -13,7 +13,7 @@ import Style from '../src/ol/style/Style.js'; function createStyle(src, img) { return new Style({ - image: new Icon(/** @type {olx.style.IconOptions} */ ({ + image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({ anchor: [0.5, 0.96], crossOrigin: 'anonymous', src: src, diff --git a/examples/icon.js b/examples/icon.js index 1367939e29..934a164376 100644 --- a/examples/icon.js +++ b/examples/icon.js @@ -19,7 +19,7 @@ const iconFeature = new Feature({ }); const iconStyle = new Style({ - image: new Icon(/** @type {olx.style.IconOptions} */ ({ + image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({ anchor: [0.5, 46], anchorXUnits: 'fraction', anchorYUnits: 'pixels', diff --git a/examples/reprojection.js b/examples/reprojection.js index 20ba191795..b7cf4d42ac 100644 --- a/examples/reprojection.js +++ b/examples/reprojection.js @@ -112,7 +112,7 @@ fetch(url).then(function(response) { options.projection = 'EPSG:3413'; options.wrapX = false; layers['wmts3413'] = new TileLayer({ - source: new WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) + source: new WMTS(/** @type {!module:ol/source/WMTS~Options} */ (options)) }); }); diff --git a/examples/wmts-hidpi.js b/examples/wmts-hidpi.js index 4371df9458..d9a0566a8b 100644 --- a/examples/wmts-hidpi.js +++ b/examples/wmts-hidpi.js @@ -34,6 +34,6 @@ fetch(capabilitiesUrl).then(function(response) { }); options.tilePixelRatio = tilePixelRatio; map.addLayer(new TileLayer({ - source: new WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) + source: new WMTS(/** @type {!module:ol/source/WMTS~Options} */ (options)) })); }); diff --git a/examples/wmts-layer-from-capabilities.js b/examples/wmts-layer-from-capabilities.js index d7c4cfa48f..669e7e534f 100644 --- a/examples/wmts-layer-from-capabilities.js +++ b/examples/wmts-layer-from-capabilities.js @@ -25,7 +25,7 @@ fetch('data/WMTSCapabilities.xml').then(function(response) { }), new TileLayer({ opacity: 1, - source: new WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) + source: new WMTS(/** @type {!module:ol/source/WMTS~Options} */ (options)) }) ], target: 'map', diff --git a/externs/example.js b/externs/example.js index 03a674c048..3731143941 100644 --- a/externs/example.js +++ b/externs/example.js @@ -1,8 +1,7 @@ /** * @type {Object} */ -var common; - +let common; /** @@ -13,12 +12,12 @@ common.getRendererFromQueryString = function(opt_default) {}; /** - * @param {function(new:ol.style.Style, olx.style.StyleOptions=)} Style Style constructor. - * @param {function(new:ol.style.Fill, olx.style.FillOptions=)} Fill Fill constructor. - * @param {function(new:ol.style.Stroke, olx.style.StrokeOptions=)} Stroke Stroke constructor. - * @param {function(new:ol.style.Icon, olx.style.IconOptions=)} Icon Icon constructor. - * @param {function(new:ol.style.Text, olx.style.TextOptions=)} Text Text constructor. + * @param {function(new:ol.style.Style, module:ol/style/Style~Options=)} Style Style constructor. + * @param {function(new:ol.style.Fill, module:ol/style/Fill~Options=)} Fill Fill constructor. + * @param {function(new:ol.style.Stroke, module:ol/style/Stroke~Options=)} Stroke Stroke constructor. + * @param {function(new:ol.style.Icon, module:ol/style/Icon~Options=)} Icon Icon constructor. + * @param {function(new:ol.style.Text, module:ol/style/Text~Options=)} Text Text constructor. * @return {function((module:ol/Feature~Feature|ol.render.Feature), number): * Array.} */ -var createMapboxStreetsV6Style = function(Style, Fill, Stroke, Icon, Text) {}; +const createMapboxStreetsV6Style = function(Style, Fill, Stroke, Icon, Text) {}; diff --git a/externs/oli.js b/externs/oli.js index e263baf07b..5ff51a5262 100644 --- a/externs/oli.js +++ b/externs/oli.js @@ -6,7 +6,7 @@ /** * @type {Object} */ -var oli; +let oli; /** @@ -187,7 +187,7 @@ oli.MapEvent.prototype.map; /** - * @type {olx.FrameState} + * @type {module:ol/PluggableMap~FrameState} */ oli.MapEvent.prototype.frameState; @@ -302,7 +302,7 @@ oli.render.Event.prototype.context; /** - * @type {olx.FrameState|undefined} + * @type {module:ol/PluggableMap~FrameState|undefined} */ oli.render.Event.prototype.frameState; diff --git a/externs/olx.js b/externs/olx.js deleted file mode 100644 index 5f4c83b8e3..0000000000 --- a/externs/olx.js +++ /dev/null @@ -1,6 +0,0 @@ - -/** - * @type {Object} - */ -let olx; - diff --git a/externs/readme.md b/externs/readme.md index a05104ef2e..579c782c98 100644 --- a/externs/readme.md +++ b/externs/readme.md @@ -2,9 +2,9 @@ This directory contains externs files, which tell the Closure compiler about symbols and properties that it should not rename. -## oli.js and olx.js +## oli.js -These two files are special externs that belong to OpenLayers, and this document explains their purpose and how they are used. +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 @@ -82,39 +82,3 @@ ol.control.Control.prototype.setMap = function(map) { }; ``` See Custom controls example for an example of how this can be used. - -### Export object literals - -Object literals cannot be exported like classes. To make sure that their properties do not get renamed, they go in `olx.js`: -```js -/** - * @typedef {{element: (Element|undefined), - * target: (Element|string|undefined)}} - * @api - */ -olx.control.ControlOptions; - -/** - * The element is the control's container element. This only needs to be - * specified if you're developing a custom control. - * @type {Element|undefined} - */ -olx.control.ControlOptions.prototype.element; - -/** - * Specify a target if you want the control to be rendered outside of the map's - * viewport. - * @type {Element|string|undefined} - */ -olx.control.ControlOptions.prototype.target; -``` -In the source code, the name used for the typedef is used as type whenever this object literal is expected: -```js -/** - * ... - * @param {olx.control.ControlOptions} options Control options. - */ -ol.control.Control = function(options) { - // ... -}; -``` diff --git a/externs/xol.js b/externs/xol.js deleted file mode 100644 index a3e12c7ff7..0000000000 --- a/externs/xol.js +++ /dev/null @@ -1,927 +0,0 @@ - -/** - * @typedef {Object} render_State - * @property {CanvasRenderingContext2D} context Canvas context that the layer is being rendered to. - * @property {number} pixelRatio Pixel ratio used by the layer renderer. - * @property {number} resolution Resolution that the render batch was created and optimized for. This is - * not the view's resolution that is being rendered. - * @property {number} rotation Rotation of the rendered layer in radians. - */ - - -/** - * @typedef {Object} source_BingMapsOptions - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {boolean|undefined} hidpi If `true` hidpi tiles will be requested. Default is `false`. - * @property {string|undefined} culture Culture code. Default is `en-us`. - * @property {string} key Bing Maps API key. Get yours at http://www.bingmapsportal.com/. - * @property {string} imagerySet Type of imagery. - * @property {number|undefined} maxZoom Max zoom. Default is what's advertized by the BingMaps service (`21` - * currently). - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. Default is `true`. - * @property {number|undefined} transition Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - */ - - -/** - * @typedef {Object} source_ClusterOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} distance Minimum distance in pixels between clusters. Default is `20`. - * @property {ol.Extent|undefined} extent Extent. - * @property {undefined|function(module:ol/Feature~Feature):module:ol/geom/Point~Point} geometryFunction Function that takes an {@link module:ol/Feature~Feature} as argument and returns an - * {@link module:ol/geom/Point~Point} as cluster calculation point for the feature. When a - * feature should not be considered for clustering, the function should return - * `null`. The default, which works when the underyling source contains point - * features only, is - * ```js - * function(feature) { - * return feature.getGeometry(); - * } - * ``` - * See {@link module:ol/geom/Polygon~Polygon#getInteriorPoint} for a way to get a cluster - * calculation point for polygons. - * @property {ol.format.Feature|undefined} format Format. - * @property {ol.ProjectionLike} projection Projection. - * @property {ol.source.Vector} source Source. - * @property {boolean|undefined} wrapX WrapX. Default is true - */ - - -/** - * @typedef {Object} source_TileUTFGridOptions - * @property {boolean|undefined} jsonp Use JSONP with callback to load the TileJSON. Useful when the server - * does not support CORS. Default is `false`. - * @property {boolean|undefined} preemptive If `true` the TileUTFGrid source loads the tiles based on their "visibility". - * This improves the speed of response, but increases traffic. - * Note that if set to `false`, you need to pass `true` as `opt_request` - * to the `forDataAtCoordinateAndResolution` method otherwise no data - * will ever be loaded. - * Default is `true`. - * @property {TileJSON|undefined} tileJSON TileJSON configuration for this source. If not provided, `url` must be - * configured. - * @property {string|undefined} url TileJSON endpoint that provides the configuration for this source. Request - * will be made through JSONP. If not provided, `tileJSON` must be configured. - */ - - -/** - * @typedef {Object} source_TileImageOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {boolean|undefined} opaque Whether the layer is opaque. - * @property {ol.ProjectionLike} projection Projection. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {ol.source.State|undefined} state Source state. - * @property {function(new: ol.ImageTile, ol.TileCoord, ol.TileState, string, ?string, - ol.TileLoadFunctionType)|undefined} - tileClass Class used to instantiate image tiles. Default is {@link ol.ImageTile}. - * @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {number|undefined} tilePixelRatio The pixel ratio used by the tile service. For example, if the tile - * service advertizes 256px by 256px tiles but actually sends 512px - * by 512px images (for retina/hidpi devices) then `tilePixelRatio` - * should be set to `2`. Default is `1`. - * @property {ol.TileUrlFunctionType|undefined} tileUrlFunction Optional function to get tile URL given a tile coordinate and the projection. - * @property {string|undefined} url URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. - * A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be - * used instead of defining each one separately in the `urls` option. - * @property {Array.|undefined} urls An array of URL templates. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. The default, `undefined`, is to - * request out-of-bounds tiles from the server. When set to `false`, only one - * world will be rendered. When set to `true`, tiles will be requested for one - * world only, but they will be wrapped horizontally to render multiple worlds. - * @property {number|undefined} transition Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - */ - - -/** - * @typedef {Object} source_VectorTileOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} cacheSize Cache size. Default is `128`. - * @property {ol.format.Feature|undefined} format Feature format for tiles. Used and required by the default - * `tileLoadFunction`. - * @property {boolean|undefined} overlaps This source may have overlapping geometries. Default is `true`. Setting this - * to `false` (e.g. for sources with polygons that represent administrative - * boundaries or TopoJSON sources) allows the renderer to optimise fill and - * stroke operations. - * @property {ol.ProjectionLike} projection Projection. - * @property {ol.source.State|undefined} state Source state. - * @property {function(new: ol.VectorTile, ol.TileCoord, ol.TileState, string, ol.format.Feature, - ol.TileLoadFunctionType)|undefined} - tileClass Class used to instantiate vector tiles. Default is {@link ol.VectorTile}. - * @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. Could look like this: - * ```js - * function(tile, url) { - * tile.setLoader(function() { - * var data = // ... fetch data - * var format = tile.getFormat(); - * tile.setFeatures(format.readFeatures(data, { - * // uncomment the line below for ol.format.MVT only - * extent: tile.getExtent(), - * featureProjection: map.getView().getProjection() - * })); - * }; - * }); - * ``` - * @property {ol.TileUrlFunctionType|undefined} tileUrlFunction Optional function to get tile URL given a tile coordinate and the projection. - * @property {string|undefined} url URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. - * A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be - * used instead of defining each one separately in the `urls` option. - * @property {Array.|undefined} urls An array of URL templates. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. When set to `false`, only one world - * will be rendered. When set to `true`, tiles will be wrapped horizontally to - * render multiple worlds. Default is `true`. - * @property {number|undefined} transition Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - */ - - -/** - * @typedef {Object} source_ImageMapGuideOptions - * @property {string|undefined} url The mapagent url. - * @property {number|undefined} displayDpi The display resolution. Default is `96`. - * @property {number|undefined} metersPerUnit The meters-per-unit value. Default is `1`. - * @property {boolean|undefined} hidpi Use the `ol.Map#pixelRatio` value when requesting the image from the remote - * server. Default is `true`. - * @property {boolean|undefined} useOverlay If `true`, will use `GETDYNAMICMAPOVERLAYIMAGE`. - * @property {ol.ProjectionLike} projection Projection. - * @property {number|undefined} ratio Ratio. `1` means image requests are the size of the map viewport, `2` means - * twice the width and height of the map viewport, and so on. Must be `1` or - * higher. Default is `1`. - * @property {Array.|undefined} resolutions Resolutions. If specified, requests will be made for these resolutions only. - * @property {ol.ImageLoadFunctionType|undefined} imageLoadFunction Optional function to load an image given a URL. - * @property {Object|undefined} params Additional parameters. - */ - - -/** - * @typedef {Object} source_MapQuestOptions - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {string} layer Layer. Possible values are `osm`, `sat`, and `hyb`. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {string|undefined} url URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. - */ - - -/** - * @typedef {Object} source_TileDebugOptions - * @property {ol.ProjectionLike} projection Projection. - * @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. Default is `true`. - */ - - -/** - * @typedef {Object} source_OSMOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * - * Default is `anonymous`. - * @property {number|undefined} maxZoom Max zoom. Default is `19`. - * @property {boolean|undefined} opaque Whether the layer is opaque. Default is `true`. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {string|undefined} url URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. - * Default is `https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png`. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. Default is `true`. - */ - - -/** - * @typedef {Object} source_ImageArcGISRestOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {boolean|undefined} hidpi Use the `ol.Map#pixelRatio` value when requesting the image from the remote - * server. Default is `true`. - * @property {ol.ImageLoadFunctionType|undefined} imageLoadFunction Optional function to load an image given a URL. - * @property {Object.|undefined} params ArcGIS Rest parameters. This field is optional. Service defaults will be - * used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is `IMAGE` by - * default. `TRANSPARENT` is `true` by default. `BBOX, `SIZE`, `BBOXSR`, - * and `IMAGESR` will be set dynamically. Set `LAYERS` to - * override the default service layer visibility. See - * {@link http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Map/02r3000000v7000000/} - * for further reference. - * @property {ol.ProjectionLike} projection Projection. - * @property {number|undefined} ratio Ratio. `1` means image requests are the size of the map viewport, `2` means - * twice the size of the map viewport, and so on. Default is `1.5`. - * @property {Array.|undefined} resolutions Resolutions. If specified, requests will be made for these resolutions only. - * @property {string|undefined} url ArcGIS Rest service URL for a Map Service or Image Service. The - * url should include /MapServer or /ImageServer. - */ - - -/** - * @typedef {Object} source_ImageCanvasOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {ol.CanvasFunctionType} canvasFunction Canvas function. The function returning the canvas element used by the source - * as an image. The arguments passed to the function are: `{ol.Extent}` the - * image extent, `{number}` the image resolution, `{number}` the device pixel - * ratio, `{ol.Size}` the image size, and `{module:ol/proj/Projection~Projection}` the image - * projection. The canvas returned by this function is cached by the source. If - * the value returned by the function is later changed then - * `dispatchChangeEvent` should be called on the source for the source to - * invalidate the current cached image. - * @property {ol.ProjectionLike} projection Projection. - * @property {number|undefined} ratio Ratio. 1 means canvases are the size of the map viewport, 2 means twice the - * width and height of the map viewport, and so on. Must be `1` or higher. - * Default is `1.5`. - * @property {Array.|undefined} resolutions Resolutions. If specified, new canvases will be created for these resolutions - * only. - * @property {ol.source.State|undefined} state Source state. - */ - - -/** - * @typedef {Object} source_RasterOptions - * @property {Array.} sources Input sources. - * @property {ol.RasterOperation|undefined} operation Raster operation. The operation will be called with data from input sources - * and the output will be assigned to the raster source. - * @property {Object|undefined} lib Functions that will be made available to operations run in a worker. - * @property {number|undefined} threads By default, operations will be run in a single worker thread. To avoid using - * workers altogether, set `threads: 0`. For pixel operations, operations can - * be run in multiple worker threads. Note that there is additional overhead in - * transferring data to multiple workers, and that depending on the user's - * system, it may not be possible to parallelize the work. - * @property {ol.source.RasterOperationType|undefined} operationType Operation type. Supported values are `'pixel'` and `'image'`. By default, - * `'pixel'` operations are assumed, and operations will be called with an - * array of pixels from input sources. If set to `'image'`, operations will - * be called with an array of ImageData objects from input sources. - */ - - -/** - * @typedef {Object} source_ImageWMSOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {boolean|undefined} hidpi Use the `ol.Map#pixelRatio` value when requesting the image from the remote - * server. Default is `true`. - * @property {ol.source.WMSServerType|string|undefined} serverType The type of the remote WMS server: `mapserver`, `geoserver` or `qgis`. Only - * needed if `hidpi` is `true`. Default is `undefined`. - * @property {ol.ImageLoadFunctionType|undefined} imageLoadFunction Optional function to load an image given a URL. - * @property {Object.} params WMS request parameters. At least a `LAYERS` param is required. `STYLES` is - * `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX` - * and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically. - * @property {ol.ProjectionLike} projection Projection. - * @property {number|undefined} ratio Ratio. `1` means image requests are the size of the map viewport, `2` means - * twice the width and height of the map viewport, and so on. Must be `1` or - * higher. Default is `1.5`. - * @property {Array.|undefined} resolutions Resolutions. If specified, requests will be made for these resolutions only. - * @property {string|undefined} url WMS service URL. - */ - - -/** - * @typedef {Object} source_StamenOptions - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {string} layer Layer. - * @property {number|undefined} minZoom Minimum zoom. - * @property {number|undefined} maxZoom Maximum zoom. - * @property {boolean|undefined} opaque Whether the layer is opaque. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {string|undefined} url URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. Default is `true`. - */ - - -/** - * @typedef {Object} source_ImageStaticOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {ol.Extent} imageExtent Extent of the image in map coordinates. This is the [left, bottom, right, - * top] map coordinates of your image. - * @property {ol.ImageLoadFunctionType|undefined} imageLoadFunction Optional function to load an image given a URL. - * @property {ol.ProjectionLike} projection Projection. - * @property {ol.Size|undefined} imageSize Size of the image in pixels. Usually the image size is auto-detected, so this - * only needs to be set if auto-detection fails for some reason. - * @property {string} url Image URL. - */ - - -/** - * @typedef {Object} source_TileArcGISRestOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {Object.|undefined} params ArcGIS Rest parameters. This field is optional. Service defaults will be - * used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is `IMAGE` by - * default. `TRANSPARENT` is `true` by default. `BBOX, `SIZE`, `BBOXSR`, - * and `IMAGESR` will be set dynamically. Set `LAYERS` to - * override the default service layer visibility. See - * {@link http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Map/02r3000000v7000000/} - * for further reference. - * @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid. Base this on the resolutions, tilesize and extent supported by the - * server. - * If this is not defined, a default grid will be used: if there is a projection - * extent, the grid will be based on that; if not, a grid based on a global - * extent with origin at 0,0 will be used. - * @property {ol.ProjectionLike} projection Projection. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {string|undefined} url ArcGIS Rest service URL for a Map Service or Image Service. The - * url should include /MapServer or /ImageServer. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. Default is `true`. - * @property {number|undefined} transition Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - * @property {Array.|undefined} urls ArcGIS Rest service urls. Use this instead of `url` when the ArcGIS Service supports multiple - * urls for export requests. - */ - - -/** - * @typedef {Object} source_TileJSONOptions - * @property {ol.AttributionLike|undefined} attributions Optional attributions for the source. If provided, these will be used - * instead of any attribution data advertised by the server. If not provided, - * any attributions advertised by the server will be used. - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {boolean|undefined} jsonp Use JSONP with callback to load the TileJSON. Useful when the server - * does not support CORS. Default is `false`. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {TileJSON|undefined} tileJSON TileJSON configuration for this source. If not provided, `url` must be - * configured. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {string|undefined} url URL to the TileJSON file. If not provided, `tileJSON` must be configured. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. Default is `true`. - * @property {number|undefined} transition Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - */ - - -/** - * @typedef {Object} source_TileWMSOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {Object.} params WMS request parameters. At least a `LAYERS` param is required. `STYLES` is - * `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX` - * and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {number|undefined} gutter The size in pixels of the gutter around image tiles to ignore. By setting - * this property to a non-zero value, images will be requested that are wider - * and taller than the tile size by a value of `2 x gutter`. Defaults to zero. - * Using a non-zero value allows artifacts of rendering at tile edges to be - * ignored. If you control the WMS service it is recommended to address - * "artifacts at tile edges" issues by properly configuring the WMS service. For - * example, MapServer has a `tile_map_edge_buffer` configuration parameter for - * this. See http://mapserver.org/output/tile_mode.html. - * @property {boolean|undefined} hidpi Use the `ol.Map#pixelRatio` value when requesting the image from the remote - * server. Default is `true`. - * @property {function(new: ol.ImageTile, ol.TileCoord, ol.TileState, string, ?string, - ol.TileLoadFunctionType)|undefined} - tileClass Class used to instantiate image tiles. Default is {@link ol.ImageTile}. - * @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid. Base this on the resolutions, tilesize and extent supported by the - * server. - * If this is not defined, a default grid will be used: if there is a projection - * extent, the grid will be based on that; if not, a grid based on a global - * extent with origin at 0,0 will be used. - * @property {ol.ProjectionLike} projection Projection. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {ol.source.WMSServerType|string|undefined} serverType The type of the remote WMS server. Currently only used when `hidpi` is - * `true`. Default is `undefined`. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {string|undefined} url WMS service URL. - * @property {Array.|undefined} urls WMS service urls. Use this instead of `url` when the WMS supports multiple - * urls for GetMap requests. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. When set to `false`, only one world - * will be rendered. When `true`, tiles will be requested for one world only, - * but they will be wrapped horizontally to render multiple worlds. The default - * is `true`. - * @property {number|undefined} transition Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - */ - - -/** - * @typedef {Object} source_VectorOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {Array.|ol.Collection.|undefined} features Features. If provided as {@link ol.Collection}, the features in the source - * and the collection will stay in sync. - * @property {ol.format.Feature|undefined} format The feature format used by the XHR feature loader when `url` is set. - * Required if `url` is set, otherwise ignored. Default is `undefined`. - * @property {module:ol/Feature~FeatureLoader|undefined} loader The loader function used to load features, from a remote source for example. - * If this is not set and `url` is set, the source will create and use an XHR - * feature loader. - * - * Example: - * - * ```js - * var vectorSource = new ol.source.Vector({ - * format: new ol.format.GeoJSON(), - * loader: function(extent, resolution, projection) { - * var proj = projection.getCode(); - * var url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' + - * 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' + - * 'outputFormat=application/json&srsname=' + proj + '&' + - * 'bbox=' + extent.join(',') + ',' + proj; - * var xhr = new XMLHttpRequest(); - * xhr.open('GET', url); - * var onError = function() { - * vectorSource.removeLoadedExtent(extent); - * } - * xhr.onerror = onError; - * xhr.onload = function() { - * if (xhr.status == 200) { - * vectorSource.addFeatures( - * vectorSource.getFormat().readFeatures(xhr.responseText)); - * } else { - * onError(); - * } - * } - * xhr.send(); - * }, - * strategy: ol.loadingstrategy.bbox - * }); - * ``` - * @property {boolean|undefined} overlaps This source may have overlapping geometries. Default is `true`. Setting this - * to `false` (e.g. for sources with polygons that represent administrative - * boundaries or TopoJSON sources) allows the renderer to optimise fill and - * stroke operations. - * @property {ol.LoadingStrategy|undefined} strategy The loading strategy to use. By default an {@link ol.loadingstrategy.all} - * strategy is used, a one-off strategy which loads all features at once. - * @property {string|module:ol/Feature~FeatureUrlFunction|undefined} url Setting this option instructs the source to load features using an XHR loader - * (see {@link ol.featureloader.xhr}). Use a `string` and an - * {@link ol.loadingstrategy.all} for a one-off download of all features from - * the given URL. Use a {@link module:ol/Feature~FeatureUrlFunction} to generate the url with - * other loading strategies. - * Requires `format` to be set as well. - * When default XHR feature loader is provided, the features will - * be transformed from the data projection to the view projection - * during parsing. If your remote data source does not advertise its projection - * properly, this transformation will be incorrect. For some formats, the - * default projection (usually EPSG:4326) can be overridden by setting the - * defaultDataProjection constructor option on the format. - * Note that if a source contains non-feature data, such as a GeoJSON geometry - * or a KML NetworkLink, these will be ignored. Use a custom loader to load these. - * @property {boolean|undefined} useSpatialIndex By default, an RTree is used as spatial index. When features are removed and - * added frequently, and the total number of features is low, setting this to - * `false` may improve performance. - * - * Note that - * {@link ol.source.Vector#getFeaturesInExtent}, - * {@link ol.source.Vector#getClosestFeatureToCoordinate} and - * {@link ol.source.Vector#getExtent} cannot be used when `useSpatialIndex` is - * set to `false`, and {@link ol.source.Vector#forEachFeatureInExtent} will loop - * through all features. - * - * When set to `false`, the features will be maintained in an - * {@link ol.Collection}, which can be retrieved through - * {@link ol.source.Vector#getFeaturesCollection}. - * - * The default is `true`. - * @property {boolean|undefined} wrapX Wrap the world horizontally. Default is `true`. For vector editing across the - * -180° and 180° meridians to work properly, this should be set to `false`. The - * resulting geometry coordinates will then exceed the world bounds. - */ - - -/** - * @typedef {Object} source_WMTSOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {string|null|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {ol.tilegrid.WMTS} tileGrid Tile grid. - * @property {ol.ProjectionLike} projection Projection. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {ol.source.WMTSRequestEncoding|string|undefined} requestEncoding Request encoding. Default is `KVP`. - * @property {string} layer Layer name as advertised in the WMTS capabilities. - * @property {string} style Style name as advertised in the WMTS capabilities. - * @property {function(new: ol.ImageTile, ol.TileCoord, ol.TileState, string, ?string, - ol.TileLoadFunctionType)|undefined} - tileClass Class used to instantiate image tiles. Default is {@link ol.ImageTile}. - * @property {number|undefined} tilePixelRatio The pixel ratio used by the tile service. For example, if the tile - * service advertizes 256px by 256px tiles but actually sends 512px - * by 512px images (for retina/hidpi devices) then `tilePixelRatio` - * should be set to `2`. Default is `1`. - * @property {string|undefined} version WMTS version. Default is `1.0.0`. - * @property {string|undefined} format Image format. Default is `image/jpeg`. - * @property {string} matrixSet Matrix set. - * @property {!Object|undefined} dimensions Additional "dimensions" for tile requests. This is an object with properties - * named like the advertised WMTS dimensions. - * @property {string|undefined} url A URL for the service. For the RESTful request encoding, this is a URL - * template. For KVP encoding, it is normal URL. A `{?-?}` template pattern, - * for example `subdomain{a-f}.domain.com`, may be used instead of defining - * each one separately in the `urls` option. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {Array.|undefined} urls An array of URLs. Requests will be distributed among the URLs in this array. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. Default is `false`. - * @property {number|undefined} transition Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - */ - - -/** - * @typedef {Object} source_XYZOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {boolean|undefined} opaque Whether the layer is opaque. - * @property {ol.ProjectionLike} projection Projection. Default is `EPSG:3857`. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {number|undefined} maxZoom Optional max zoom level. Default is `18`. - * @property {number|undefined} minZoom Optional min zoom level. Default is `0`. - * @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid. - * @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @property {number|undefined} tilePixelRatio The pixel ratio used by the tile service. For example, if the tile - * service advertizes 256px by 256px tiles but actually sends 512px - * by 512px images (for retina/hidpi devices) then `tilePixelRatio` - * should be set to `2`. Default is `1`. - * @property {number|ol.Size|undefined} tileSize The tile size used by the tile service. Default is `[256, 256]` pixels. - * @property {ol.TileUrlFunctionType|undefined} tileUrlFunction Optional function to get tile URL given a tile coordinate and the projection. - * Required if url or urls are not provided. - * @property {string|undefined} url URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. - * A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be - * used instead of defining each one separately in the `urls` option. - * @property {Array.|undefined} urls An array of URL templates. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. Default is `true`. - * @property {number|undefined} transition Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - */ - - -/** - * @typedef {Object} source_CartoDBOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {ol.ProjectionLike} projection Projection. Default is `EPSG:3857`. - * @property {number|undefined} maxZoom Optional max zoom level. Default is `18`. - * @property {number|undefined} minZoom Minimum zoom. - * @property {boolean|undefined} wrapX Whether to wrap the world horizontally. Default is `true`. - * @property {Object|undefined} config If using anonymous maps, the CartoDB config to use. See - * {@link http://docs.cartodb.com/cartodb-platform/maps-api/anonymous-maps/} - * for more detail. - * If using named maps, a key-value lookup with the template parameters. - * See {@link http://docs.cartodb.com/cartodb-platform/maps-api/named-maps/} - * for more detail. - * @property {string|undefined} map If using named maps, this will be the name of the template to load. - * See {@link http://docs.cartodb.com/cartodb-platform/maps-api/named-maps/} - * for more detail. - * @property {string} account CartoDB account name - */ - - -/** - * @typedef {Object} source_ZoomifyOptions - * @property {ol.AttributionLike|undefined} attributions Attributions. - * @property {number|undefined} cacheSize Cache size. Default is `2048`. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {ol.ProjectionLike|undefined} projection Projection. - * @property {number|undefined} reprojectionErrorThreshold Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @property {!string} url URL template or base URL of the Zoomify service. A base URL is the fixed part - * of the URL, excluding the tile group, z, x, and y folder structure, e.g. - * `http://my.zoomify.info/IMAGE.TIF/`. A URL template must include - * `{TileGroup}`, `{x}`, `{y}`, and `{z}` placeholders, e.g. - * `http://my.zoomify.info/IMAGE.TIF/{TileGroup}/{z}-{x}-{y}.jpg`. - * Internet Imaging Protocol (IIP) with JTL extension can be also used with - * `{tileIndex}` and `{z}` placeholders, e.g. - * `http://my.zoomify.info?FIF=IMAGE.TIF&JTL={z},{tileIndex}`. - * A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be - * used instead of defining each one separately in the `urls` option. - * @property {string|undefined} tierSizeCalculation Tier size calculation method: `default` or `truncated`. - * @property {ol.Size} size Size of the image. - * @property {ol.Extent|undefined} extent Extent for the TileGrid that is created. Default sets the TileGrid in the - * fourth quadrant, meaning extent is `[0, -height, width, 0]`. To change the - * extent to the first quadrant (the default for OpenLayers 2) set the extent - * as `[0, 0, width, height]`. - * @property {number|undefined} transition Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - * @property {number|undefined} tileSize Tile size. Same tile size is used for all zoom levels. Default value is - * `256`. - */ - - -/** - * @typedef {Object} style_CircleOptions - * @property {module:ol/style/Fill~Fill|undefined} fill Fill style. - * @property {number} radius Circle radius. - * @property {boolean|undefined} snapToPixel If `true` integral numbers of pixels are used as the X and Y pixel - * coordinate when drawing the circle in the output canvas. If `false` - * fractional numbers may be used. Using `true` allows for "sharp" - * rendering (no blur), while using `false` allows for "accurate" - * rendering. Note that accuracy is important if the circle's - * position is animated. Without it, the circle may jitter noticeably. - * Default value is `true`. - * @property {module:ol/style/Stroke~Stroke|undefined} stroke Stroke style. - * @property {module:ol/style/AtlasManager~AtlasManager|undefined} atlasManager The atlas manager to use for this circle. When using WebGL it is - * recommended to use an atlas manager to avoid texture switching. - * If an atlas manager is given, the circle is added to an atlas. - * By default no atlas manager is used. - */ - - -/** - * @typedef {Object} style_IconOptions - * @property {Array.|undefined} anchor Anchor. Default value is `[0.5, 0.5]` (icon center). - * @property {module:ol/style/IconOrigin~IconOrigin|undefined} anchorOrigin Origin of the anchor: `bottom-left`, `bottom-right`, `top-left` or - * `top-right`. Default is `top-left`. - * @property {module:ol/style/IconAnchorUnits~IconAnchorUnits|undefined} anchorXUnits Units in which the anchor x value is specified. A value of `'fraction'` - * indicates the x value is a fraction of the icon. A value of `'pixels'` - * indicates the x value in pixels. Default is `'fraction'`. - * @property {module:ol/style/IconAnchorUnits~IconAnchorUnits|undefined} anchorYUnits Units in which the anchor y value is specified. A value of `'fraction'` - * indicates the y value is a fraction of the icon. A value of `'pixels'` - * indicates the y value in pixels. Default is `'fraction'`. - * @property {ol.Color|string|undefined} color Color to tint the icon. If not specified, the icon will be left as is. - * @property {null|string|undefined} crossOrigin The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @property {Image|HTMLCanvasElement|undefined} img Image object for the icon. If the `src` option is not provided then the - * provided image must already be loaded. And in that case, it is required - * to provide the size of the image, with the `imgSize` option. - * @property {Array.|undefined} offset Offset, which, together with the size and the offset origin, - * define the sub-rectangle to use from the original icon image. Default value - * is `[0, 0]`. - * @property {module:ol/style/IconOrigin~IconOrigin|undefined} offsetOrigin Origin of the offset: `bottom-left`, `bottom-right`, `top-left` or - * `top-right`. Default is `top-left`. - * @property {number|undefined} opacity Opacity of the icon. Default is `1`. - * @property {number|undefined} scale Scale. Default is `1`. - * @property {boolean|undefined} snapToPixel If `true` integral numbers of pixels are used as the X and Y pixel - * coordinate when drawing the icon in the output canvas. If `false` - * fractional numbers may be used. Using `true` allows for "sharp" - * rendering (no blur), while using `false` allows for "accurate" - * rendering. Note that accuracy is important if the icon's position - * is animated. Without it, the icon may jitter noticeably. Default - * value is `true`. - * @property {boolean|undefined} rotateWithView Whether to rotate the icon with the view. Default is `false`. - * @property {number|undefined} rotation Rotation in radians (positive rotation clockwise). Default is `0`. - * @property {ol.Size|undefined} size Icon size in pixel. Can be used together with `offset` to define the - * sub-rectangle to use from the origin (sprite) icon image. - * @property {ol.Size|undefined} imgSize Image size in pixels. Only required if `img` is set and `src` is not, and for - * SVG images in Internet Explorer 11. The provided `imgSize` needs to match - * the actual size of the image. - * @property {string|undefined} src Image source URI. - */ - - -/** - * @typedef {Object} style_RegularShapeOptions - * @property {module:ol/style/Fill~Fill|undefined} fill Fill style. - * @property {number} points Number of points for stars and regular polygons. In case of a polygon, the - * number of points is the number of sides. - * @property {number|undefined} radius Radius of a regular polygon. - * @property {number|undefined} radius1 Outer radius of a star. - * @property {number|undefined} radius2 Inner radius of a star. - * @property {number|undefined} angle Shape's angle in radians. A value of 0 will have one of the shape's point - * facing up. - * Default value is 0. - * @property {boolean|undefined} snapToPixel If `true` integral numbers of pixels are used as the X and Y pixel - * coordinate when drawing the shape in the output canvas. If `false` - * fractional numbers may be used. Using `true` allows for "sharp" - * rendering (no blur), while using `false` allows for "accurate" - * rendering. Note that accuracy is important if the shape's - * position is animated. Without it, the shape may jitter noticeably. - * Default value is `true`. - * @property {module:ol/style/Stroke~Stroke|undefined} stroke Stroke style. - * @property {number|undefined} rotation Rotation in radians (positive rotation clockwise). Default is `0`. - * @property {boolean|undefined} rotateWithView Whether to rotate the shape with the view. Default is `false`. - * @property {module:ol/style/AtlasManager~AtlasManager|undefined} atlasManager The atlas manager to use for this symbol. When using WebGL it is - * recommended to use an atlas manager to avoid texture switching. - * If an atlas manager is given, the symbol is added to an atlas. - * By default no atlas manager is used. - */ - - -/** - * @typedef {Object} style_TextOptions - * @property {string|undefined} font Font style as CSS 'font' value, see: - * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font}. - * Default is '10px sans-serif' - * @property {number|undefined} maxAngle When `placement` is set to `'line'`, allow a maximum angle between adjacent - * characters. The expected value is in radians, and the default is 45° - * (`Math.PI / 4`). - * @property {number|undefined} offsetX Horizontal text offset in pixels. A positive will shift the text right. - * Default is `0`. - * @property {number|undefined} offsetY Vertical text offset in pixels. A positive will shift the text down. Default - * is `0`. - * @property {boolean|undefined} overflow For polygon labels or when `placement` is set to `'line'`, allow text to - * exceed the width of the polygon at the label position or the length of - * the path that it follows. Default is `false`. - * @property {module:ol/style/Text~TextPlacement|undefined} placement Text placement. - * @property {number|undefined} scale Scale. - * @property {boolean|undefined} rotateWithView Whether to rotate the text with the view. Default is `false`. - * @property {number|undefined} rotation Rotation in radians (positive rotation clockwise). Default is `0`. - * @property {string|undefined} text Text content. - * @property {string|undefined} textAlign Text alignment. Possible values: 'left', 'right', 'center', 'end' or 'start'. - * Default is 'center' for `placement: 'point'`. For `placement: 'line'`, the - * default is to let the renderer choose a placement where `maxAngle` is not - * exceeded. - * @property {string|undefined} textBaseline Text base line. Possible values: 'bottom', 'top', 'middle', 'alphabetic', - * 'hanging', 'ideographic'. Default is 'middle'. - * @property {module:ol/style/Fill~Fill|undefined} fill Fill style. If none is provided, we'll use a dark fill-style (#333). - * @property {module:ol/style/Stroke~Stroke|undefined} stroke Stroke style. - * @property {module:ol/style/Fill~Fill|undefined} backgroundFill Fill style for the text background when `placement` is `'point'`. Default is - * no fill. - * @property {module:ol/style/Stroke~Stroke|undefined} backgroundStroke Stroke style for the text background when `placement` is `'point'`. Default - * is no stroke. - * @property {Array.|undefined} padding Padding in pixels around the text for decluttering and background. The order - * of values in the array is `[top, right, bottom, left]`. Default is - * `[0, 0, 0, 0]`. - */ - - -/** - * @typedef {Object} style_StyleOptions - * @property {undefined|string|module:ol/geom/Geometry~Geometry|ol.StyleGeometryFunction} geometry Feature property or geometry or function returning a geometry to render for - * this style. - * @property {module:ol/style/Fill~Fill|undefined} fill Fill style. - * @property {module:ol/style/Image~ImageStyle|undefined} image Image style. - * @property {ol.StyleRenderFunction|undefined} renderer Custom renderer. When configured, `fill`, `stroke` and `image` will be - * ignored, and the provided function will be called with each render frame for - * each geometry. - * - * @property {module:ol/style/Stroke~Stroke|undefined} stroke Stroke style. - * @property {module:ol/style/Text~Text|undefined} text Text style. - * @property {number|undefined} zIndex Z index. - */ - - -/** - * @typedef {Object} tilegrid_TileGridOptions - * @property {ol.Extent|undefined} extent Extent for the tile grid. No tiles outside this extent will be requested by - * {@link ol.source.Tile} sources. When no `origin` or `origins` are - * configured, the `origin` will be set to the top-left corner of the extent. - * @property {number|undefined} minZoom Minimum zoom. Default is 0. - * @property {ol.Coordinate|undefined} origin The tile grid origin, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`). - * Tile coordinates increase left to right and upwards. If not specified, - * `extent` or `origins` must be provided. - * @property {Array.|undefined} origins Tile grid origins, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`), for - * each zoom level. If given, the array length should match the length of the - * `resolutions` array, i.e. each resolution can have a different origin. Tile - * coordinates increase left to right and upwards. If not specified, `extent` - * or `origin` must be provided. - * @property {!Array.} resolutions Resolutions. The array index of each resolution needs to match the zoom - * level. This means that even if a `minZoom` is configured, the resolutions - * array will have a length of `maxZoom + 1`. - * @property {number|ol.Size|undefined} tileSize Tile size. Default is `[256, 256]`. - * @property {Array.|undefined} tileSizes Tile sizes. If given, the array length should match the length of the - * `resolutions` array, i.e. each resolution can have a different tile size. - */ - - -/** - * @typedef {Object} tilegrid_WMTSOptions - * @property {ol.Extent|undefined} extent Extent for the tile grid. No tiles outside this extent will be requested by - * {@link ol.source.Tile} sources. When no `origin` or `origins` are - * configured, the `origin` will be set to the top-left corner of the extent. - * @property {ol.Coordinate|undefined} origin The tile grid origin, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`). - * Tile coordinates increase left to right and upwards. If not specified, - * `extent` or `origins` must be provided. - * @property {Array.|undefined} origins Tile grid origins, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`), for - * each zoom level. If given, the array length should match the length of the - * `resolutions` array, i.e. each resolution can have a different origin. Tile - * coordinates increase left to right and upwards. If not specified, `extent` or - * `origin` must be provided. - * @property {!Array.} resolutions Resolutions. The array index of each resolution needs to match the zoom - * level. This means that even if a `minZoom` is configured, the resolutions - * array will have a length of `maxZoom + 1` - * @property {!Array.} matrixIds matrix IDs. The length of this array needs to match the length of the - * `resolutions` array. - * @property {Array.|undefined} sizes Number of tile rows and columns of the grid for each zoom level. The values - * here are the `TileMatrixWidth` and `TileMatrixHeight` advertised in the - * GetCapabilities response of the WMTS, and define the grid's extent together - * with the `origin`. An `extent` can be configured in addition, and will - * further limit the extent for which tile requests are made by sources. Note - * that when the top-left corner of the `extent` is used as `origin` or - * `origins`, then the `y` value must be negative because OpenLayers tile - * coordinates increase upwards. - * @property {number|ol.Size|undefined} tileSize Tile size. - * @property {Array.|undefined} tileSizes Tile sizes. The length of this array needs to match the length of the - * `resolutions` array. - * @property {Array.|undefined} widths Number of tile columns that cover the grid's extent for each zoom level. Only - * required when used with a source that has `wrapX` set to `true`, and only - * when the grid's origin differs from the one of the projection's extent. The - * array length has to match the length of the `resolutions` array, i.e. each - * resolution will have a matching entry here. - */ - - -/** - * @typedef {Object} tilegrid_XYZOptions - * @property {ol.Extent|undefined} extent Extent for the tile grid. The origin for an XYZ tile grid is the top-left - * corner of the extent. The zero level of the grid is defined by the - * resolution at which one tile fits in the provided extent. If not provided, - * the extent of the EPSG:3857 projection is used. - * @property {number|undefined} maxZoom Maximum zoom. The default is `ol.DEFAULT_MAX_ZOOM`. This determines the - * number of levels in the grid set. For example, a `maxZoom` of 21 means there - * are 22 levels in the grid set. - * @property {number|undefined} minZoom Minimum zoom. Default is 0. - * @property {number|ol.Size|undefined} tileSize Tile size in pixels. Default is `[256, 256]`. - */ diff --git a/package.json b/package.json index aea273bf03..ef417cad92 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ ], "homepage": "https://openlayers.org/", "scripts": { - "lint": "eslint tasks test src/ol examples", + "lint": "eslint tasks test src/ol examples config", "pretest": "npm run lint", "posttest": "npm run typecheck", "test": "npm run karma -- --single-run", diff --git a/src/ol/interaction/Translate.js b/src/ol/interaction/Translate.js index 9035c35a52..81d1ce9d9b 100644 --- a/src/ol/interaction/Translate.js +++ b/src/ol/interaction/Translate.js @@ -38,7 +38,7 @@ const TranslateEventType = { /** - * @typedef {Object} interaction_TranslateOptions + * @typedef {Object} Options * @property {module:ol/Collection~Collection.} [features] Only features contained in this collection will be able to be translated. If * not specified, all features on the map will be able to be translated. * @property {Array.|function(module:ol/layer/Layer~Layer): boolean} [layers] A list of layers from which features should be @@ -94,7 +94,7 @@ inherits(TranslateEvent, Event); * @constructor * @extends {module:ol/interaction/Pointer~Pointer} * @fires module:ol/interaction/Translate~TranslateEvent - * @param {olx.interaction.TranslateOptions=} opt_options Options. + * @param {module:ol/interaction/Translate~Options=} opt_options Options. * @api */ const Translate = function(opt_options) { diff --git a/src/ol/source/TileArcGISRest.js b/src/ol/source/TileArcGISRest.js index c23020c6a4..0f0bc4b0bf 100644 --- a/src/ol/source/TileArcGISRest.js +++ b/src/ol/source/TileArcGISRest.js @@ -10,6 +10,47 @@ import TileImage from '../source/TileImage.js'; import {hash as tileCoordHash} from '../tilecoord.js'; import {appendParams} from '../uri.js'; +/** + * @typedef {Object} Options + * @property {ol.AttributionLike} [attributions] Attributions. + * @property {number} [cacheSize=2048] Cache size. + * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. + * Note that you must provide a `crossOrigin` value if you are using the WebGL renderer + * or if you want to access pixel data with the Canvas renderer. See + * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} + * for more detail. + * @property {Object.} [params] ArcGIS Rest parameters. This field is optional. Service defaults will be + * used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is `IMAGE` by + * default. `TRANSPARENT` is `true` by default. `BBOX, `SIZE`, `BBOXSR`, + * and `IMAGESR` will be set dynamically. Set `LAYERS` to + * override the default service layer visibility. See + * {@link http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Map/02r3000000v7000000/} + * for further reference. + * @property {ol.tilegrid.TileGrid} [tileGrid] Tile grid. Base this on the resolutions, + * tilesize and extent supported by the server. + * If this is not defined, a default grid will be used: if there is a projection + * extent, the grid will be based on that; if not, a grid based on a global + * extent with origin at 0,0 will be used. + * @property {ol.ProjectionLike} projection Projection. + * @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels). + * Higher values can increase reprojection performance, but decrease precision. + * @property {ol.TileLoadFunctionType} [tileLoadFunction] Optional function to load a tile given a URL. + * The default is + * ```js + * function(imageTile, src) { + * imageTile.getImage().src = src; + * }; + * ``` + * @property {string} [url] ArcGIS Rest service URL for a Map Service or Image Service. The + * url should include /MapServer or /ImageServer. + * @property {boolean} [wrapX=true] Whether to wrap the world horizontally. + * @property {number} [transition] Duration of the opacity transition for rendering. To disable the opacity + * transition, pass `transition: 0`. + * @property {Array.} urls ArcGIS Rest service urls. Use this instead of `url` when the ArcGIS + * Service supports multiple urls for export requests. + */ + + /** * @classdesc * Layer source for tile data from ArcGIS Rest services. Map and Image @@ -20,8 +61,7 @@ import {appendParams} from '../uri.js'; * * @constructor * @extends {module:ol/source/TileImage~TileImage} - * @param {olx.source.TileArcGISRestOptions=} opt_options Tile ArcGIS Rest - * options. + * @param {module:ol/source/TileArcGISRest~Options=} opt_options Tile ArcGIS Rest options. * @api */ const TileArcGISRest = function(opt_options) { diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index ce6b842395..22fe1e1d76 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -21,6 +21,15 @@ import SourceState from '../source/State.js'; import VectorEventType from '../source/VectorEventType.js'; import RBush from '../structs/RBush.js'; +/** + * A function that takes an {@link module:ol/extent~Extent} and a resolution as arguments, and + * returns an array of {@link module:ol/extent~Extent} with the extents to load. Usually this + * is one of the standard {@link ol.loadingstrategy} strategies. + * + * @typedef {function(module:ol/extent~Extent, number): Array.} LoadingStrategy + * @api + */ + /** * @classdesc @@ -95,7 +104,7 @@ inherits(VectorSourceEvent, Event); * Setting this to `false` (e.g. for sources with polygons that represent administrative * boundaries or TopoJSON sources) allows the renderer to optimise fill and * stroke operations. - * @property {ol.LoadingStrategy} [strategy] The loading strategy to use. + * @property {module:ol/source/Vector~LoadingStrategy} [strategy] The loading strategy to use. * By default an {@link ol.loadingstrategy.all} * strategy is used, a one-off strategy which loads all features at once. * @property {string|module:ol/Feature~FeatureUrlFunction} [url] @@ -191,7 +200,7 @@ const VectorSource = function(opt_options) { /** * @private - * @type {ol.LoadingStrategy} + * @type {module:ol/source/Vector~LoadingStrategy} */ this.strategy_ = options.strategy !== undefined ? options.strategy : allStrategy; diff --git a/src/ol/source/WMTS.js b/src/ol/source/WMTS.js index 02a5703ba4..f78af486ca 100644 --- a/src/ol/source/WMTS.js +++ b/src/ol/source/WMTS.js @@ -352,7 +352,7 @@ WMTS.prototype.updateDimensions = function(dimensions) { * - format - {string} Image format for the layer. Default is the first * format returned in the GetCapabilities response. * - crossOrigin - {string|null|undefined} Cross origin. Default is `undefined`. - * @return {?olx.source.WMTSOptions} WMTS source options object or `null` if the layer was not found. + * @return {?module:ol/source/WMTS~Options} WMTS source options object or `null` if the layer was not found. * @api */ export function optionsFromCapabilities(wmtsCap, config) { diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js deleted file mode 100644 index 666a15b52d..0000000000 --- a/src/ol/typedefs.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @module ol/typedefs - */ - -//FIXME Remove when reworking typedefs, export typedefs as variables instead -const ol = {}; - -/** - * File for all typedefs used by the compiler, and referenced by JSDoc. - * - * These look like vars (or var properties), but in fact are simply identifiers - * for the Closure compiler. Originally they were included in the appropriate - * namespace file, but with the move away from Closure namespaces and towards - * self-contained standard modules are now all in this file. - * Unlike the other type definitions - enums and constructor functions - they - * are not code and so are not imported or exported. They are only referred to - * in type-defining comments used by the Closure compiler, and so should not - * appear in module code. - * - * They are now all in the `ol` namespace. - */ - - -/** - * A function that takes an {@link module:ol/extent~Extent} and a resolution as arguments, and - * returns an array of {@link module:ol/extent~Extent} with the extents to load. Usually this - * is one of the standard {@link ol.loadingstrategy} strategies. - * - * @typedef {function(module:ol/extent~Extent, number): Array.} - */ -ol.LoadingStrategy; diff --git a/src/olx.jsdoc b/src/olx.jsdoc deleted file mode 100644 index 499f6c0878..0000000000 --- a/src/olx.jsdoc +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @namespace olx - */ - -/** - * @namespace olx.control - */ - -/** - * @namespace olx.format - */ - -/** - * @namespace olx.interaction - */ - -/** - * @namespace olx.layer - */ - -/** - * @namespace olx.parser - */ - -/** - * @namespace olx.render - */ - -/** - * @namespace olx.source - */ - -/** - * @namespace olx.style - */ - -/** - * @namespace olx.tilegrid - */ diff --git a/tasks/generate-info.js b/tasks/generate-info.js index ba328d9b6d..c3eeca4fba 100644 --- a/tasks/generate-info.js +++ b/tasks/generate-info.js @@ -9,7 +9,6 @@ const isWindows = process.platform.indexOf('win') === 0; const sourceDir = path.join(__dirname, '..', 'src'); const externsDir = path.join(__dirname, '..', 'externs'); const externsPaths = [ - path.join(externsDir, 'olx.js'), path.join(externsDir, 'geojson.js') ]; const infoPath = path.join(__dirname, '..', 'build', 'info.json'); diff --git a/tasks/t.js b/tasks/t.js deleted file mode 100644 index 3e09af3421..0000000000 --- a/tasks/t.js +++ /dev/null @@ -1,187 +0,0 @@ -const fs = require('fs'); -const util = require('util'); -const path = require('path'); - -const readFile = util.promisify(fs.readFile); -const writeFile = util.promisify(fs.writeFile); -const externs = path.resolve(__dirname, '../externs'); - -function parse(source) { - const length = source.length; - - let index = 0; - const IN_CODE = 'in code'; - const IN_COMMENT = 'in comment'; - - function next() { - const char = source.charAt(index); - ++index; - return char; - } - - function scanLine() { - let char = next(); - let line = ''; - while (index < length && char !== '\n') { - line += char; - char = next(); - } - return line; - } - - let state = IN_CODE; - const blocks = []; - let comment; - while (index < length) { - const line = scanLine(); - if (state === IN_CODE) { - if (line === '/**') { - state = IN_COMMENT; - comment = ''; - } - continue; - } - - // in a comment - if (!line) { - continue; - } - - if (line !== ' */') { - comment += line + '\n'; - continue; - } - - // comment is done - const code = scanLine(); - if (code.startsWith('olx')) { - blocks.push({code, comment}); - } - state = IN_CODE; - } - return blocks; -} - -function processParam(name, comment) { - const IN_DESCRIPTION = 'in description'; - const IN_TYPE = 'in type'; - const DONE = 'done'; - - const lines = comment.split('\n'); - lines.pop(); // ends with newline - let description = ''; - let type; - let state = IN_DESCRIPTION; - lines.forEach(line => { - if (state === DONE) { - throw new Error(`Extra comment after @api for param ${name}:\n${comment}`); - } - - if (!(line.startsWith(' * ') || line === ' *')) { - throw new Error(`Unexpected comment start for param ${name}:\n${comment}`); - } - - if (line.indexOf('@type ') === 3) { - state = IN_TYPE; - if (type) { - throw new Error(`Duplicate type for param ${name}:\n${comment}`); - } - type = line.slice(9); - return; - } - - if (line.indexOf('@api') === 3) { - state = DONE; - return; - } - - if (state === IN_DESCRIPTION) { - if (type) { - throw new Error(`Description after type for param ${name}:\n${comment}`); - } - description += line.slice(3) + '\n'; - return; - } - - type += line.slice(3) + '\n'; - }); - - return {name, type, description}; -} - -function getName(name) { - if (!name.startsWith('olx.')) { - throw new Error(`Unexpected name: ${name}`); - } - return name.slice(4).replace(/\./g, '_'); -} - -function processBlock(block, data) { - const name = getName(block.code.slice(0, -1)); - - const protoStart = name.indexOf('_prototype_'); - if (protoStart > 0) { - const parentName = name.slice(0, protoStart); - const childName = name.slice(protoStart + 11); - if (!(parentName in data)) { - throw new Error(`No parent for ${block.code}`); - } - const param = processParam(childName, block.comment); - data[parentName].params.push(param); - return; - } - - if (block.comment.indexOf('@typedef') === -1) { - if (block.comment.indexOf('Namespace.') === -1) { - throw new Error(`Unexpected comment for ${block.code}`); - } - return; - } - - data[name] = { - name, - comment: block.comment, - params: [] - }; -} - -function processBlocks(blocks) { - const data = {}; - blocks.forEach(block => processBlock(block, data)); - return data; -} - -function format(data) { - let source = ''; - for (const name in data) { - - // add the @typedef - source += `\n/**\n * @typedef {Object} ${name}\n`; - - const params = data[name].params; - if (!params.length) { - throw new Error(`No params for ${name}`); - } - - params.forEach(param => { - const description = param.description.replace(/\n$/, '').split('\n').join('\n * '); - source += ` * @property ${param.type} ${param.name} ${description}\n`; - }); - source += ' */\n\n'; - } - return source; -} - -async function main() { - const source = String(await readFile(path.join(externs, 'olx.js'))); - const blocks = parse(source); - const data = processBlocks(blocks); - const output = format(data); - await writeFile(path.join(externs, 'xol.js'), output); -} - -if (require.main === module) { - main().catch(err => { - process.stdout.write(`${err.stack}\n`, () => process.exit(1)); - }); -} diff --git a/test/rendering/ol/style/icon.test.js b/test/rendering/ol/style/icon.test.js index df1566db8d..07013b69d8 100644 --- a/test/rendering/ol/style/icon.test.js +++ b/test/rendering/ol/style/icon.test.js @@ -58,7 +58,7 @@ describe('ol.rendering.style.Icon', function() { img.onload = function() { imgInfo.img = img; feature.setStyle(new Style({ - image: new Icon(/** @type {olx.style.IconOptions} */ (imgInfo)) + image: new Icon(/** @type {module:ol/style/Icon~Options} */ (imgInfo)) })); vectorSource.addFeature(feature); callback();