Commit Graph

108 Commits

Author SHA1 Message Date
Gabby Getz ff559c7109 build workers, third party, and combine with eslint 2022-05-11 16:53:41 -04:00
Sean Lilley d74ee83ba8 Update jsHint to esversion 11 2022-03-22 18:11:09 -04:00
Gabby Getz 31c154a299 Remove when.js and replace with native promises
There were a few areas in Source where a function was assumed to be executed synchronously when a function was resolved. Native Promises however, by spec, will resolve at the end of a frame. There were also some strange handling of promise rejection in imagery providers that I cleaned up a bit in order to make them testable.

- In LabelCollection and EntityCluster, order of execution adjustment where made.
- Added TextureAtlas.addImageSync to support the order of execution fix in LabelCollection
- ArcGisMapServerImageryProvider.readyPromise will not reject if there is a failure unless the request cannot be retried.
- SingleTileImageryProvider.readyPromise will not reject if there is a failure unless the request cannot be retried.

The majority of the changes lie in the Specs, where unresolved promises weren’t being awaited before finishing executions, and where resolved promises are assumed to be synchronous all over the place and needed a good amount of fixes. Another issue which came up was calling Promise.reject in the body of a spec can cause node to halt execution when running via the command line.
2022-03-16 09:38:39 -04:00
Eli Bogomolny 7fa0d1c1ce Delete files 2022-03-09 15:58:41 -05:00
Eli Bogomolny 691ae2b943 Remove zip.js comments and update gulpfile comment 2021-10-08 12:44:38 -04:00
Eli Bogomolny 51950009af use pako with buildModuleUrl paths 2021-10-07 14:14:47 -04:00
Eli Bogomolny 4472b26d81 configure without web workers 2021-10-07 00:55:46 -04:00
Eli Bogomolny 3a07c02572 pako workers for zip.js 2021-09-29 16:35:11 -04:00
ebogo1 2bed051958 rename to Uri.js 2021-08-29 12:11:22 -04:00
ebogo1 4ed739465e Merge remote-tracking branch 'origin/main' into uri-js 2021-08-29 11:51:13 -04:00
ebogo1 edefb597b3 add meshoptimizer npm module 2021-08-27 11:13:34 -04:00
ebogo1 0d2b579786 Merge remote-tracking branch 'origin/npm-third-party-staging' into uri-js 2021-08-23 13:05:59 -04:00
Matthew Amato 974bb42a99 Use protobufjs from npm
Locked to version 6.7.0 since that is the version we are already using and
updating it requires additinal work because of the use of util.lazyResolve
in the GoogleEarthEnterpriceMetadata root parser code.
2021-08-22 15:08:43 -04:00
ebogo1 a5d7070f26 first pass 2021-08-18 23:18:11 -04:00
ebogo1 b962003b37 reduce import sizes for pako and zip 2021-08-04 13:29:21 -04:00
ebogo1 74b874a73f Merge remote-tracking branch 'origin/main' into npm-third-party-staging 2021-08-01 12:00:17 -04:00
ebogo1 7b40a60bae remove inflate and deflate workers 2021-07-28 14:42:15 -04:00
ebogo1 65f59241e3 zip.js in exportKml 2021-07-26 17:05:12 -04:00
ebogo1 8165fd9d24 add ThirdParty/npm/ktx-parse.js 2021-07-23 16:45:46 -04:00
ebogo1 e1228598c8 add npm packages pt 1 2021-07-20 17:15:17 -04:00
Sean Lilley fe8fec2d51 master -> main 2021-07-16 19:01:30 -04:00
Matthew Amato f594b3c99b Start of replacing submitted third party libraries with npm modules
Rather than submit libraries to Source/ThirdParty, which always end up
being modified for our build system and quickly go out of date, this
change starts to use libraries via npm instead. Currently Autolinker,
earcut, when, tween.js, rbush, kdbush, quickselect, and topojson are
ported.

The main hurdle that prevented us from doing this sooner was the fact that
Cesium has a long history of not requiring a build step after every code
change and has a goal of writing valid JS code, unlike many libraries today
 that mandate a bundler to turn invalid JS code into valid code.

Rather than mandate a bundler during development, this initial step adds a
"buildThirdyParty" function to the current "build" step. This function runs
third party libraries (defined in the ThirdParty/npm/ folder) through
RollUp and creates an equivalent file in `Source/ThirdPartyNpm`.

The change to end users will be non-existent, especially since the combined
Cesium.js will still re-export any third party modules as part of the
private API just like it used to.

This doesn't prevent code duplication for users using some of the same
third party libraries as Cesium. This is just an improvement as to how
depend on third party libraries internally.

I think Cesium's days of being "bundler free" are probably limited long
term, performance is the main hurdle and newer tools like esbuild may make
that no longer a problem. But that's outside the scope of this initial
goal.
2021-04-11 15:02:36 -04:00
Peter Gagliardi bcafd892fc Update Codemirror + JSHint to support ES6+ syntax 2020-02-20 08:57:26 -05:00
Matthew Amato aabd27a760 Migrate Cesium to ES6 Modules
See https://github.com/AnalyticalGraphicsInc/cesium/pull/8224 for details.

