Commit Graph

88 Commits

Author SHA1 Message Date
jjspace 09a719b8fb
run prettier v3 2024-09-20 11:24:24 -04:00
Gabby Getz 07948fbbd2 Update to eslint 9 and cesium-config-eslint 11 2024-05-02 14:20:39 -04:00
Sanjeet Suhag 1ab481a767 Removes duplication of rules 2022-05-23 10:31:40 -04:00
Peter Gagliardi 2fa7015313 string concatenation -> template literals 2022-02-02 15:40:21 -05:00
Gabby Getz 8143df4436 var -> const/let 2022-01-21 11:26:25 -05:00
Gabby Getz 3de446615c Update eslint config 2022-01-21 11:25:54 -05:00
hpinkos 2e13fb60db reconfigure eslint 2021-01-25 11:00:37 -05:00
Frederic Junod 241a27edf8 Update prettier to version ^2.1.1 2020-08-28 10:15:42 +02:00
Matthew Amato 2fd0e8f7e4 Format all code with prettier 2020-04-16 20:31:36 -04: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
hpinkos 1a8e2dd5a7 update node modules 2019-09-19 11:04:04 -04:00
Sanuj 04216d0204 Replace "use strict" by 'use strict' 2016-02-09 11:07:51 +05:30
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
Matthew Amato 72dcba6670 Remove remnants of Chrome Frame
Fixes #3065
2015-10-13 19:58:09 -04:00
hpinkos 22376f0a54 fix specs 2014-07-09 13:29:04 -04:00
Matthew Amato ae9dd46f14 Ongoing TimeInterval refactoring.
This change mostly modifies the contructor functions to take an `options` object.
2014-06-13 14:37:13 -04:00
Matthew Amato 38aa8f1a02 Require result parameter for JulianDate functions
1. Does not require a parameter for `fromXXX` and `clone`. (because that seems to be the pattern we are going with)
2. Used scratch parameters in places where it was easy to add.
3. I didn't try to optimize the Timeline widget since it's getting rewritten anyway.
2014-06-12 15:10:57 -04:00
Matthew Amato b083865cc0 Swap order of parameters in JulianDate.getSecondsDifference and JulianDate.getDaysDifference 2014-06-11 13:56:03 -04:00
Matthew Amato 7a7423f887 Ongoing JulianDate refactoring
Default constructing a JulianDate no longer creates an instance set to the current time; I added JulianDate.now() for this purpose.
2014-06-10 10:35:39 -04:00
Matthew Amato cb6005ca86 Start refactoring JulianDate
Turn all prototype functions (except for clone/equals/eqaulsEpsilon/compareTo) into static functions.
2014-06-09 17:57:04 -04:00
Matthew Amato 8aab494595 Update Dojo from 1.9.1 to 1.9.3. 2014-05-23 11:45:22 -04:00
Kevin Ring 61135d240a Sort requires. 2014-05-14 18:23:01 -04:00
Ed Mackey 6ba9516ece Fix #1160, and clear the canvas correctly.
The canvas used to be cleared by "resize" which would write
to the size even if it was unchanged.  Now that this is no
longer the case, it must be cleared manually.
2013-09-23 13:54:00 -04:00
mramato f3d64d3a59 Replace `undefined` equality checks with `defined` function.
There are some errors in the conversion that still need to be addressed.
2013-08-11 23:05:36 -04:00
Matthew Amato fee5ebc67c Update dojo to 1.9.1
Fixed #883
2013-07-08 15:55:08 -04:00
Matthew Amato 97f3e25eda Optimize resizing for Viewer and related widgets.
`Animation` and `Timeline` no longer listen to `window.resize`.  Instead the `Viewer` resizes them as needed.  Also added checks to avoid unecessary resizing when the current size and new size are identical.
2013-06-17 15:01:42 -04:00
mramato 3622248964 Switch to minified version of dojo 1.9.
Delete uncompressed and dojox files.
2013-06-14 13:43:28 -04:00
Ed Mackey abf3a5a57c Change TimelineDemo to reflect proper theme names. 2013-03-21 16:05:58 -04:00
Matthew Amato 80fbe8baec Widget cleanup
1. The first parameter to each widget is now uniformly named and documented.  It can either be an element or string.
2. Each widget exposes a public `container` property, which is the element that was passed into the constructor.
3. `cesium-darker` is now the default theme, deleted `darker.css` files and replaced them with `lighter.css`  For each of use, there is now a `lighter.css` in the Widgets directory which just includes all other `lighter.css` files.

