diff --git a/.travis.yml b/.travis.yml
index 8849be3542..fc35d94558 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,14 +1,9 @@
-sudo: false
language: node_js
node_js:
- '8'
cache:
directories:
- node_modules
-before_script:
-- rm src/ol/renderer/webgl/*shader.js
-- rm src/ol/renderer/webgl/*shader/locations.js
-script: make ci
after_success:
- cat coverage/lcov.info | coveralls
branches:
diff --git a/Makefile b/Makefile
index 24fcfe4cfc..4b6a442712 100644
--- a/Makefile
+++ b/Makefile
@@ -1,280 +1,13 @@
-OS := $(shell uname)
-BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
-
SRC_GLSL := $(shell find src -type f -name '*.glsl')
SRC_SHADER_JS := $(patsubst %shader.glsl,%shader.js,$(SRC_GLSL))
SRC_SHADERLOCATIONS_JS := $(patsubst %shader.glsl,%shader/locations.js,$(SRC_GLSL))
-SRC_JS := $(filter-out $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS),$(shell find src -name '*.js'))
-SRC_JSDOC = $(shell find src -type f -name '*.jsdoc')
-
-EXAMPLES := $(shell find examples -type f)
-EXAMPLES_HTML := $(filter-out examples/index.html,$(shell find examples -maxdepth 1 -type f -name '*.html'))
-EXAMPLES_JS := $(patsubst %.html,%.js,$(EXAMPLES_HTML))
-
-BUILD_EXAMPLES := $(subst examples,build/examples,$(EXAMPLES)) build/examples/index.js
-
-BUILD_HOSTED := build/hosted/$(BRANCH)
-BUILD_HOSTED_EXAMPLES := $(addprefix $(BUILD_HOSTED)/,$(EXAMPLES))
-BUILD_HOSTED_EXAMPLES_JS := $(addprefix $(BUILD_HOSTED)/,$(EXAMPLES_JS))
-
-UNPHANTOMABLE_EXAMPLES = examples/shaded-relief.html examples/raster.html examples/region-growing.html examples/color-manipulation.html
-CHECK_EXAMPLE_TIMESTAMPS = $(patsubst examples/%.html,build/timestamps/check-%-timestamp,$(filter-out $(UNPHANTOMABLE_EXAMPLES),$(EXAMPLES_HTML)))
-
-TASKS_JS := $(shell find tasks -name '*.js')
-
-ifeq (CYGWIN,$(findstring CYGWIN,$(OS)))
- CLOSURE_LIB = $(shell cygpath -u $(shell node -e 'process.stdout.write(require("closure-util").getLibraryPath())'))
-else
- CLOSURE_LIB = $(shell node -e 'process.stdout.write(require("closure-util").getLibraryPath())')
-endif
-
-ifeq ($(OS),Darwin)
- STAT_COMPRESSED = stat -f ' compressed: %z bytes'
- STAT_UNCOMPRESSED = stat -f 'uncompressed: %z bytes'
-else
- STAT_COMPRESSED = stat -c ' compressed: %s bytes'
- STAT_UNCOMPRESSED = stat -c 'uncompressed: %s bytes'
-endif
-
-.PHONY: default
-default: help
-
-.PHONY: help
-help:
- @echo
- @echo "The most common targets are:"
- @echo
- @echo "- install Install node dependencies"
- @echo "- serve Start dev server for running examples and tests"
- @echo "- test Run unit tests in the console"
- @echo "- check Perform a number of checks on the code"
- @echo "- clean Remove generated files"
- @echo "- help Display this help message"
- @echo
- @echo "Other less frequently used targets are:"
- @echo
- @echo "- build Build ol.js, ol-debug.js, ol.js.map and ol.css"
- @echo "- ci Run the full continuous integration process"
- @echo "- apidoc Build the API documentation using JSDoc"
- @echo "- cleanall Remove all the build artefacts"
- @echo "- check-deps Check if the required dependencies are installed"
- @echo
-
-.PHONY: apidoc
-apidoc: build/timestamps/jsdoc-$(BRANCH)-timestamp
-
-.PHONY: build
-build: build/ol.css build/ol.js build/ol-debug.js build/ol.js.map
-
-.PHONY: check
-check: build/ol.js test
-
-.PHONY: check-examples
-check-examples: $(CHECK_EXAMPLE_TIMESTAMPS)
-
-.PHONY: check-deps
-check-deps: EXECUTABLES = git node python java
-check-deps:
- @for exe in $(EXECUTABLES) ;\
- do \
- which $${exe} > /dev/null && \
- echo "Program $${exe} OK" || \
- echo "Program $${exe} MISSING!" ;\
- done ;\
-
-.PHONY: ci
-ci: build test package compile-examples check-examples apidoc
-
-.PHONY: compile-examples
-compile-examples: build/compiled-examples/all.combined.js
-
-.PHONY: clean
-clean:
- rm -f build/timestamps/check-*-timestamp
- rm -f build/ol.css
- rm -f build/ol.js
- rm -f build/ol.js.map
- rm -f build/ol-debug.js
- rm -rf build/examples
- rm -rf build/compiled-examples
- rm -rf build/package
- rm -rf $(BUILD_HOSTED)
-
-.PHONY: cleanall
-cleanall:
- rm -rf build
-
-.PHONY: css
-css: build/ol.css
-
-.PHONY: examples
-examples: $(BUILD_EXAMPLES)
-
-.PHONY: install
-install: build/timestamps/node-modules-timestamp
-
-.PHONY: npm-install
-npm-install: build/timestamps/node-modules-timestamp
.PHONY: shaders
-shaders: $(SRC_SHADER_JS $(SRC_SHADERLOCATIONS_JS)
+shaders: $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS)
-.PHONY: serve
-serve:
- node tasks/serve.js
-
-.PHONY: test
-test: build/timestamps/node-modules-timestamp
- npm test
-
-.PHONY: host-examples
-host-examples: $(BUILD_HOSTED_EXAMPLES) \
- $(BUILD_HOSTED)/build/ol.js \
- $(BUILD_HOSTED)/build/ol-debug.js \
- $(BUILD_HOSTED)/css/ol.css \
- $(BUILD_HOSTED)/examples/loader.js \
- $(BUILD_HOSTED)/examples/index.js \
- $(BUILD_HOSTED)/build/ol-deps.js
-
-.PHONY: host-libraries
-host-libraries: build/timestamps/node-modules-timestamp
- @rm -rf $(BUILD_HOSTED)/closure-library
- @mkdir -p $(BUILD_HOSTED)/closure-library
- @cp -r $(CLOSURE_LIB)/* $(BUILD_HOSTED)/closure-library/
- @rm -rf $(BUILD_HOSTED)/ol/ol
- @mkdir -p $(BUILD_HOSTED)/ol/ol
- @cp -r src/ol/* $(BUILD_HOSTED)/ol/ol/
- @rm -rf $(BUILD_HOSTED)/ol.ext
- @mkdir -p $(BUILD_HOSTED)/ol.ext
- @cp -r build/ol.ext/* $(BUILD_HOSTED)/ol.ext/
-
-$(BUILD_EXAMPLES): $(EXAMPLES) package.json
- @mkdir -p $(@D)
- @node tasks/build-examples.js
-
-build/timestamps/check-%-timestamp: $(BUILD_HOSTED)/examples/%.html \
- $(BUILD_HOSTED)/examples/%.js \
- $(filter $(BUILD_HOSTED)/examples/resources/%,$(BUILD_HOSTED_EXAMPLES)) \
- $(filter $(BUILD_HOSTED)/examples/data/%,$(BUILD_HOSTED_EXAMPLES)) \
- $(BUILD_HOSTED)/examples/loader.js \
- $(BUILD_HOSTED)/build/ol.js \
- $(BUILD_HOSTED)/css/ol.css
- @mkdir -p $(@D)
- node tasks/check-example.js $<
- @touch $@
-
-build/compiled-examples/all.js: $(EXAMPLES_JS)
- @mkdir -p $(@D)
- @python bin/combine-examples.py $^ > $@
-
-build/compiled-examples/all.combined.js: config/examples-all.json build/compiled-examples/all.js \
- $(SRC_JS) $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS) \
- build/timestamps/node-modules-timestamp
- @mkdir -p $(@D)
- node tasks/build.js $< $@
-
-build/compiled-examples/%.json: config/example.json build/examples/%.js \
- build/timestamps/node-modules-timestamp
- @mkdir -p $(@D)
- @sed -e 's|{{id}}|$*|' $< > $@
-
-build/compiled-examples/%.combined.js: build/compiled-examples/%.json \
- $(SRC_JS) $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS)\
- build/timestamps/node-modules-timestamp
- @mkdir -p $(@D)
- node tasks/build.js $< $@
-
-build/timestamps/jsdoc-$(BRANCH)-timestamp: config/jsdoc/api/index.md \
- config/jsdoc/api/conf.json $(SRC_JS) \
- $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS) \
- $(shell find config/jsdoc/api/template -type f) \
- build/timestamps/node-modules-timestamp
- @mkdir -p $(@D)
- @rm -rf $(BUILD_HOSTED)/apidoc
- ./node_modules/.bin/jsdoc config/jsdoc/api/index.md -c config/jsdoc/api/conf.json --package package.json -d $(BUILD_HOSTED)/apidoc
- @touch $@
-
-$(BUILD_HOSTED_EXAMPLES_JS): $(BUILD_HOSTED)/examples/%.js: build/examples/%.js
- @mkdir -p $(@D)
- @python bin/split-example.py $< $(@D)
-
-$(BUILD_HOSTED)/examples/loader.js: bin/loader_hosted_examples.js
- @mkdir -p $(@D)
- @cp $< $@
-
-$(BUILD_HOSTED)/examples/%: build/examples/%
- @mkdir -p $(@D)
- @cp $< $@
-
-$(BUILD_HOSTED)/build/ol.js: build/ol.js
- @mkdir -p $(@D)
- @cp $< $@
-
-$(BUILD_HOSTED)/build/ol-debug.js: build/ol-debug.js
- @mkdir -p $(@D)
- @cp $< $@
-
-$(BUILD_HOSTED)/css/ol.css: build/ol.css
- @mkdir -p $(@D)
- @cp $< $@
-
-$(BUILD_HOSTED)/build/ol-deps.js: host-libraries
- @mkdir -p $(@D)
- @python $(CLOSURE_LIB)/closure/bin/build/depswriter.py \
- --root_with_prefix "src ../../../ol" \
- --root_with_prefix "build/ol.ext ../../../ol.ext" \
- --root $(BUILD_HOSTED)/closure-library/closure/goog \
- --root_with_prefix "$(BUILD_HOSTED)/closure-library/third_party ../../third_party" \
- --output_file $@
-
-build/timestamps/node-modules-timestamp: package.json
- @mkdir -p $(@D)
- npm install
- @touch $@
-
-build/ol.css: css/ol.css build/timestamps/node-modules-timestamp
- @mkdir -p $(@D)
- @echo "Running cleancss..."
- @./node_modules/.bin/cleancss $< > $@
-
-build/ol.js: config/ol.json $(SRC_JS) $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS) \
- build/timestamps/node-modules-timestamp
- @mkdir -p $(@D)
- node tasks/build.js $< $@
- @$(STAT_UNCOMPRESSED) $@
- @cp $@ /tmp/
- @gzip /tmp/ol.js
- @$(STAT_COMPRESSED) /tmp/ol.js.gz
- @rm /tmp/ol.js.gz
-
-build/ol.js.map: config/ol.json $(SRC_JS) $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS) \
- build/timestamps/node-modules-timestamp
- @mkdir -p $(@D)
- node tasks/build.js $< $@
-
-build/ol-debug.js: config/ol-debug.json $(SRC_JS) $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS) \
- build/timestamps/node-modules-timestamp
- @mkdir -p $(@D)
- node tasks/build.js $< $@
- @$(STAT_UNCOMPRESSED) $@
- @cp $@ /tmp/
- @gzip /tmp/ol-debug.js
- @$(STAT_COMPRESSED) /tmp/ol-debug.js.gz
- @rm /tmp/ol-debug.js.gz
-
-%shader.js: %shader.glsl src/ol/webgl/shader.mustache tasks/glslunit.js build/timestamps/node-modules-timestamp
+%shader.js: %shader.glsl src/ol/webgl/shader.mustache tasks/glslunit.js
@node tasks/glslunit.js --input $< | ./node_modules/.bin/mustache - src/ol/webgl/shader.mustache > $@
-%shader/locations.js: %shader.glsl src/ol/webgl/shaderlocations.mustache tasks/glslunit.js build/timestamps/node-modules-timestamp
+%shader/Locations.js: %shader.glsl src/ol/webgl/shaderlocations.mustache tasks/glslunit.js
@mkdir -p $(@D)
@node tasks/glslunit.js --input $< | ./node_modules/.bin/mustache - src/ol/webgl/shaderlocations.mustache > $@
-
-.PHONY: package
-package:
- @rm -rf build/package
- @cp -r package build
- @cd ./src && cp -r ol/* ../build/package
- @rm build/package/typedefs.js
- @cp css/ol.css build/package
- ./node_modules/.bin/jscodeshift --transform transforms/module.js build/package
- npm run lint-package
diff --git a/bin/check-example.js b/bin/check-example.js
deleted file mode 100644
index ee7b8be5bf..0000000000
--- a/bin/check-example.js
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// A PhantomJS script used to check that the hosted examples load
-// without errors. This script is executed by the build tool's
-// check-examples target.
-//
-var args = require('system').args;
-if (args.length != 2) {
- phantom.exit(2);
-}
-var examplePath = args[1];
-var page = require('webpage').create();
-page.onError = function(msg, trace) {
- var msgStack = ['JavaScript ERROR: ' + msg];
- if (trace) {
- msgStack.push('TRACE:');
- trace.forEach(function(t) {
- msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function + '")' : ''));
- });
- }
- console.error(msgStack.join('\n'));
- phantom.exit(1);
-};
-page.open(examplePath, function(s) {
- var exitCode = 0;
- if (s != 'success') {
- exitCode = 1;
- console.error('PAGE LOAD ERROR');
- }
- phantom.exit(exitCode);
-});
-page.onConsoleMessage = function(msg) {
- console.log('console:', msg);
-};
diff --git a/bin/combine-examples.py b/bin/combine-examples.py
deleted file mode 100755
index c9cd9e36e2..0000000000
--- a/bin/combine-examples.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-
-import re
-import sys
-
-
-def main(argv):
- examples = {}
- requires = set()
- for filename in argv[1:]:
- lines = open(filename, 'rU').readlines()
- if len(lines) > 0 and lines[0].startswith('// NOCOMPILE'):
- continue
- requires.update(line for line in lines if line.startswith('goog.require'))
- examples[filename] = [line for line in lines if not line.startswith('goog.require')]
- for require in sorted(requires):
- sys.stdout.write(require)
- for filename in sorted(examples.keys()):
- sys.stdout.write('// ' + filename + '\n')
- sys.stdout.write('(function(){\n')
- for line in examples[filename]:
- sys.stdout.write(line)
- sys.stdout.write('})();\n')
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/bin/example-screenshot.js b/bin/example-screenshot.js
deleted file mode 100644
index ff5ce91c94..0000000000
--- a/bin/example-screenshot.js
+++ /dev/null
@@ -1,180 +0,0 @@
-
-
-/**
- * This script is supposed to be executed via phantomjs. It will generate
- * screenshots of the html files in the directory specified by a commandline
- * option when these files are served through a webserver which can also be
- * specified. The screenshots will be in the current working directory.
- *
- * Example usage:
- *
- * user@host:~/openlayers/bin $ phantomjs example-screenshot.js \
- * http://localhost:8000/openlayers/examples/ \
- * ../examples
- *
- * The above command will generate `*.png` files in `examples/` for all html
- * files that are served through `http://localhost:8000/openlayers/examples/`.
- *
- * So if there is a file `my-humpty-example.html` inside of the relative folder
- * `../examples/` which is being served through the webserver so that
- * `http://localhost:8000/openlayers/examples/my-humpty-example.html` is a valid and
- * reachable URL, this script will generate a screenshot and store it as
- * `my-humpty-example.html.png`.
- *
- * The query string `?mode=raw` will be appended to the generated URL.
- *
- * Known limitations:
- *
- * As phantomjs doesn't support WebGL (see e.g.
- * https://github.com/ariya/phantomjs/wiki/Supported-Web-Standards and
- * http://code.google.com/p/phantomjs/issues/detail?id=273) This won't render
- * OpenLayers maps rendered through the webglrenderer.
- *
- * In parts based upon this gist: https://gist.github.com/crazy4groovy/3160121
- */
-(function() { // global closure
-
- var page = require('webpage').create(), // imports
- fs = require('fs'),
- system = require('system'),
- // arguments
- baseExamplesUrl = system.args[1],
- exampleDir = system.args[2],
- // various settings
- ignoreFiles = [
- 'index.html'
- ],
- intervalMillisecs = 25,
- renderMillisecs = 2000,
- // basic variables
- curDir = fs.workingDirectory,
- exampleDirList = fs.list(exampleDir),
- pageindex = 0,
- fileName = '',
- htmlFiles = [],
- lenHtmlFiles = 0,
- loadInProgress = false;
-
- // simple object with helper functions
- var util = {
- /**
- * Returns the basename of a file given a path.
- */
- baseName: function(path) {
- var parts = path.split(fs.separator);
- return parts[parts.length - 1];
- },
- /**
- * Super basic test whether a file can be considered a HTML-file.
- */
- isHtmlFile: function(filename) {
- return (/\.html?$/).test(filename);
- },
- /**
- * Appends a slash to given string if it isn't there already.
- */
- appendSlash: function(str) {
- return ((/\/$/).test(str)) ? str : str + '/';
- },
- /**
- * Generates an URL out of given baseurl and path.
- */
- buildUrl: function(baseurl, path) {
- var name = util.baseName(path),
- mode = 'raw';
- return util.appendSlash(baseurl) + name + '?mode=' + mode;
- },
- /**
- * Simple progressbar logger that uses our globals pageindex & lenHtmlFiles.
- */
- logProgress: function() {
- var doneSymbol = '-',
- todoSymbol = ' ',
- currentSymbol = '>',
- barStrLeft = '[',
- barStrRight = ']',
- progresStep = 5, // one doneSymbol equals this percentage
- totalSteps = Math.round(100 / progresStep),
- ratio = (lenHtmlFiles === 0) ? 0 : (pageindex / lenHtmlFiles),
- percent = (ratio === 0) ? 0 : ratio * 100,
- normalizedNumDone = Math.floor(ratio * totalSteps),
- normalizedNumTodo = totalSteps - normalizedNumDone,
- progressLine = '',
- i = 0;
- // the progress bar
- progressLine += barStrLeft;
- for (; i < normalizedNumDone; i++) {
- progressLine += doneSymbol;
- }
- for (i = 0; i < normalizedNumTodo; i++) {
- progressLine += (i === 0) ? currentSymbol : todoSymbol;
- }
- progressLine += barStrRight;
- // the percentage information
- // pad if necessary
- if (percent < 10) {
- progressLine += ' ';
- } else if (percent < 100) {
- progressLine += ' ';
- }
- progressLine += ' ' + percent.toFixed(1) + ' % done';
- // additional information
- if (fileName !== '') {
- progressLine += ', ' + util.baseName(fileName) + '';
- }
- console.log(progressLine);
- }
- };
-
- // iterate over all files in examples directory
- // and find the HTML files.
- for (var i = 0; i < exampleDirList.length; i++) {
- var fullpath = exampleDir + fs.separator + exampleDirList[i];
- if (fs.isFile(fullpath) && util.isHtmlFile(fullpath) &&
- ignoreFiles.indexOf(util.baseName(fullpath)) === -1) {
- //TODO: make this more async (i.e. pop on/off stack WHILE rending pages)
- htmlFiles.push(fullpath);
- }
- }
- lenHtmlFiles = htmlFiles.length;
-
- console.log('Capturing ' + lenHtmlFiles + ' example screenshots.');
-
- // The main interval function that is executed regularly and renders a
- // page to a file
- var interval = setInterval(function() {
- if (!loadInProgress && pageindex < lenHtmlFiles) {
- util.logProgress();
- fileName = htmlFiles[pageindex];
- page.viewportSize = { width: 800, height: 600 };
- page.clipRect = {
- top: 0,
- left: 0,
- width: page.viewportSize.width,
- height: page.viewportSize.height
- };
- page.open(util.buildUrl(baseExamplesUrl, htmlFiles[pageindex]));
- }
- if (pageindex == lenHtmlFiles) {
- util.logProgress();
- console.log(lenHtmlFiles + ' screenshots captured.');
- phantom.exit();
- }
- }, intervalMillisecs);
-
- // set loadInProgress flag so we only process one image at time.
- page.onLoadStarted = function() {
- loadInProgress = true;
- };
-
- // When the page is loaded, render it to an image
- page.onLoadFinished = function() {
- var dest = exampleDir + fs.separator + util.baseName(fileName) + '.png';
- window.setTimeout(function() {
- loadInProgress = false;
- page.render(dest); // actually render the page.
- pageindex++;
- }, renderMillisecs);
- };
-
-})(); // eof global closure
diff --git a/bin/loader_hosted_examples.js b/bin/loader_hosted_examples.js
deleted file mode 100644
index 4901ce435b..0000000000
--- a/bin/loader_hosted_examples.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * This loader is used for the hosted examples. It is used in place of the
- * development loader (examples/loader.js).
- *
- * The loader loads ol.js and the example's script in "production" mode; it
- * loads Closure Library's base.js, ol-deps.js, the example's "goog.require"
- * script, and the example's script in "development" mode.
- *
- * The ol.js and ol-deps.js scripts are built using OpenLayers's Makefile. They are
- * located in the ../build/ directory, relative to this script.
- *
- * The script must be named loader.js.
- *
- * Usage:
- *
- *
- */
-
-(function() {
-
- var i, pair;
-
- var href = window.location.href, start, end, paramsString, pairs,
- pageParams = {};
- if (href.indexOf('?') > 0) {
- start = href.indexOf('?') + 1;
- end = href.indexOf('#') > 0 ? href.indexOf('#') : href.length;
- paramsString = href.substring(start, end);
- pairs = paramsString.split(/[&;]/);
- for (i = 0; i < pairs.length; ++i) {
- pair = pairs[i].split('=');
- if (pair[0]) {
- pageParams[decodeURIComponent(pair[0])] =
- decodeURIComponent(pair[1]);
- }
- }
- }
-
- var scripts = document.getElementsByTagName('script');
- var src, index, search, chunks, scriptParams = {};
- for (i = scripts.length - 1; i >= 0; --i) {
- src = scripts[i].getAttribute('src');
- if (~(index = src.indexOf('loader.js?'))) {
- search = src.substr(index + 10);
- chunks = search ? search.split('&') : [];
- for (i = chunks.length - 1; i >= 0; --i) {
- pair = chunks[i].split('=');
- if (pair[0]) {
- scriptParams[decodeURIComponent(pair[0])] =
- decodeURIComponent(pair[1]);
- }
- }
- break;
- }
- }
-
- var raw = pageParams.mode && pageParams.mode.toLowerCase() === 'raw';
-
- var scriptId = encodeURIComponent(scriptParams.id);
- if (!raw) {
- document.write(' ');
- } else {
- window.CLOSURE_NO_DEPS = true; // we've got our own deps file
- document.write(' ');
- document.write(' ');
- document.write(' ');
- }
- document.write(' ');
-}());
diff --git a/bin/split-example.py b/bin/split-example.py
deleted file mode 100644
index 8f8b92d4ce..0000000000
--- a/bin/split-example.py
+++ /dev/null
@@ -1,39 +0,0 @@
-import os
-import re
-import sys
-
-
-def split_example_file(example, dst_dir):
- lines = open(example, 'rU').readlines()
-
- target_lines = []
- target_require_lines = []
-
- found_requires = False
- found_code = False
- for line in lines:
- m = re.match(r'goog.require\(\'(.*)\'\);', line)
- if m:
- found_requires = True
- target_require_lines.append(line)
- elif found_requires:
- if found_code or line not in ('\n', '\r\n'):
- found_code = True
- target_lines.append(line)
-
- target = open(
- os.path.join(dst_dir, os.path.basename(example)), 'wb')
- target_require = open(
- os.path.join(dst_dir, os.path.basename(example)
- .replace('.js', '-require.js')),
- 'wb')
-
- target.writelines(target_lines)
- target.close()
-
- target_require.writelines(target_require_lines)
- target_require.close()
-
-
-if __name__ == '__main__':
- split_example_file(*sys.argv[1:])
diff --git a/package.json b/package.json
index 37bb432af1..09f5381a9e 100644
--- a/package.json
+++ b/package.json
@@ -9,24 +9,14 @@
],
"homepage": "https://openlayers.org/",
"scripts": {
- "install": "node tasks/install.js",
- "postinstall": "closure-util update",
- "start": "node tasks/serve.js",
"lint": "eslint tasks test src examples transforms",
- "lint-package": "eslint --fix build/package",
"pretest": "npm run lint",
"test": "npm run karma -- --single-run",
- "debug-server": "node tasks/serve-lib.js",
"karma": "karma start test/karma.config.js",
- "transform-src": "jscodeshift --transform transforms/module.js src",
- "changecase-src": "node tasks/filename-case-from-module.js",
- "transform-examples": "jscodeshift --transform transforms/module.js examples",
- "transform-test": "jscodeshift --transform transforms/module.js test",
- "transform": "npm run changecase-src && npm run transform-src && npm run transform-examples && npm run transform-test && npm run lint -- --fix",
"serve-examples": "mkdir -p build/examples && webpack --config examples/webpack/config.js --watch & serve build/examples",
"build-examples": "webpack --config examples/webpack/config.js --env=prod"
},
- "main": "dist/ol.js",
+ "main": "src/ol/index.js",
"repository": {
"type": "git",
"url": "git://github.com/openlayers/openlayers.git"
@@ -40,63 +30,49 @@
"css/ol.css"
],
"dependencies": {
- "async": "2.6.0",
- "closure-util": "1.26.0",
- "fs-extra": "5.0.0",
- "jsdoc": "3.5.5",
- "nomnom": "1.8.1",
"pbf": "3.1.0",
"pixelworks": "1.1.0",
- "rbush": "2.0.1",
- "rollup": "^0.52.0",
- "rollup-plugin-cleanup": "^2.0.0",
- "rollup-plugin-commonjs": "^8.2.6",
- "rollup-plugin-node-resolve": "^3.0.0",
- "temp": "0.8.3",
- "walk": "2.3.9"
+ "rbush": "2.0.1"
},
"devDependencies": {
+ "async": "2.6.0",
"babel-minify-webpack-plugin": "^0.2.0",
"clean-css-cli": "4.1.10",
"copy-webpack-plugin": "^4.0.1",
"coveralls": "3.0.0",
- "debounce": "^1.1.0",
"eslint": "4.13.1",
"eslint-config-openlayers": "7.0.0",
"eslint-plugin-openlayers-internal": "^3.1.0",
"expect.js": "0.3.1",
"front-matter": "^2.1.2",
- "gaze": "^1.0.0",
+ "fs-extra": "5.0.0",
"glob": "7.1.1",
"handlebars": "4.0.11",
"html-webpack-plugin": "^2.30.1",
"istanbul": "0.4.5",
"jquery": "3.2.1",
"jscodeshift": "^0.4.0",
+ "jsdoc": "3.5.5",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.1.1",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.1",
- "karma-mocha": "^1.3.0",
- "karma-sauce-launcher": "^1.1.0",
- "karma-webpack": "^2.0.4",
+ "karma-mocha": "1.3.0",
+ "karma-sauce-launcher": "1.2.0",
+ "karma-webpack": "2.0.6",
"marked": "0.3.7",
- "metalsmith": "2.3.0",
- "metalsmith-layouts": "1.8.1",
"mocha": "4.0.1",
- "mocha-phantomjs-core": "^2.1.0",
- "mustache": "2.3.0",
- "phantomjs-prebuilt": "2.1.16",
+ "mustache": "^2.3.0",
+ "nomnom": "1.8.1",
"pixelmatch": "^4.0.2",
"proj4": "2.4.4",
"serve": "^6.0.6",
- "serve-files": "1.0.1",
"sinon": "4.1.3",
- "slimerjs": "0.10.3",
"url-polyfill": "^1.0.7",
- "webpack": "^3.5.5",
- "webpack-dev-server": "^2.7.1",
- "webpack-merge": "^4.1.0"
+ "walk": "^2.3.9",
+ "webpack": "3.10.0",
+ "webpack-dev-server": "2.9.7",
+ "webpack-merge": "4.1.1"
},
"eslintConfig": {
"extends": "openlayers",
@@ -148,17 +124,5 @@
}
]
}
- },
- "ext": [{
- "module": "rbush"
- },
- {
- "module": "pbf",
- "name": "PBF"
- },
- {
- "module": "pixelworks",
- "import": "Processor"
- }
- ]
+ }
}
diff --git a/src/ol/render/webgl/circlereplay/defaultshader.glsl b/src/ol/render/webgl/circlereplay/defaultshader.glsl
index 47e1d421f1..c68cceb08f 100644
--- a/src/ol/render/webgl/circlereplay/defaultshader.glsl
+++ b/src/ol/render/webgl/circlereplay/defaultshader.glsl
@@ -1,4 +1,4 @@
-//! NAMESPACE=ol.render.webgl.circlereplay.defaultshader
+//! NAMESPACE=_ol_render_webgl_circlereplay_defaultshader_
//! COMMON
diff --git a/src/ol/render/webgl/circlereplay/defaultshader.js b/src/ol/render/webgl/circlereplay/defaultshader.js
index 4b51035a82..e6ba346fc6 100644
--- a/src/ol/render/webgl/circlereplay/defaultshader.js
+++ b/src/ol/render/webgl/circlereplay/defaultshader.js
@@ -1,13 +1,11 @@
-/**
- * @module ol/render/webgl/circlereplay/defaultshader
- */
-// This file is automatically generated, do not edit
+// This file is automatically generated, do not edit.
+// Run `make shaders` to generate, and commit the result.
+
import _ol_ from '../../../index.js';
import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js';
import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js';
var _ol_render_webgl_circlereplay_defaultshader_ = {};
-
_ol_render_webgl_circlereplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
'precision mediump float;\nvarying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\n\nuniform float u_opacity;\nuniform vec4 u_fillColor;\nuniform vec4 u_strokeColor;\nuniform vec2 u_size;\n\nvoid main(void) {\n vec2 windowCenter = vec2((v_center.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_center.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n vec2 windowOffset = vec2((v_offset.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_offset.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n float radius = length(windowCenter - windowOffset);\n float dist = length(windowCenter - gl_FragCoord.xy);\n if (dist > radius + v_halfWidth) {\n if (u_strokeColor.a == 0.0) {\n gl_FragColor = u_fillColor;\n } else {\n gl_FragColor = u_strokeColor;\n }\n gl_FragColor.a = gl_FragColor.a - (dist - (radius + v_halfWidth));\n } else if (u_fillColor.a == 0.0) {\n // Hooray, no fill, just stroke. We can use real antialiasing.\n gl_FragColor = u_strokeColor;\n if (dist < radius - v_halfWidth) {\n gl_FragColor.a = gl_FragColor.a - (radius - v_halfWidth - dist);\n }\n } else {\n gl_FragColor = u_fillColor;\n float strokeDist = radius - v_halfWidth;\n float antialias = 2.0 * v_pixelRatio;\n if (dist > strokeDist) {\n gl_FragColor = u_strokeColor;\n } else if (dist >= strokeDist - antialias) {\n float step = smoothstep(strokeDist - antialias, strokeDist, dist);\n gl_FragColor = mix(u_fillColor, u_strokeColor, step);\n }\n }\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n if (gl_FragColor.a <= 0.0) {\n discard;\n }\n}\n' :
'precision mediump float;varying vec2 a;varying vec2 b;varying float c;varying float d;uniform float m;uniform vec4 n;uniform vec4 o;uniform vec2 p;void main(void){vec2 windowCenter=vec2((a.x+1.0)/2.0*p.x*d,(a.y+1.0)/2.0*p.y*d);vec2 windowOffset=vec2((b.x+1.0)/2.0*p.x*d,(b.y+1.0)/2.0*p.y*d);float radius=length(windowCenter-windowOffset);float dist=length(windowCenter-gl_FragCoord.xy);if(dist>radius+c){if(o.a==0.0){gl_FragColor=n;}else{gl_FragColor=o;}gl_FragColor.a=gl_FragColor.a-(dist-(radius+c));}else if(n.a==0.0){gl_FragColor=o;if(diststrokeDist){gl_FragColor=o;}else if(dist>=strokeDist-antialias){float step=smoothstep(strokeDist-antialias,strokeDist,dist);gl_FragColor=mix(n,o,step);}} gl_FragColor.a=gl_FragColor.a*m;if(gl_FragColor.a<=0.0){discard;}}');
@@ -15,4 +13,5 @@ _ol_render_webgl_circlereplay_defaultshader_.fragment = new _ol_webgl_Fragment_(
_ol_render_webgl_circlereplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
'varying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\nattribute vec2 a_position;\nattribute float a_instruction;\nattribute float a_radius;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n v_center = vec4(u_projectionMatrix * vec4(a_position, 0.0, 1.0)).xy;\n v_pixelRatio = u_pixelRatio;\n float lineWidth = u_lineWidth * u_pixelRatio;\n v_halfWidth = lineWidth / 2.0;\n if (lineWidth == 0.0) {\n lineWidth = 2.0 * u_pixelRatio;\n }\n vec2 offset;\n // Radius with anitaliasing (roughly).\n float radius = a_radius + 3.0 * u_pixelRatio;\n // Until we get gl_VertexID in WebGL, we store an instruction.\n if (a_instruction == 0.0) {\n // Offsetting the edges of the triangle by lineWidth / 2 is necessary, however\n // we should also leave some space for the antialiasing, thus we offset by lineWidth.\n offset = vec2(-1.0, 1.0);\n } else if (a_instruction == 1.0) {\n offset = vec2(-1.0, -1.0);\n } else if (a_instruction == 2.0) {\n offset = vec2(1.0, -1.0);\n } else {\n offset = vec2(1.0, 1.0);\n }\n\n gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0.0, 1.0) +\n offsetMatrix * vec4(offset * lineWidth, 0.0, 0.0);\n v_offset = vec4(u_projectionMatrix * vec4(a_position.x + a_radius, a_position.y,\n 0.0, 1.0)).xy;\n\n if (distance(v_center, v_offset) > 20000.0) {\n gl_Position = vec4(v_center, 0.0, 1.0);\n }\n}\n\n\n' :
'varying vec2 a;varying vec2 b;varying float c;varying float d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;void main(void){mat4 offsetMatrix=i*j;a=vec4(h*vec4(e,0.0,1.0)).xy;d=l;float lineWidth=k*l;c=lineWidth/2.0;if(lineWidth==0.0){lineWidth=2.0*l;}vec2 offset;float radius=g+3.0*l;//Until we get gl_VertexID in WebGL,we store an instruction.if(f==0.0){//Offsetting the edges of the triangle by lineWidth/2 is necessary,however//we should also leave some space for the antialiasing,thus we offset by lineWidth.offset=vec2(-1.0,1.0);}else if(f==1.0){offset=vec2(-1.0,-1.0);}else if(f==2.0){offset=vec2(1.0,-1.0);}else{offset=vec2(1.0,1.0);}gl_Position=h*vec4(e+offset*radius,0.0,1.0)+offsetMatrix*vec4(offset*lineWidth,0.0,0.0);b=vec4(h*vec4(e.x+g,e.y,0.0,1.0)).xy;if(distance(a,b)>20000.0){gl_Position=vec4(a,0.0,1.0);}}');
+
export default _ol_render_webgl_circlereplay_defaultshader_;
diff --git a/src/ol/render/webgl/linestringreplay/defaultshader.glsl b/src/ol/render/webgl/linestringreplay/defaultshader.glsl
index 1bc1408836..b04d05cdc3 100644
--- a/src/ol/render/webgl/linestringreplay/defaultshader.glsl
+++ b/src/ol/render/webgl/linestringreplay/defaultshader.glsl
@@ -1,4 +1,4 @@
-//! NAMESPACE=ol.render.webgl.linestringreplay.defaultshader
+//! NAMESPACE=_ol_render_webgl_linestringreplay_defaultshader_
//! COMMON
diff --git a/src/ol/render/webgl/linestringreplay/defaultshader.js b/src/ol/render/webgl/linestringreplay/defaultshader.js
index c03bbf3d7a..df3f2323f6 100644
--- a/src/ol/render/webgl/linestringreplay/defaultshader.js
+++ b/src/ol/render/webgl/linestringreplay/defaultshader.js
@@ -1,13 +1,11 @@
-/**
- * @module ol/render/webgl/linestringreplay/defaultshader
- */
-// This file is automatically generated, do not edit
+// This file is automatically generated, do not edit.
+// Run `make shaders` to generate, and commit the result.
+
import _ol_ from '../../../index.js';
import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js';
import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js';
var _ol_render_webgl_linestringreplay_defaultshader_ = {};
-
_ol_render_webgl_linestringreplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
'precision mediump float;\nvarying float v_round;\nvarying vec2 v_roundVertex;\nvarying float v_halfWidth;\n\n\n\nuniform float u_opacity;\nuniform vec4 u_color;\nuniform vec2 u_size;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n if (v_round > 0.0) {\n vec2 windowCoords = vec2((v_roundVertex.x + 1.0) / 2.0 * u_size.x * u_pixelRatio,\n (v_roundVertex.y + 1.0) / 2.0 * u_size.y * u_pixelRatio);\n if (length(windowCoords - gl_FragCoord.xy) > v_halfWidth * u_pixelRatio) {\n discard;\n }\n }\n gl_FragColor = u_color;\n float alpha = u_color.a * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n' :
'precision mediump float;varying float a;varying vec2 aVertex;varying float c;uniform float m;uniform vec4 n;uniform vec2 o;uniform float p;void main(void){if(a>0.0){vec2 windowCoords=vec2((aVertex.x+1.0)/2.0*o.x*p,(aVertex.y+1.0)/2.0*o.y*p);if(length(windowCoords-gl_FragCoord.xy)>c*p){discard;}} gl_FragColor=n;float alpha=n.a*m;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}');
@@ -15,4 +13,5 @@ _ol_render_webgl_linestringreplay_defaultshader_.fragment = new _ol_webgl_Fragme
_ol_render_webgl_linestringreplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
'varying float v_round;\nvarying vec2 v_roundVertex;\nvarying float v_halfWidth;\n\n\nattribute vec2 a_lastPos;\nattribute vec2 a_position;\nattribute vec2 a_nextPos;\nattribute float a_direction;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_miterLimit;\n\nbool nearlyEquals(in float value, in float ref) {\n float epsilon = 0.000000000001;\n return value >= ref - epsilon && value <= ref + epsilon;\n}\n\nvoid alongNormal(out vec2 offset, in vec2 nextP, in float turnDir, in float direction) {\n vec2 dirVect = nextP - a_position;\n vec2 normal = normalize(vec2(-turnDir * dirVect.y, turnDir * dirVect.x));\n offset = u_lineWidth / 2.0 * normal * direction;\n}\n\nvoid miterUp(out vec2 offset, out float round, in bool isRound, in float direction) {\n float halfWidth = u_lineWidth / 2.0;\n vec2 tangent = normalize(normalize(a_nextPos - a_position) + normalize(a_position - a_lastPos));\n vec2 normal = vec2(-tangent.y, tangent.x);\n vec2 dirVect = a_nextPos - a_position;\n vec2 tmpNormal = normalize(vec2(-dirVect.y, dirVect.x));\n float miterLength = abs(halfWidth / dot(normal, tmpNormal));\n offset = normal * direction * miterLength;\n round = 0.0;\n if (isRound) {\n round = 1.0;\n } else if (miterLength > u_miterLimit + u_lineWidth) {\n offset = halfWidth * tmpNormal * direction;\n }\n}\n\nbool miterDown(out vec2 offset, in vec4 projPos, in mat4 offsetMatrix, in float direction) {\n bool degenerate = false;\n vec2 tangent = normalize(normalize(a_nextPos - a_position) + normalize(a_position - a_lastPos));\n vec2 normal = vec2(-tangent.y, tangent.x);\n vec2 dirVect = a_lastPos - a_position;\n vec2 tmpNormal = normalize(vec2(-dirVect.y, dirVect.x));\n vec2 longOffset, shortOffset, longVertex;\n vec4 shortProjVertex;\n float halfWidth = u_lineWidth / 2.0;\n if (length(a_nextPos - a_position) > length(a_lastPos - a_position)) {\n longOffset = tmpNormal * direction * halfWidth;\n shortOffset = normalize(vec2(dirVect.y, -dirVect.x)) * direction * halfWidth;\n longVertex = a_nextPos;\n shortProjVertex = u_projectionMatrix * vec4(a_lastPos, 0.0, 1.0);\n } else {\n shortOffset = tmpNormal * direction * halfWidth;\n longOffset = normalize(vec2(dirVect.y, -dirVect.x)) * direction * halfWidth;\n longVertex = a_lastPos;\n shortProjVertex = u_projectionMatrix * vec4(a_nextPos, 0.0, 1.0);\n }\n //Intersection algorithm based on theory by Paul Bourke (http://paulbourke.net/geometry/pointlineplane/).\n vec4 p1 = u_projectionMatrix * vec4(longVertex, 0.0, 1.0) + offsetMatrix * vec4(longOffset, 0.0, 0.0);\n vec4 p2 = projPos + offsetMatrix * vec4(longOffset, 0.0, 0.0);\n vec4 p3 = shortProjVertex + offsetMatrix * vec4(-shortOffset, 0.0, 0.0);\n vec4 p4 = shortProjVertex + offsetMatrix * vec4(shortOffset, 0.0, 0.0);\n float denom = (p4.y - p3.y) * (p2.x - p1.x) - (p4.x - p3.x) * (p2.y - p1.y);\n float firstU = ((p4.x - p3.x) * (p1.y - p3.y) - (p4.y - p3.y) * (p1.x - p3.x)) / denom;\n float secondU = ((p2.x - p1.x) * (p1.y - p3.y) - (p2.y - p1.y) * (p1.x - p3.x)) / denom;\n float epsilon = 0.000000000001;\n if (firstU > epsilon && firstU < 1.0 - epsilon && secondU > epsilon && secondU < 1.0 - epsilon) {\n shortProjVertex.x = p1.x + firstU * (p2.x - p1.x);\n shortProjVertex.y = p1.y + firstU * (p2.y - p1.y);\n offset = shortProjVertex.xy;\n degenerate = true;\n } else {\n float miterLength = abs(halfWidth / dot(normal, tmpNormal));\n offset = normal * direction * miterLength;\n }\n return degenerate;\n}\n\nvoid squareCap(out vec2 offset, out float round, in bool isRound, in vec2 nextP,\n in float turnDir, in float direction) {\n round = 0.0;\n vec2 dirVect = a_position - nextP;\n vec2 firstNormal = normalize(dirVect);\n vec2 secondNormal = vec2(turnDir * firstNormal.y * direction, -turnDir * firstNormal.x * direction);\n vec2 hypotenuse = normalize(firstNormal - secondNormal);\n vec2 normal = vec2(turnDir * hypotenuse.y * direction, -turnDir * hypotenuse.x * direction);\n float length = sqrt(v_halfWidth * v_halfWidth * 2.0);\n offset = normal * length;\n if (isRound) {\n round = 1.0;\n }\n}\n\nvoid main(void) {\n bool degenerate = false;\n float direction = float(sign(a_direction));\n mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n vec2 offset;\n vec4 projPos = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n bool round = nearlyEquals(mod(a_direction, 2.0), 0.0);\n\n v_round = 0.0;\n v_halfWidth = u_lineWidth / 2.0;\n v_roundVertex = projPos.xy;\n\n if (nearlyEquals(mod(a_direction, 3.0), 0.0) || nearlyEquals(mod(a_direction, 17.0), 0.0)) {\n alongNormal(offset, a_nextPos, 1.0, direction);\n } else if (nearlyEquals(mod(a_direction, 5.0), 0.0) || nearlyEquals(mod(a_direction, 13.0), 0.0)) {\n alongNormal(offset, a_lastPos, -1.0, direction);\n } else if (nearlyEquals(mod(a_direction, 23.0), 0.0)) {\n miterUp(offset, v_round, round, direction);\n } else if (nearlyEquals(mod(a_direction, 19.0), 0.0)) {\n degenerate = miterDown(offset, projPos, offsetMatrix, direction);\n } else if (nearlyEquals(mod(a_direction, 7.0), 0.0)) {\n squareCap(offset, v_round, round, a_nextPos, 1.0, direction);\n } else if (nearlyEquals(mod(a_direction, 11.0), 0.0)) {\n squareCap(offset, v_round, round, a_lastPos, -1.0, direction);\n }\n if (!degenerate) {\n vec4 offsets = offsetMatrix * vec4(offset, 0.0, 0.0);\n gl_Position = projPos + offsets;\n } else {\n gl_Position = vec4(offset, 0.0, 1.0);\n }\n}\n\n\n' :
'varying float a;varying vec2 aVertex;varying float c;attribute vec2 d;attribute vec2 e;attribute vec2 f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;bool nearlyEquals(in float value,in float ref){float epsilon=0.000000000001;return value>=ref-epsilon&&value<=ref+epsilon;}void alongNormal(out vec2 offset,in vec2 nextP,in float turnDir,in float direction){vec2 dirVect=nextP-e;vec2 normal=normalize(vec2(-turnDir*dirVect.y,turnDir*dirVect.x));offset=k/2.0*normal*direction;}void miterUp(out vec2 offset,out float round,in bool isRound,in float direction){float halfWidth=k/2.0;vec2 tangent=normalize(normalize(f-e)+normalize(e-d));vec2 normal=vec2(-tangent.y,tangent.x);vec2 dirVect=f-e;vec2 tmpNormal=normalize(vec2(-dirVect.y,dirVect.x));float miterLength=abs(halfWidth/dot(normal,tmpNormal));offset=normal*direction*miterLength;round=0.0;if(isRound){round=1.0;}else if(miterLength>l+k){offset=halfWidth*tmpNormal*direction;}} bool miterDown(out vec2 offset,in vec4 projPos,in mat4 offsetMatrix,in float direction){bool degenerate=false;vec2 tangent=normalize(normalize(f-e)+normalize(e-d));vec2 normal=vec2(-tangent.y,tangent.x);vec2 dirVect=d-e;vec2 tmpNormal=normalize(vec2(-dirVect.y,dirVect.x));vec2 longOffset,shortOffset,longVertex;vec4 shortProjVertex;float halfWidth=k/2.0;if(length(f-e)>length(d-e)){longOffset=tmpNormal*direction*halfWidth;shortOffset=normalize(vec2(dirVect.y,-dirVect.x))*direction*halfWidth;longVertex=f;shortProjVertex=h*vec4(d,0.0,1.0);}else{shortOffset=tmpNormal*direction*halfWidth;longOffset=normalize(vec2(dirVect.y,-dirVect.x))*direction*halfWidth;longVertex=d;shortProjVertex=h*vec4(f,0.0,1.0);}vec4 p1=h*vec4(longVertex,0.0,1.0)+offsetMatrix*vec4(longOffset,0.0,0.0);vec4 p2=projPos+offsetMatrix*vec4(longOffset,0.0,0.0);vec4 p3=shortProjVertex+offsetMatrix*vec4(-shortOffset,0.0,0.0);vec4 p4=shortProjVertex+offsetMatrix*vec4(shortOffset,0.0,0.0);float denom=(p4.y-p3.y)*(p2.x-p1.x)-(p4.x-p3.x)*(p2.y-p1.y);float firstU=((p4.x-p3.x)*(p1.y-p3.y)-(p4.y-p3.y)*(p1.x-p3.x))/denom;float secondU=((p2.x-p1.x)*(p1.y-p3.y)-(p2.y-p1.y)*(p1.x-p3.x))/denom;float epsilon=0.000000000001;if(firstU>epsilon&&firstU<1.0-epsilon&&secondU>epsilon&&secondU<1.0-epsilon){shortProjVertex.x=p1.x+firstU*(p2.x-p1.x);shortProjVertex.y=p1.y+firstU*(p2.y-p1.y);offset=shortProjVertex.xy;degenerate=true;}else{float miterLength=abs(halfWidth/dot(normal,tmpNormal));offset=normal*direction*miterLength;}return degenerate;}void squareCap(out vec2 offset,out float round,in bool isRound,in vec2 nextP,in float turnDir,in float direction){round=0.0;vec2 dirVect=e-nextP;vec2 firstNormal=normalize(dirVect);vec2 secondNormal=vec2(turnDir*firstNormal.y*direction,-turnDir*firstNormal.x*direction);vec2 hypotenuse=normalize(firstNormal-secondNormal);vec2 normal=vec2(turnDir*hypotenuse.y*direction,-turnDir*hypotenuse.x*direction);float length=sqrt(c*c*2.0);offset=normal*length;if(isRound){round=1.0;}} void main(void){bool degenerate=false;float direction=float(sign(g));mat4 offsetMatrix=i*j;vec2 offset;vec4 projPos=h*vec4(e,0.0,1.0);bool round=nearlyEquals(mod(g,2.0),0.0);a=0.0;c=k/2.0;aVertex=projPos.xy;if(nearlyEquals(mod(g,3.0),0.0)||nearlyEquals(mod(g,17.0),0.0)){alongNormal(offset,f,1.0,direction);}else if(nearlyEquals(mod(g,5.0),0.0)||nearlyEquals(mod(g,13.0),0.0)){alongNormal(offset,d,-1.0,direction);}else if(nearlyEquals(mod(g,23.0),0.0)){miterUp(offset,a,round,direction);}else if(nearlyEquals(mod(g,19.0),0.0)){degenerate=miterDown(offset,projPos,offsetMatrix,direction);}else if(nearlyEquals(mod(g,7.0),0.0)){squareCap(offset,a,round,f,1.0,direction);}else if(nearlyEquals(mod(g,11.0),0.0)){squareCap(offset,a,round,d,-1.0,direction);}if(!degenerate){vec4 offsets=offsetMatrix*vec4(offset,0.0,0.0);gl_Position=projPos+offsets;}else{gl_Position=vec4(offset,0.0,1.0);}}');
+
export default _ol_render_webgl_linestringreplay_defaultshader_;
diff --git a/src/ol/render/webgl/polygonreplay/defaultshader.glsl b/src/ol/render/webgl/polygonreplay/defaultshader.glsl
index b90498fd0f..6e0ded8d5a 100644
--- a/src/ol/render/webgl/polygonreplay/defaultshader.glsl
+++ b/src/ol/render/webgl/polygonreplay/defaultshader.glsl
@@ -1,4 +1,4 @@
-//! NAMESPACE=ol.render.webgl.polygonreplay.defaultshader
+//! NAMESPACE=_ol_render_webgl_polygonreplay_defaultshader_
//! COMMON
diff --git a/src/ol/render/webgl/polygonreplay/defaultshader.js b/src/ol/render/webgl/polygonreplay/defaultshader.js
index 564af702ec..03dd482d32 100644
--- a/src/ol/render/webgl/polygonreplay/defaultshader.js
+++ b/src/ol/render/webgl/polygonreplay/defaultshader.js
@@ -1,13 +1,11 @@
-/**
- * @module ol/render/webgl/polygonreplay/defaultshader
- */
-// This file is automatically generated, do not edit
+// This file is automatically generated, do not edit.
+// Run `make shaders` to generate, and commit the result.
+
import _ol_ from '../../../index.js';
import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js';
import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js';
var _ol_render_webgl_polygonreplay_defaultshader_ = {};
-
_ol_render_webgl_polygonreplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
'precision mediump float;\n\n\n\nuniform vec4 u_color;\nuniform float u_opacity;\n\nvoid main(void) {\n gl_FragColor = u_color;\n float alpha = u_color.a * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n' :
'precision mediump float;uniform vec4 e;uniform float f;void main(void){gl_FragColor=e;float alpha=e.a*f;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}');
@@ -15,4 +13,5 @@ _ol_render_webgl_polygonreplay_defaultshader_.fragment = new _ol_webgl_Fragment_
_ol_render_webgl_polygonreplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
'\n\nattribute vec2 a_position;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n}\n\n\n' :
'attribute vec2 a;uniform mat4 b;uniform mat4 c;uniform mat4 d;void main(void){gl_Position=b*vec4(a,0.0,1.0);}');
+
export default _ol_render_webgl_polygonreplay_defaultshader_;
diff --git a/src/ol/render/webgl/texturereplay/defaultshader.glsl b/src/ol/render/webgl/texturereplay/defaultshader.glsl
index 870c27269c..affbff08be 100644
--- a/src/ol/render/webgl/texturereplay/defaultshader.glsl
+++ b/src/ol/render/webgl/texturereplay/defaultshader.glsl
@@ -1,4 +1,4 @@
-//! NAMESPACE=ol.render.webgl.texturereplay.defaultshader
+//! NAMESPACE=_ol_render_webgl_texturereplay_defaultshader_
//! COMMON
diff --git a/src/ol/render/webgl/texturereplay/defaultshader.js b/src/ol/render/webgl/texturereplay/defaultshader.js
index aa4de3dfb1..a276ebfda4 100644
--- a/src/ol/render/webgl/texturereplay/defaultshader.js
+++ b/src/ol/render/webgl/texturereplay/defaultshader.js
@@ -1,13 +1,11 @@
-/**
- * @module ol/render/webgl/texturereplay/defaultshader
- */
-// This file is automatically generated, do not edit
+// This file is automatically generated, do not edit.
+// Run `make shaders` to generate, and commit the result.
+
import _ol_ from '../../../index.js';
import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js';
import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js';
var _ol_render_webgl_texturereplay_defaultshader_ = {};
-
_ol_render_webgl_texturereplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
'precision mediump float;\nvarying vec2 v_texCoord;\nvarying float v_opacity;\n\nuniform float u_opacity;\nuniform sampler2D u_image;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_image, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n float alpha = texColor.a * v_opacity * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n' :
'precision mediump float;varying vec2 a;varying float b;uniform float k;uniform sampler2D l;void main(void){vec4 texColor=texture2D(l,a);gl_FragColor.rgb=texColor.rgb;float alpha=texColor.a*b*k;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}');
@@ -15,4 +13,5 @@ _ol_render_webgl_texturereplay_defaultshader_.fragment = new _ol_webgl_Fragment_
_ol_render_webgl_texturereplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n' :
'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.0,0.0);gl_Position=h*vec4(c,0.0,1.0)+offsets;a=d;b=f;}');
+
export default _ol_render_webgl_texturereplay_defaultshader_;
diff --git a/src/ol/renderer/webgl/defaultmapshader.glsl b/src/ol/renderer/webgl/defaultmapshader.glsl
index 56d5bd1c82..6621e9cf22 100644
--- a/src/ol/renderer/webgl/defaultmapshader.glsl
+++ b/src/ol/renderer/webgl/defaultmapshader.glsl
@@ -1,4 +1,4 @@
-//! NAMESPACE=ol.renderer.webgl.defaultmapshader
+//! NAMESPACE=_ol_renderer_webgl_defaultmapshader_
//! COMMON
diff --git a/src/ol/renderer/webgl/defaultmapshader.js b/src/ol/renderer/webgl/defaultmapshader.js
index 158ac27381..e2446c300d 100644
--- a/src/ol/renderer/webgl/defaultmapshader.js
+++ b/src/ol/renderer/webgl/defaultmapshader.js
@@ -1,13 +1,11 @@
-/**
- * @module ol/renderer/webgl/defaultmapshader
- */
-// This file is automatically generated, do not edit
+// This file is automatically generated, do not edit.
+// Run `make shaders` to generate, and commit the result.
+
import _ol_ from '../../index.js';
import _ol_webgl_Fragment_ from '../../webgl/Fragment.js';
import _ol_webgl_Vertex_ from '../../webgl/Vertex.js';
var _ol_renderer_webgl_defaultmapshader_ = {};
-
_ol_renderer_webgl_defaultmapshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform float u_opacity;\nuniform sampler2D u_texture;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_texture, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n gl_FragColor.a = texColor.a * u_opacity;\n}\n' :
'precision mediump float;varying vec2 a;uniform float f;uniform sampler2D g;void main(void){vec4 texColor=texture2D(g,a);gl_FragColor.rgb=texColor.rgb;gl_FragColor.a=texColor.a*f;}');
@@ -15,4 +13,5 @@ _ol_renderer_webgl_defaultmapshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEB
_ol_renderer_webgl_defaultmapshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
'varying vec2 v_texCoord;\n\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\n\nuniform mat4 u_texCoordMatrix;\nuniform mat4 u_projectionMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.);\n v_texCoord = (u_texCoordMatrix * vec4(a_texCoord, 0., 1.)).st;\n}\n\n\n' :
'varying vec2 a;attribute vec2 b;attribute vec2 c;uniform mat4 d;uniform mat4 e;void main(void){gl_Position=e*vec4(b,0.,1.);a=(d*vec4(c,0.,1.)).st;}');
+
export default _ol_renderer_webgl_defaultmapshader_;
diff --git a/src/ol/renderer/webgl/tilelayershader.glsl b/src/ol/renderer/webgl/tilelayershader.glsl
index 4a88e8853b..59b9aa04c8 100644
--- a/src/ol/renderer/webgl/tilelayershader.glsl
+++ b/src/ol/renderer/webgl/tilelayershader.glsl
@@ -1,4 +1,4 @@
-//! NAMESPACE=ol.renderer.webgl.tilelayershader
+//! NAMESPACE=_ol_renderer_webgl_tilelayershader_
//! COMMON
diff --git a/src/ol/renderer/webgl/tilelayershader.js b/src/ol/renderer/webgl/tilelayershader.js
index 7bbcbc7c8a..e5796690e1 100644
--- a/src/ol/renderer/webgl/tilelayershader.js
+++ b/src/ol/renderer/webgl/tilelayershader.js
@@ -1,13 +1,11 @@
-/**
- * @module ol/renderer/webgl/tilelayershader
- */
-// This file is automatically generated, do not edit
+// This file is automatically generated, do not edit.
+// Run `make shaders` to generate, and commit the result.
+
import _ol_ from '../../index.js';
import _ol_webgl_Fragment_ from '../../webgl/Fragment.js';
import _ol_webgl_Vertex_ from '../../webgl/Vertex.js';
var _ol_renderer_webgl_tilelayershader_ = {};
-
_ol_renderer_webgl_tilelayershader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform sampler2D u_texture;\n\nvoid main(void) {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n}\n' :
'precision mediump float;varying vec2 a;uniform sampler2D e;void main(void){gl_FragColor=texture2D(e,a);}');
@@ -15,4 +13,5 @@ _ol_renderer_webgl_tilelayershader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBU
_ol_renderer_webgl_tilelayershader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
'varying vec2 v_texCoord;\n\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nuniform vec4 u_tileOffset;\n\nvoid main(void) {\n gl_Position = vec4(a_position * u_tileOffset.xy + u_tileOffset.zw, 0., 1.);\n v_texCoord = a_texCoord;\n}\n\n\n' :
'varying vec2 a;attribute vec2 b;attribute vec2 c;uniform vec4 d;void main(void){gl_Position=vec4(b*d.xy+d.zw,0.,1.);a=c;}');
+
export default _ol_renderer_webgl_tilelayershader_;
diff --git a/src/ol/webgl/shader.mustache b/src/ol/webgl/shader.mustache
index 33c6c16e4b..ff5e494886 100644
--- a/src/ol/webgl/shader.mustache
+++ b/src/ol/webgl/shader.mustache
@@ -1,15 +1,17 @@
-// This file is automatically generated, do not edit
-goog.provide('{{namespace}}');
+// This file is automatically generated, do not edit.
+// Run `make shaders` to generate, and commit the result.
-goog.require('ol');
-goog.require('ol.webgl.Fragment');
-goog.require('ol.webgl.Vertex');
+import _ol_ from '../../index.js';
+import _ol_webgl_Fragment_ from '../../webgl/Fragment.js';
+import _ol_webgl_Vertex_ from '../../webgl/Vertex.js';
+var {{namespace}} = {};
-
-{{namespace}}.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ?
+{{namespace}}.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
'precision mediump float;\n{{{originalFragmentSource}}}' :
'precision mediump float;{{{fragmentSource}}}');
-{{namespace}}.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ?
+{{namespace}}.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
'{{{originalVertexSource}}}' :
'{{{vertexSource}}}');
+
+export default {{namespace}};
diff --git a/src/ol/webgl/shaderlocations.mustache b/src/ol/webgl/shaderlocations.mustache
index a2e1a15934..1278783e5b 100644
--- a/src/ol/webgl/shaderlocations.mustache
+++ b/src/ol/webgl/shaderlocations.mustache
@@ -1,8 +1,7 @@
// This file is automatically generated, do not edit
-goog.provide('{{namespace}}.Locations');
-
-goog.require('ol');
+// Run `make shaders` to generate, and commit the result.
+import _ol_ from '../../../index.js';
/**
* @constructor
@@ -10,14 +9,14 @@ goog.require('ol');
* @param {WebGLProgram} program Program.
* @struct
*/
-{{namespace}}.Locations = function(gl, program) {
+{{namespace}}_Locations_ = function(gl, program) {
{{#uniforms}}
/**
* @type {WebGLUniformLocation}
*/
this.{{originalName}} = gl.getUniformLocation(
- program, ol.DEBUG_WEBGL ? '{{originalName}}' : '{{shortName}}');
+ program, _ol_.DEBUG_WEBGL ? '{{originalName}}' : '{{shortName}}');
{{/uniforms}}
{{#attributes}}
@@ -25,6 +24,8 @@ goog.require('ol');
* @type {number}
*/
this.{{originalName}} = gl.getAttribLocation(
- program, ol.DEBUG_WEBGL ? '{{originalName}}' : '{{shortName}}');
+ program, _ol_.DEBUG_WEBGL ? '{{originalName}}' : '{{shortName}}');
{{/attributes}}
};
+
+export default {{namespace}}_Locations_;
diff --git a/tasks/build-examples.js b/tasks/build-examples.js
deleted file mode 100644
index 47054ea603..0000000000
--- a/tasks/build-examples.js
+++ /dev/null
@@ -1,272 +0,0 @@
-var path = require('path');
-
-var Metalsmith = require('metalsmith');
-var handlebars = require('handlebars');
-var templates = require('metalsmith-layouts');
-var marked = require('marked');
-var pkg = require('../package.json');
-
-var markupRegEx = /([^\/^\.]*)\.html$/;
-var cleanupJSRegEx = /.*(\/\/ NOCOMPILE|goog\.require\(.*\);)[\r\n]*/g;
-var requiresRegEx = /.*goog\.require\('(ol\.\S*)'\);/g;
-var isCssRegEx = /\.css$/;
-var isJsRegEx = /\.js(\?.*)?$/;
-
-var srcDir = path.join(__dirname, '..', 'examples');
-var destDir = path.join(__dirname, '..', 'build', 'examples');
-var templatesDir = path.join(__dirname, '..', 'config', 'examples');
-
-/**
- * Returns an array of names that are explicitly required inside the source
- * by calling `goog.require('ol.…')`. Only returns `ol.` prefixed names.
- *
- * @param {string} src The JavaScript sourcecode to search for goog.require.
- * @returns {Array.} An array of `ol.*` names.
- */
-function getRequires(src) {
- var requires = [];
- var match = requiresRegEx.exec(src);
- while (match) {
- requires.push(match[1]);
- match = requiresRegEx.exec(src);
- }
- return requires;
-}
-
-/**
- * Takes an array of the names of required OpenLayers symbols and returns an
- * HTML-snippet with an unordered list to the API-docs for the particular
- * classes.
- *
- * @param {Array.} requires An array of `ol.` names that the source
- * requires.
- * @returns {string} The HTML-snippet with the list of links to API-docs.
- */
-function getLinkToApiHtml(requires) {
- var lis = requires.map(function(symb) {
- var href = '../apidoc/' + symb + '.html';
- return '' + symb + ' ';
- });
- return '';
-}
-
-/**
- * A Metalsmith plugin that adds metadata to the example HTML files. For each
- * example HTML file, this adds metadata for related js and css resources. When
- * these files are run through the example template, the extra metadata is used
- * to show the complete example source in the textarea and submit the parts to
- * CodePen.
- *
- * @param {Object} files The file lookup provided by Metalsmith. Property names
- * are file paths relative to the source directory. The file objects
- * include any existing metadata (e.g. from YAML front-matter), the file
- * contents, and stats.
- * @param {Object} metalsmith The metalsmith instance the plugin is being used
- * with.
- * @param {function(Error)} done Called when done (with any error).
- */
-function augmentExamples(files, metalsmith, done) {
- setImmediate(done); // all remaining code is synchronous
- for (var filename in files) {
- var file = files[filename];
- var match = filename.match(markupRegEx);
- if (match && filename !== 'index.html') {
- if (!file.layout) {
- throw new Error(filename + ': Missing "layout" in YAML front-matter');
- }
- var id = match[1];
-
- // add js tag and source
- var jsFilename = id + '.js';
- if (!(jsFilename in files)) {
- throw new Error('No .js file found for ' + filename);
- }
- var jsSource = files[jsFilename].contents.toString()
- // Change data paths to absolute urls
- .replace(/'data\//g, '\'https://openlayers.org/en/v' + pkg.version + '/examples/data/');
- if (file.cloak) {
- for (var key in file.cloak) {
- jsSource = jsSource.replace(new RegExp(key, 'g'), file.cloak[key]);
- }
- }
- var requires = getRequires(jsSource);
- file.requires = requires;
- file.js = {
- tag: '',
- source: jsSource.replace(cleanupJSRegEx, ''),
- apiHtml: getLinkToApiHtml(requires)
- };
-
- // add css tag and source
- var cssFilename = id + '.css';
- if (cssFilename in files) {
- file.css = {
- tag: ' ',
- source: files[cssFilename].contents.toString()
- };
- }
-
- // add additional resources
- if (file.resources) {
- var resources = [];
- var remoteResources = [];
- var codePenResources = [];
- for (var i = 0, ii = file.resources.length; i < ii; ++i) {
- var resource = file.resources[i];
- var remoteResource = resource.indexOf('//') === -1 ?
- 'https://openlayers.org/en/v' + pkg.version + '/examples/' +
- resource : resource;
- codePenResources[i] = remoteResource;
- if (isJsRegEx.test(resource)) {
- resources[i] = '';
- remoteResources[i] = '';
- } else if (isCssRegEx.test(resource)) {
- if (resource.indexOf('bootstrap.min.css') === -1) {
- resources[i] = ' ';
- }
- remoteResources[i] = ' ';
- } else {
- throw new Error('Invalid value for resource: ' +
- resource + ' is not .js or .css: ' + filename);
- }
- }
- file.extraHead = {
- local: resources.join('\n'),
- remote: remoteResources.join('\n')
- };
- file.extraResources = file.resources.length ?
- ',' + codePenResources.join(',') : '';
- }
- }
- }
-}
-
-/**
- * Create an inverted index of keywords from examples. Property names are
- * lowercased words. Property values are objects mapping example index to word
- * count.
- * @param {Array.} exampleInfos Array of example info objects.
- * @return {Object} Word index.
- */
-function createWordIndex(exampleInfos) {
- var index = {};
- var keys = ['shortdesc', 'title', 'tags', 'requires'];
- exampleInfos.forEach(function(info, i) {
- keys.forEach(function(key) {
- var text = info[key];
- if (Array.isArray(text)) {
- text = text.join(' ');
- }
- var words = text ? text.split(/\W+/) : [];
- words.forEach(function(word) {
- if (word) {
- word = word.toLowerCase();
- var counts = index[word];
- if (counts) {
- if (index in counts) {
- counts[i] += 1;
- } else {
- counts[i] = 1;
- }
- } else {
- counts = {};
- counts[i] = 1;
- index[word] = counts;
- }
- }
- });
- });
- });
- return index;
-}
-
-/**
- * A plugin that generates the example index.js file. This file includes a
- * list of example metadata objects and a word index used when searching for
- * examples.
- * @param {Object} files The file lookup provided by Metalsmith. Property names
- * are file paths relative to the source directory. The file objects
- * include any existing metadata (e.g. from YAML front-matter), the file
- * contents, and stats.
- * @param {Object} metalsmith The metalsmith instance the plugin is being used
- * with.
- * @param {function(Error)} done Called when done (with any error).
- */
-function createIndex(files, metalsmith, done) {
- setImmediate(done); // all remaining code is synchronous
- var exampleInfos = [];
- for (var filename in files) {
- var example = files[filename];
- if (markupRegEx.test(filename) && filename !== 'index.html') {
- exampleInfos.push({
- link: filename,
- example: filename,
- title: example.title,
- shortdesc: example.shortdesc,
- tags: example.tags,
- requires: example.requires
- });
- }
- }
- var info = {
- examples: exampleInfos,
- index: createWordIndex(exampleInfos)
- };
- files['index.js'] = {
- contents: new Buffer('var info = ' + JSON.stringify(info)),
- mode: '0644'
- };
-}
-
-function main(callback) {
- var smith = new Metalsmith('.')
- .source(srcDir)
- .destination(destDir)
- .concurrency(25)
- .metadata({
- olVersion: pkg.version
- })
- .use(augmentExamples)
- .use(createIndex)
- .use(templates({
- engine: 'handlebars',
- directory: templatesDir,
- helpers: {
- md: function(str) {
- return new handlebars.SafeString(marked(str));
- },
- indent: function(text, options) {
- if (!text) {
- return text;
- }
- var count = options.hash.spaces || 2;
- var spaces = new Array(count + 1).join(' ');
- return text.split('\n').map(function(line) {
- return line ? spaces + line : '';
- }).join('\n');
- }
- }
- }))
- .build(function(err) {
- callback(err);
- });
- return smith;
-}
-
-if (require.main === module) {
- main(function(err) {
- if (err) {
- process.stderr.write(
- 'Building examples failed. See the full trace below.\n\n' +
- err.stack + '\n');
- process.exit(1);
- } else {
- process.exit(0);
- }
- });
-}
-
-module.exports = main;
diff --git a/tasks/build-ext.js b/tasks/build-ext.js
deleted file mode 100644
index 700fb0d087..0000000000
--- a/tasks/build-ext.js
+++ /dev/null
@@ -1,75 +0,0 @@
-'use strict';
-
-const cleanup = require('rollup-plugin-cleanup');
-const common = require('rollup-plugin-commonjs');
-const node = require('rollup-plugin-node-resolve');
-const path = require('path');
-const pkg = require('../package.json');
-const rollup = require('rollup').rollup;
-
-/**
- * Wrap a bundled dependency for consumption by the Compiler.
- * @param {Object} ext Details from the `ext` object in package.json.
- * @return {Object} A rollup plugin.
- */
-function wrap(ext) {
- return {
- name: 'googup',
- transformBundle: function(source) {
- let name = `ol.ext.${ext.name || ext.module}`;
- let postamble = '';
- if (ext.import) {
- name += '.' + ext.import;
- } else {
- postamble = `${name} = ${name}.default;\n`;
- }
- return `
-/**
- * @fileoverview
- * @suppress {accessControls, ambiguousFunctionDecl, checkDebuggerStatement, checkRegExp, checkTypes, checkVars, const, constantProperty, deprecated, duplicate, es5Strict, fileoverviewTags, missingProperties, nonStandardJsDocs, strictModuleDepCheck, suspiciousCode, undefinedNames, undefinedVars, unknownDefines, unusedLocalVariables, uselessCode, visibility}
- */
-goog.provide('${name}');
-
-/** @typedef {function(*)} */
-${name} = function() {};
-
-(function() {${source}}).call(ol.ext);
-${postamble}`;
- }
- };
-}
-
-/**
- * Build all external modules.
- * @return {Promise} Resolves on successful completion.
- */
-function main() {
- return Promise.all(pkg.ext.map(ext => {
- const moduleName = ext.name || ext.module;
- const options = {
- extend: true,
- input: require.resolve(ext.module),
- format: 'iife',
- exports: 'named',
- plugins: [
- node(),
- common(),
- cleanup(),
- wrap(ext)
- ]
- };
- return rollup(options).then(bundle => {
- options.name = moduleName;
- options.file = `${path.join(__dirname, '..', 'build', 'ol.ext', moduleName.toLowerCase())}.js`;
- bundle.write(options);
- });
- }));
-}
-
-if (require.main === module) {
- main().catch(err => {
- process.stderr.write(`${err.message}\n`, () => process.exit(1));
- });
-}
-
-module.exports = main;
diff --git a/tasks/build.js b/tasks/build.js
deleted file mode 100644
index e97fe02d15..0000000000
--- a/tasks/build.js
+++ /dev/null
@@ -1,324 +0,0 @@
-/**
- * This task builds OpenLayers with the Closure Compiler.
- */
-var path = require('path');
-
-var async = require('async');
-var closure = require('closure-util');
-var fs = require('fs-extra');
-var nomnom = require('nomnom');
-var temp = require('temp').track();
-var exec = require('child_process').exec;
-
-var generateExports = require('./generate-exports');
-
-var log = closure.log;
-var root = path.join(__dirname, '..');
-
-var umdWrapper = ';(function (root, factory) {\n' +
- ' if (typeof exports === "object") {\n' +
- ' module.exports = factory();\n' +
- ' } else if (typeof define === "function" && define.amd) {\n' +
- ' define([], factory);\n' +
- ' } else {\n' +
- ' root.ol = factory();\n' +
- ' }\n' +
- '}(this, function () {\n' +
- ' var OPENLAYERS = {};\n' +
- ' %output%\n' +
- ' return OPENLAYERS.ol;\n' +
- '}));\n';
-
-var version;
-
-
-/**
- * Apply defaults and assert that a provided config object is valid.
- * @param {Object} config Build configuration object.
- * @param {function(Error)} callback Called with an error if config is invalid.
- */
-function assertValidConfig(config, callback) {
- process.nextTick(function() {
- if (!Array.isArray(config.exports)) {
- callback(new Error('Config missing "exports" array'));
- return;
- }
- if (config.namespace && typeof config.namespace !== 'string') {
- callback(new Error('Config "namespace" must be a string'));
- return;
- }
- if (config.compile && typeof config.compile !== 'object') {
- callback(new Error('Config "compile" must be an object'));
- return;
- }
- if (config.jvm && !Array.isArray(config.jvm)) {
- callback(new Error('Config "jvm" must be an array'));
- return;
- }
- if (config.src && !Array.isArray(config.src)) {
- callback(new Error('Config "src" must be an array'));
- return;
- }
- if (config.umd) {
- config.namespace = 'OPENLAYERS';
- if (config.compile) {
- config.compile.output_wrapper = umdWrapper;
- if (version) {
- if (!config.compile.define) {
- config.compile.define = [];
- }
- config.compile.define.push('ol.VERSION=\'' + version + '\'');
- }
- }
- }
- callback(null);
- });
-}
-
-
-/**
- * Read the build configuration file.
- * @param {string} configPath Path to config file.
- * @param {function(Error, Object)} callback Callback.
- */
-function readConfig(configPath, callback) {
- fs.readFile(configPath, function(err, data) {
- if (err) {
- if (err.code === 'ENOENT') {
- err = new Error('Unable to find config file: ' + configPath);
- }
- callback(err);
- return;
- }
- var config;
- try {
- config = JSON.parse(String(data));
- } catch (err2) {
- callback(new Error('Trouble parsing config as JSON: ' + err2.message));
- return;
- }
- callback(null, config);
- });
-}
-
-
-/**
- * Write the exports code to a temporary file.
- * @param {string} exports Exports code.
- * @param {function(Error, string)} callback Called with the path to the temp
- * file (or any error).
- */
-function writeExports(exports, callback) {
- temp.open({prefix: 'exports', suffix: '.js'}, function(err, info) {
- if (err) {
- callback(err);
- return;
- }
- log.verbose('build', 'Writing exports: ' + info.path);
- fs.writeFile(info.path, exports, function(err) {
- if (err) {
- callback(err);
- return;
- }
- fs.close(info.fd, function(err) {
- if (err) {
- callback(err);
- return;
- }
- callback(null, info.path);
- });
- });
- });
-}
-
-
-/**
- * Get the list of sources sorted in dependency order.
- * @param {Object} config Build configuration object.
- * @param {string} exports Exports code (with goog.exportSymbol calls).
- * @param {function(Error, Array.)} callback Called with a list of paths
- * or any error.
- */
-function getDependencies(config, exports, callback) {
- writeExports(exports, function(err, exportsPath) {
- if (err) {
- callback(err);
- return;
- }
- log.info('ol', 'Parsing dependencies');
- var options;
- if (config.src) {
- options = {
- lib: config.src,
- cwd: config.cwd
- };
- } else {
- options = {
- lib: ['src/**/*.js', 'build/ol.ext/*.js'],
- cwd: root
- };
- }
- closure.getDependencies(options, function(err, paths) {
- if (err) {
- callback(err);
- return;
- }
- paths.push(exportsPath);
- callback(null, paths);
- });
- });
-}
-
-
-/**
- * Concatenate all sources.
- * @param {Array.} paths List of paths to source files.
- * @param {function(Error, string)} callback Called with the concatenated
- * output or any error.
- */
-function concatenate(paths, callback) {
- async.map(paths, fs.readFile, function(err, results) {
- if (err) {
- var msg = 'Trouble concatenating sources. ' + err.message;
- callback(new Error(msg));
- } else {
- var parts = umdWrapper.split('%output%');
- var src = parts[0] +
- 'var goog = this.goog = {};\n' +
- 'this.CLOSURE_NO_DEPS = true;\n' +
- results.join('\n') +
- 'ol.VERSION = \'' + version + '\';\n' +
- 'OPENLAYERS.ol = ol;\n' +
- parts[1];
- callback(null, src);
- }
- });
-}
-
-
-/**
- * Run the compiler.
- * @param {Object} config Build configuration object.
- * @param {Array.} paths List of paths to source files.
- * @param {function(Error, string)} callback Called with the compiled output or
- * any error.
- */
-function build(config, paths, callback) {
- var options = {
- compile: config.compile,
- cwd: config.cwd || root,
- jvm: config.jvm
- };
- if (!options.compile) {
- log.info('ol', 'No compile options found. Concatenating ' +
- paths.length + ' sources');
- concatenate(paths, callback);
- } else {
- log.info('ol', 'Compiling ' + paths.length + ' sources');
- paths = paths.concat('src/ol/typedefs.js');
- options.compile.js = paths.concat(options.compile.js || []);
- closure.compile(options, callback);
- }
-}
-
-
-/**
- * Gets the version from the Git tag.
- * @param {function(Error, string)} callback Called with the output
- * ready to be written into a file, or any error.
- */
-function getVersion(callback) {
- exec('git describe --tags', function(error, stdout, stderr) {
- version = stdout.trim();
- callback(null);
- });
-}
-
-
-/**
- * Adds a file header with the most recent Git tag.
- * @param {string} compiledSource The compiled library.
- * @param {function(Error, string)} callback Called with the output
- * ready to be written into a file, or any error.
- */
-function addHeader(compiledSource, callback) {
- var header = '// OpenLayers. See https://openlayers.org/\n';
- header += '// License: https://raw.githubusercontent.com/openlayers/' +
- 'openlayers/master/LICENSE.md\n';
- if (version !== '') {
- header += '// Version: ' + version + '\n';
- }
- callback(null, header + compiledSource);
-}
-
-
-/**
- * Generate a build of the library.
- * @param {Object} config Build configuration object. Must have an "exports"
- * array and a "compile" object with options for the compiler.
- * @param {function(Error, string)} callback Called with the compiled source
- * or any error.
- */
-function main(config, callback) {
- async.waterfall([
- getVersion,
- assertValidConfig.bind(null, config),
- generateExports.bind(null, config),
- getDependencies.bind(null, config),
- build.bind(null, config),
- addHeader
- ], callback);
-}
-
-
-/**
- * If running this module directly, read the config file and call the main
- * function.
- */
-if (require.main === module) {
- var options = nomnom.options({
- config: {
- position: 0,
- required: true,
- help: 'Path to JSON config file'
- },
- output: {
- position: 1,
- required: true,
- help: 'Output file path'
- },
- loglevel: {
- abbr: 'l',
- choices: ['silly', 'verbose', 'info', 'warn', 'error'],
- default: 'info',
- help: 'Log level',
- metavar: 'LEVEL'
- }
- }).parse();
-
- /**
- * Set the log level.
- * @type {string}
- */
- log.level = options.loglevel;
-
- // read the config, run the main function, and write the output file
- async.waterfall([
- readConfig.bind(null, options.config),
- main,
- fs.outputFile.bind(fs, options.output)
- ], function(err) {
- if (err) {
- log.error(err.message);
- process.exit(1);
- } else {
- process.exit(0);
- }
- });
-}
-
-
-/**
- * Export main function.
- */
-module.exports = main;
diff --git a/tasks/check-example.js b/tasks/check-example.js
deleted file mode 100644
index 244bbfc97a..0000000000
--- a/tasks/check-example.js
+++ /dev/null
@@ -1,64 +0,0 @@
-/*eslint-env es6*/
-
-const http = require('http');
-const path = require('path');
-const serveFiles = require('serve-files');
-const spawn = require('child_process').spawn;
-
-if (!process.argv[2]) {
- process.stdout.write(`USAGE: node ${path.basename(module.filename)} [example_path]\n`);
- process.exit(0);
-}
-
-const root = process.cwd();
-const port = 8000;
-const host = null;
-const examplePath = process.argv[2];
-const phantomPath = require('phantomjs-prebuilt').path;
-
-const server = http.createServer(serveFiles.createFileResponseHandler({
- documentRoot: root,
- followSymbolicLinks: false,
- cacheTimeInSeconds: 3600
-}));
-
-server.listen(port, host, null, function() {
- const childProcess = spawn(phantomPath, ['--ssl-protocol=any', '--ignore-ssl-errors=true', path.join(__dirname, '..', 'bin', 'check-example.js'), 'http://localhost:8000/' + examplePath]);
- childProcess.stdout.pipe(process.stdout);
- childProcess.stderr.pipe(process.stderr);
- process.stdin.pipe(childProcess.stdin);
-
- childProcess.on('error', function(err) {
- process.stderr.write(`Error executing phantom on ${phantomPath}\n`);
- process.stderr.write(err.stack + '\n');
- process.exit(1);
- });
-
- childProcess.on('exit', function(code) {
- process.exit(code);
- });
-
-});
-
-// Keep track of connections, to enforce killing them when server must be stopped.
-var connections = {};
-server.on('connection', function(socket) {
- socket._cid = process.hrtime();
- connections[socket._cid] = socket;
-
- socket.on('end', function() {
- delete connections[this._cid];
- });
-});
-
-['SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT', 'SIGBUS', 'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGTERM'].forEach(signal => {
- process.once(signal, () => {
- process.stdout.write(`Got ${signal}, stopping...\n`),
- server.close(() => {
- process.stdout.write('Stopped.\n');
- process.exit(0);
- });
-
- Object.keys(connections).forEach(cid => connections[cid].destroy());
- });
-});
diff --git a/tasks/filename-case-from-module.js b/tasks/filename-case-from-module.js
deleted file mode 100644
index 97e5e3006a..0000000000
--- a/tasks/filename-case-from-module.js
+++ /dev/null
@@ -1,29 +0,0 @@
-const glob = require('glob');
-const fs = require('fs');
-const path = require('path');
-
-glob('src/**/*.js', {}, function(err, files) {
- if (!err) {
- process.stdout.write(`Checking ${files.length} files...\n`);
- let renamed = 0;
- files.forEach(function(filename) {
- const contents = fs.readFileSync(filename, 'utf-8');
- const lines = contents.split('\n');
- for (let i = lines.length - 1; i >= 0; --i) {
- const line = lines[i];
- const match = line.match(/goog\.provide\('.*\.([^']*)'\);$/);
- if (match && match.length) {
- const newName = match[1] + '.js';
- if (newName != newName.toLowerCase()) {
- fs.renameSync(filename, path.resolve(path.dirname(filename), newName));
- ++renamed;
- }
- }
- }
- });
- process.stdout.write(`Renamed ${renamed} files.\n`);
- } else {
- process.stdout.write(err.message);
- process.exit(1);
- }
-});
diff --git a/tasks/install.js b/tasks/install.js
deleted file mode 100644
index 68d8465a43..0000000000
--- a/tasks/install.js
+++ /dev/null
@@ -1,10 +0,0 @@
-var buildExt = require('./build-ext');
-
-buildExt(function(err) {
- if (err) {
- process.stderr.write(err + '\n');
- process.exit(1);
- } else {
- process.exit(0);
- }
-});
diff --git a/tasks/readme.md b/tasks/readme.md
index e62ecc72ab..2e92ecb8be 100644
--- a/tasks/readme.md
+++ b/tasks/readme.md
@@ -106,22 +106,6 @@ Called internally to parse the library for annotations and write out a `build/in
Builds examples and the example index.
-## `check-example.js`
-
-Runs an example in PhantomJS and returns an exit code != 0 after printing a stack trace when something is wrong with the example.
-
-To check the `simple.html` example when on master, first run the `build-examples.js` task, then invoke
-
- node tasks/check-example.js build/hosted/master/simple.html
-
-
-## `serve.js`
-
-Run a debug server that provides all library sources unminified. Provides a static server for examples and tests. See the `--help` option for more detail.
-
- node tasks/serve.js --help
-
-
## `test.js`
Run the tests once in a headless browser. Note that you can also run the tests by running the `serve.js` task and then visiting the root of the test directory in your browser.
diff --git a/tasks/serve-lib.js b/tasks/serve-lib.js
deleted file mode 100644
index 8a6f9d721e..0000000000
--- a/tasks/serve-lib.js
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * This task starts a dev server that provides a script loader for the
- * OpenLayers library.
- */
-
-var path = require('path');
-
-var closure = require('closure-util');
-var nomnom = require('nomnom');
-
-var log = closure.log;
-var name = path.basename(__filename, '.js');
-
-/**
- * Create a debug server for the OpenLayers and Closure Library sources.
- * @param {function(Error, closure.Server)} callback Callback.
- */
-var createServer = exports.createServer = function(callback) {
- var server;
- var manager = new closure.Manager({
- lib: [
- 'src/**/*.js',
- 'build/ol.ext/*.js'
- ],
- cwd: path.join(__dirname, '..')
- });
- manager.on('error', function(err) {
- if (server) {
- log.error('serve', err.message);
- } else {
- callback(err);
- }
- });
- manager.on('ready', function() {
- server = new closure.Server({
- manager: manager,
- loader: '/loader.js'
- });
- callback(null, server);
- });
-};
-
-/**
- * Try listening for incoming connections on a range of ports.
- * @param {number} min Minimum port to try.
- * @param {number} max Maximum port to try.
- * @param {http.Server} server The server.
- * @param {function(Error)} callback Callback called with any error.
- */
-function listen(min, max, server, callback) {
- function _listen(port) {
- server.once('error', function(err) {
- if (err.code === 'EADDRINUSE') {
- log.warn(name, 'Port %d in use, trying next one', port);
- ++port;
- if (port < max) {
- _listen(port);
- } else {
- callback(new Error('Could not find an open port'));
- }
- } else {
- callback(err);
- }
- });
- server.listen(port);
- }
- server.once('listening', function() {
- callback(null);
- });
- _listen(min);
-}
-
-/**
- * If running this module directly start the server.
- */
-if (require.main === module) {
- var options = nomnom.options({
- port: {
- abbr: 'p',
- default: 3000,
- help: 'Port for incoming connections (will try additional ports if used)',
- metavar: 'PORT'
- },
- loglevel: {
- abbr: 'l',
- choices: ['silly', 'verbose', 'info', 'warn', 'error'],
- default: 'info',
- help: 'Log level',
- metavar: 'LEVEL'
- }
- }).parse();
-
- /** @type {string} */
- log.level = options.loglevel;
-
- log.info(name, 'Parsing dependencies.');
- createServer(function(err, server) {
- if (err) {
- log.error(name, 'Parsing failed');
- log.error(name, err.message);
- process.exit(1);
- }
- listen(options.port, options.port + 4, server, function(err) {
- if (err) {
- log.error(name, 'Server failed to start: ' + err.message);
- process.exit(1);
- }
- log.info(name, 'Debug server running http://localhost:' +
- server.address().port + '/loader.js (Ctrl+C to stop)');
- });
- });
-
-}
diff --git a/tasks/serve.js b/tasks/serve.js
deleted file mode 100644
index 6fe96a400e..0000000000
--- a/tasks/serve.js
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * This task starts a dev server that provides a script loader for OpenLayers
- * and Closure Library. In addition, a static server hosts all files in the
- * repository.
- */
-
-var path = require('path');
-var url = require('url');
-
-var Gaze = require('gaze').Gaze;
-var closure = require('closure-util');
-var debounce = require('debounce');
-var fs = require('fs-extra');
-var nomnom = require('nomnom');
-
-var buildExamples = require('./build-examples');
-var log = closure.log;
-
-
-/**
- * Create a debug server for ol and Closure Library sources.
- * @param {function(Error, closure.Server)} callback Callback.
- */
-var createServer = exports.createServer = function(callback) {
- var server;
- var manager = new closure.Manager({
- lib: [
- 'src/**/*.js',
- 'build/ol.ext/*.js',
- 'test/spec/**/*.test.js',
- 'test_rendering/spec/**/*.test.js',
- 'build/test_requires.js',
- 'build/test_rendering_requires.js'
- ],
- main: 'build/examples/*.js'
- });
- manager.on('error', function(err) {
- if (server) {
- log.error('serve', err.message);
- } else {
- callback(err);
- }
- });
- manager.on('ready', function() {
- server = new closure.Server({
- manager: manager,
- loader: /^\/(?:(?:build\/examples)|(?:test(?:_rendering)?))\/loader\.js/,
- getMain: function(req) {
- var main;
- var query = url.parse(req.url, true).query;
- var referer = req.headers.referer;
- var pathName = url.parse(referer).pathname;
- if (pathName.indexOf('/test/') === 0) {
- main = path.resolve(
- path.join(process.cwd(), 'build'), 'test_requires.js');
- } else if (pathName.indexOf('/test_rendering/') === 0) {
- main = path.resolve(
- path.join(process.cwd(), 'build'), 'test_rendering_requires.js');
- } else {
- if (query.id) {
- if (referer) {
- var from = path.join(process.cwd(),
- path.dirname(url.parse(referer).pathname));
- main = path.resolve(from, query.id + '.js');
- }
- }
- }
- return main;
- }
- });
- callback(null, server);
- });
-};
-
-/**
- * Build the examples and exit on any error.
- * @param {Function=} opt_callback Called when done building examples.
- */
-function buildExamplesOrFatal(opt_callback) {
- log.info('serve', 'Building examples.');
- buildExamples(function(err) {
- if (err) {
- log.error('serve', 'Building examples failed.');
- log.error('serve', err.message);
- log.error('serve', 'Use "verbose" logging to see the full stack trace.');
- log.verbose('serve', err.stack);
- process.exit(1);
- }
- // This is awkward, but then so is CSS itself
- var src = path.join(__dirname, '..', 'css', 'ol.css');
- var dest = path.join(__dirname, '..', 'build', 'css', 'ol.css');
- fs.copy(src, dest, function(err2) {
- if (err2) {
- log.error('serve', 'Failed to copy CSS.');
- log.error('serve', err.message);
- log.error('serve',
- 'Use "verbose" logging to see the full stack trace.');
- log.verbose('serve', err.stack);
- process.exit(1);
- }
- log.verbose('serve', 'Done building examples.');
- if (opt_callback) {
- opt_callback();
- }
- });
- });
-}
-
-/**
- * If running this module directly start the server.
- */
-if (require.main === module) {
- var options = nomnom.options({
- port: {
- abbr: 'p',
- default: 3000,
- help: 'Port for incoming connections',
- metavar: 'PORT'
- },
- loglevel: {
- abbr: 'l',
- choices: ['silly', 'verbose', 'info', 'warn', 'error'],
- default: 'info',
- help: 'Log level',
- metavar: 'LEVEL'
- }
- }).parse();
-
- /** @type {string} */
- log.level = options.loglevel;
-
- buildExamplesOrFatal(function() {
- log.info('serve', 'Parsing dependencies.');
- createServer(function(err, server) {
- if (err) {
- log.error('serve', 'Parsing failed');
- log.error('serve', err.message);
- process.exit(1);
- }
- server.listen(options.port, function() {
- log.info('serve', 'Listening on http://localhost:' +
- options.port + '/ (Ctrl+C to stop)');
- });
- server.on('error', function(err) {
- log.error('serve', 'Server failed to start: ' + err.message);
- process.exit(1);
- });
- });
-
- var gaze = new Gaze('examples/**/*');
- var debouncedBuild = debounce(buildExamplesOrFatal, 250);
- gaze.on('all', function(event, filepath) {
- log.verbose('serve', 'Watch event: ' + event + ' ' + filepath);
- debouncedBuild();
- });
- });
-
-}
diff --git a/tasks/test.js b/tasks/test.js
deleted file mode 100644
index 5a5ac8223e..0000000000
--- a/tasks/test.js
+++ /dev/null
@@ -1,102 +0,0 @@
-const Server = require('karma').Server;
-const closure = require('closure-util');
-const path = require('path');
-const processCliArgs = require('karma/lib/cli').process;
-
-function insertDependencies(manager, files, previousLookup) {
- previousLookup = previousLookup || {};
- let firstIndex = NaN;
- const original = files.filter((obj, index) => {
- if (previousLookup[obj.pattern]) {
- if (isNaN(firstIndex)) {
- firstIndex = index;
- }
- return false;
- } else {
- return true;
- }
- });
- if (isNaN(firstIndex)) {
- firstIndex = 0;
- }
- const lookup = {};
- const dependencies = manager.getDependencies().map(script => {
- lookup[script.path] = true;
- return {
- pattern: script.path,
- included: true,
- served: true,
- watched: false
- };
- });
- original.splice.apply(original, [firstIndex, 0].concat(dependencies));
- files.length = 0;
- files.push.apply(files, original);
-
- return lookup;
-}
-
-/**
- * Start Karma. This prepends the Karma `files` config with all library files
- * sorted in dependency order.
- * @param {Object} config Karma options.
- * @param {Manager} manager The dependency file manager.
- * @param {function(Error)} callback Called with any error.
- */
-function serve(config, manager, callback) {
- function exit(code) {
- let error = null;
- if (code) {
- error = new Error(`Karma exited with ${code}`);
- error.code = code;
- }
- callback(error);
- }
- const server = new Server(config, exit);
-
- const files = server.get('config.files');
-
- let lookup = insertDependencies(manager, files);
-
- // stop goog base.js from trying to load deps.js
- files.unshift({
- pattern: path.resolve(__dirname, '../test/no-deps.js'),
- included: true,
- served: true,
- watched: false
- });
-
- manager.on('update', () => {
- lookup = insertDependencies(manager, files, lookup);
- server.refreshFiles();
- });
-
- server.start();
-}
-
-function main(config, callback) {
- const manager = new closure.Manager({
- lib: [
- 'src/**/*.js',
- 'build/ol.ext/*.js'
- ]
- });
-
- manager.on('error', callback);
-
- manager.on('ready', () => {
- serve(config, manager, callback);
- });
-}
-
-if (require.main === module) {
- const config = processCliArgs();
- main(config, (err, manager) => {
- if (err) {
- process.stderr.write(err.message, () => process.exit(1));
- return;
- } else {
- process.exit(0);
- }
- });
-}
diff --git a/test/karma.config.js b/test/karma.config.js
index 8dfaae32fe..bbc1975369 100644
--- a/test/karma.config.js
+++ b/test/karma.config.js
@@ -3,14 +3,6 @@
const path = require('path');
const pkg = require('../package.json');
-/**
- * The config below is not enough to run Karma. In addition, we need to add
- * all library files in dependency order. This could be done with a plugin if
- * Karma supported async plugins (there may be other alternatives as well). But
- * for now we start Karma with the `tasks/test.js` script. This script
- * sorts dependencies and adds files to the Karma config below.
- */
-
module.exports = function(karma) {
karma.set({
frameworks: ['mocha'],
@@ -61,18 +53,6 @@ module.exports = function(karma) {
'**/*.js': ['webpack']
},
reporters: ['progress'],
- coverageReporter: {
- reporters: [
- {
- type: 'lcov', // produces HTML output and lcov
- dir: '../coverage/',
- subdir: '.'
- },
- {
- type: 'text-summary' // prints the textual summary to the terminal
- }
- ]
- },
webpackMiddleware: {
noInfo: true
}
@@ -119,7 +99,7 @@ module.exports = function(karma) {
}
},
hostname: 'travis.dev',
- reporters: ['dots', 'saucelabs', 'coverage'],
+ reporters: ['dots', 'saucelabs'],
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 1,
captureTimeout: 240000,
@@ -127,9 +107,6 @@ module.exports = function(karma) {
customLaunchers: customLaunchers,
browsers: Object.keys(customLaunchers),
preprocessors: {
- // source files, that you wanna generate coverage for
- // do not include tests or libraries
- // (these files will be instrumented by Istanbul)
'../src/**/*.js': ['coverage']
},
coverageReporter: {
diff --git a/test/no-deps.js b/test/no-deps.js
deleted file mode 100644
index f870b409a7..0000000000
--- a/test/no-deps.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// TODO: get rid of this when we get rid of goog base.js
-var CLOSURE_NO_DEPS = true; // eslint-disable-line