eslint
There are a handful of new .eslintrc.json files, mostly to identify the files that are still AMD modules (Sandcastle/Workers). These are needed because you can't change the parser type with a comment directive (since the parser is the thing reading the file). We can finally detect unusued modules! So those have all been cleaned up as well.

requirejs -> rollup & clean-css
requirejs, almond, and karma-requirejs have all been removed. We now use rollup for building and minifying (via uglify) JS code and clean-css for css. These changes are fairly straight-forward and just involve calling rollup instead of requirejs in the build process.

Overall build time is significantly faster. CI is ~11 minutes compared to ~17 in master. Running makeZipFile on my machine takes 69 seconds compared to 112 seconds in master. There's probably plenty of room for additional optimization here too.

We wrote an published a small npm module, rollup-plugin-strip-pragma, for stripping the requirejs pragmas we use out of the release builds. This is maintained in the Tools/rollup-plugin-strip-pragma directory.

As for what we produce. The built version of Cesium is now a UMD module. So it should work anywhere that hasn't made the jump to ES6 yet. For users that were already using the "legacy" combined/minified approach, nothing changes.

One awesome thing about roll-up is that it compiles all of the workers at once and automatically detects shared codes and generates separate bundles under the hood. This means the size of our worker modules shrink dramatically and Cesium itself will load them much faster. The total minified/gzipped size of all workers in master is 2.6 MB compared to 225 KB in this branch! This should be most noticeable on demos like Geometry & Appearances which load lots of workers for the various geometry typs.

roll-up is also used to build Cesium Viewer, which is now an ES6 app.

We use clean-css via gulp and it is also a straightforward change from requirejs that requires no special mention.

Workers
While the spec allows for ES6 Web Workers, no browser actually supports them yet. That means we needed a way to get our workers into non-ES6 form. Thankfully, roll-up can generate AMD modules, which means we now have a build step to compile our Worker source code back into AMD and use the existing TaskProcessor to load and execute them. This build step is part of the standard build task and is called createWorkers. During development, these "built" workers are un-optimized so you can still debug them and read the code.

Since there is a build step, that means if you are changing code that affects a worker, you need to re-run build, or you can use the build-watch task to do it automatically.

The ES6 versions of Worker code has moved into Source/WorkersES6 and we build the workers into their "old home" of Source/Workers. cesiumWorkerBootstrapper and transferTypedArrayTest which were already non-AMD ES5 scripts remain living in the Workers directory.

Surprisingly little was changed about TaskProcessor or the worker system in general, especially considering that I thought this would be one of the major hurdles.

ThirdParty
A lot of our ThirdParty either already had a hand-written wrapper for AMD (which I updated to ES6) or had UMD which created problems when importing the same code in both Node and the browser. I basically had to update the wrapper of every third-party library to fix these problems. In some cases I updated the library version itself (Autolinker, topojson). Nothing to be too concerned about, but future clean-up would be using npm versions of these libraries and auto-generating the wrappers as needed so we don't hand-edit things.

Sandcastle
Sandcastle is eternal and manages to live another day in it's ancient requirejs/dojo 1.x form. Sandcastle now automatically uses the ES6 version of Cesium if it is available and fallsback to the ES5 unminified version if it is now. The built version of Sandcastle always uses CesiumUnminified, just like master. This means Sandcastle still works in IE11 if you run the combine step first (or use the relase zip)