I plan on continuing widget cleanup, but decided it was better to make small, incremental pull requests rather than shoving everything together.
2013-03-21 14:02:25 -04:00
Matthew Amato 338bf31c22 Remove need to call Timeline.updateFromClock.
Register for the `Clock.onTick` event instead, which was introduced with the animation branch.

This is a minor tweak to bring Timeline in line with other widgets (event driven rather than manual updates from the user).  I plan on looking into refactoring Timeline to use knockout/viewModels soon, but I thought this was a good simple change in the mean time.
2013-02-27 16:34:26 -05:00
Ed Mackey af0f585ea4 Fix height of widget in Timeline Demo. 2013-02-24 11:43:03 -05:00
mramato 7363f09eb6 Hopefully final review changes. 2013-02-21 21:35:40 -05:00
Matthew Amato 49b57592f4 More changes after review.
1. No need to pass the tool tip to rectButton and wingButton, as it will be set by SvgButton anyway.
2. Remove ClockViewModel.tickAndSynchronize and use clock.tick instead.  As Clock.onTick event for subscribing to clock ticks.
2013-02-21 15:23:20 -05:00
Matthew Amato 8734cabd1c Widget reorganization
1. Move widget specific code into subdirectories to make it easy to tell which pieces are shared or widget specific.
2. Break out darker css styling into separate files for Animation and Timeline.
3. Remove Dojo/TimelineWidget files since the dojo version isn't needed.
2013-02-21 13:10:47 -05:00
Matthew Amato f3153c8d98 Get rid of setScale & getScale.
Use the supplied parent elements size instead.  Properly handle non-uniform transforms.
Also fix a test I broken with my last commit.
2013-02-11 16:40:10 -05:00
Matthew Amato 84f34061c8 Hopefully final round of doc/clean/tests before merging. 2013-02-08 11:09:17 -05:00
Matthew Amato 16b1b49ab3 More cleanup. 2013-02-07 17:01:19 -05:00
Matthew Amato 04c752bac5 More AnimationViewModel Specs
Found and fixes a few bugs during the process.
2013-02-07 11:42:48 -05:00
Matthew Amato 22027dcb79 More cleanup, start of tests. 2013-02-06 19:58:21 -05:00
Matthew Amato b735377b5f Ongoing cleanup
1. Rename ButtonViewModel to ToggleButtonViewModel.
2. Rename "selected" to "toggled" to match 1.
3. Add binarySearch.numericComparator so people don't always define their own function
4. Start of AnimationViewModel cleanup, still more to do.
2013-02-06 14:27:38 -05:00
Matthew Amato 37227f0197 Ongoing refactoring.
1. Delete AnimationController and AnimationControllerSpec.
2. Move required AnimationController functionality to AnimationViewModel.
3. Add a new ClockViewModel to eventually be shared across widgets.
4. Add AnimationViewModelSpec (though tests are a mess).
5. Revert many of the changes to Clock/ClockRange/ClockStep to be closer inline with master.

Still a ton of cleanup to be done.
2013-02-01 16:08:50 -05:00
Matthew Amato 88b45c2112 Some cleanup to Animation.js
While there's still plenty of work to do, Animation.js is mostly finished for this go-around.  More cleanup will be done once we merge back into the `playback` branch.
2013-01-31 16:32:02 -05:00
Matthew Amato 15fac0112a Merge branch 'playback' into playbackTweaks 2013-01-30 19:22:04 -05:00
Matthew Amato d27ead7f0a Merge branch 'master' into playback
Conflicts:
	Apps/TimelineDemo/index.html
2013-01-30 19:19:20 -05:00
Matthew Amato e5fe701233 Ongoing viewModel refactoring.
Not all widget features work yet and there's still a lot of work to be done.
2013-01-30 17:24:15 -05:00
Matthew Amato 262ef93379 Start of an AnimationViewModel. 2013-01-30 10:48:21 -05:00
Matthew Amato 42607fd268 Update to Dojo 1.8.3
1. Delete `ThirdParty/dojo-release-1.7.2-src`
2. Add `ThirdParty/dojo-release-1.8.3-src`
3. Update source with find and replace.

No other changes
2013-01-28 19:59:41 -05:00
Ed Mackey fc31679535 Rename Playback widget to Animation widget. 2013-01-16 12:13:42 -05:00
Ed Mackey ba3ae3e404 Fix Timeline Demo 2013-01-16 11:45:22 -05:00
Ed Mackey 6060e7f9fd Tweak timeline demo colors. 2013-01-09 13:11:27 -05:00