Removed Cesium usage from Sandcastle proper, since it wasn't really needed
Generate a VERSION propertyin the gallery index since Cesium is no longer being included.
Remove requirejs from Sandcastle bucket
Update bucket to use the built version of Cesium if it is available by fallbackto the ES6 version during development.
Standalone.html was also updated
There's a bit of room for further clean-up here, but I think this gets us into master. I did not rename bucket-requirejs.html because I'm pretty sure it would break previously shared demos. We can put in some backwards compatible code later on if we want. (But I'd rather just see a full Sandcastle rewrite).

Specs
Specs are now all ES6, except for TestWorkers, which remain standard JS worker modules. This means you can no longer run the unbuilt unit tests in IE11. No changes for Chrome and Firefox.

Since the specs use ES6 modules and built Cesium is an ES5 UMD, I added a build-specs build step which generates a combined ES5 version of the specs which rely on Cesium as a global variable. We then inject these files into jasmine instead of the standard specs and everything works exactly as it did before. SpecRunner.html has been updated to inject the correct version of the script depending on the build/release query parameters.

The Specs must always use Cesium by importing Source/Cesium.js, this is so we can replace it with the built Cesium as describe above.

There's a bunch of room for clean-up here, such as unifying our two copies of jasmine into a single helper file, but I didn't want to start doing that clean-up as part of this already overly big PR. The important thing is that we can still test the built version and still test on IE/Edge as needed.

I also found and fixed two bugs that were causing failing unit tests, one in BingMapsImageryProviderSpec.js (which was overwriting createImage andnot setting it back) and ShadowVolumeAppearance.js (which had a module level caching bug). I think these may have been the cause of random CI failures in master as well, but only time will tell.

For coverage, we had to switch to karma-coverage-istanbul-instrumenter for native ES6 support, but that's it.

Finally, I updated appveryor to build Cesium and run the built tests under IE. We still don't fail the build for IE, but we should probably fix that if we want to keep it going.

NodeJS
When NODE_ENV is production, we now require in the minified CesiumJS directly, which works great because it's now a UMD module. Otherwise, we use the excellant esmpackage to load individual modules, it was a fairly straightforward swap from our old requirejs usage. We could probably drop esm too if we don't care about debugging or if we provie source maps at some point.
2019-10-03 11:51:23 -04:00
Matthew Amato 7f5cf310eb Update dojo 1.9.3 -> 1.10.4
The version we have is old and until Sandcastle gets its much needed
makeover, we should stay current with dependancies.
2015-11-21 10:46:07 -05:00
Scott Hunter 8941b29bdb Switch almond to a npm module since it's only used by the build process. 2015-10-26 17:36:43 -04:00
Matthew Amato 77d22e0c62 Update AMD loaders
Update `requirejs` from 2.1.9 to 2.1.20.
Update `almond` from 0.2.6 to 0.3.1.
2015-10-22 17:07:26 -04:00
Matthew Amato 83e90ee78e Remove old build system and associated tools.
Replaced with gulp in #3106.
2015-10-22 17:02:35 -04:00
Frederic Junod 3f2fd5e648 Remove unused ThirdParty/es5-shim
Not used since 339be2c
2015-08-11 17:04:26 +02:00
Kevin Ring 1b55eea19d Fix model tests and don't let pretty printing hang. 2015-03-16 18:13:21 +11:00
Kevin Ring 93d11896f8 Fix long timeout when spec throws an exception. 2015-02-24 15:12:50 +11:00
Kevin Ring e421e7d6ba Improve jasmine's handling of possibly-async functions.
Jasmine doesn't like it when an async spec (one that takes a done parameter) actually ends up being synchronous and calls `done()` before the spec returns.  It mostly works, but ends up creating a deep call stack that risks causing a stach overflow.

This change makes jasmine detect when done() is called before the spec returns and treat the spec as it would a normal synchronous spec.  This should improve performance a bit too because all Cesium specs are async from the perspective of Jasmine, but only some of them actually are.
2015-02-18 15:16:57 +11:00
Kevin Ring 32cab84dad Make Jasmine treat typed arrays as regular arrays. 2015-02-18 10:16:25 +11:00
Kevin Ring affb2e7945 Remove jasmine 1.3.1. 2015-02-17 16:13:01 +11:00
Kevin Ring 2030cd0a2c Modify jasmine-html rather than supplying our own.
I'm torn on this, but I think it's the right approach.
2015-02-17 16:07:09 +11:00
Kevin Ring 6d961d8149 Show spec tree before run completes. 2015-02-12 11:00:00 +11:00
Kevin Ring 857632ce17 Basic support for categories. 2015-02-11 23:57:09 +11:00
Kevin Ring ec0f8cfeb6 Remove Jasmine 2.1.3. 2015-02-11 12:16:29 +11:00
Kevin Ring 41a414d432 Upgrade to Jasmine 2.2.0. 2015-02-11 12:15:51 +11:00
Kevin Ring 18c51959c7 Upgrade to Jasmine 2.1.3. 2015-01-02 20:21:11 +11:00
Kevin Ring f6d3e88f9a Make tests run under Jasmine 2.1.2.
There are 1947 failures, but hey.
2014-12-01 15:59:07 +11:00
Matthew Amato 5c2653df26 Upgrade to CodeMirror 4.6
Everything works, except for autocomplete.  More cleanup and testing needed.
2014-10-15 17:36:26 -04:00
Matthew Amato 8aab494595 Update Dojo from 1.9.1 to 1.9.3. 2014-05-23 11:45:22 -04:00
Dan Bagnell 6eaf40b7d5 Update links on index page and the links generated by jasmine. 2013-12-02 20:23:05 -05:00
Scott Hunter 8ce00005a3 Update JSHint to 2.1.10 to match the version in the Eclipse plugin. 2013-10-29 23:07:32 -04:00
Scott Hunter 2990551e08 Update RequireJS to 2.1.9. 2013-10-21 16:51:48 -04:00
Scott Hunter 4b32e4a3b9 Upgrade RequireJS to version 2.1.8, and Almond to 0.2.6. 2013-10-10 16:05:37 -04:00
Matthew Amato fee5ebc67c Update dojo to 1.9.1
Fixed #883
2013-07-08 15:55:08 -04:00
Scott Hunter 205db79fb2 If beforeAll/afterAll fails, display an error. 2013-06-18 12:06:59 -04:00
Scott Hunter e0ab8a6104 Completely disable the symbolSummary instead of just partially. 2013-06-18 12:06:58 -04:00