Commit Graph

237 Commits

Author SHA1 Message Date
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
Peter Gagliardi 2fa7015313 string concatenation -> template literals 2022-02-02 15:40:21 -05:00
Gabby Getz 9f254c819b disbale-next-line 2022-01-26 13:40:08 -05:00
Gabby Getz 8143df4436 var -> const/let 2022-01-21 11:26:25 -05:00
willjad 3bae221214 remove chrome 79 workaround 2020-07-25 13:26:31 -05:00
Omar Shehata ebd4496e4e Ignore non-existant labels (like 'New in 1.XX') 2020-06-11 15:23:06 -04:00
Hannah 72dc2cb29f
Update CesiumSandcastle.js 2020-05-29 10:41:31 -04:00
Ian Lilley 6cdd33b90c Changed code mirror viewport margin to Infinity for improved search 2020-05-13 10:38:50 -04:00
Ed Mackey d403528fc5 Update Sandcastle indentation. 2020-04-18 16:49:40 -04:00
Matthew Amato 2fd0e8f7e4 Format all code with prettier 2020-04-16 20:31:36 -04:00
Matthew Amato 1b16c31941 Add configuration for prettier code formatting
1. Add prettier and configuration files, but do not format code yet.
2. Configure it for all html|css|js|md code.
3. Fix a bug it found in `CZML Custom Properties.html`
4. Add a pre-commit hook via husky and pretty-quick which will
automatically format changed files when they are staged on the client.
5. Run `prettier-check` during CI and fail the build of code is not
formatted properly.
6. Install eslint config for prettier. This does not enable prettier
checking in eslint (it's unusably slow) but instead just makes sure that
no eslint rules conflict with prettier formatting.
7. Update .editorconfig to match (since prettier respects it)
8. Tweak Sandcastle to handle prettier formated examples
2020-04-13 17:19:59 -04:00
Peter Gagliardi bcafd892fc Update Codemirror + JSHint to support ES6+ syntax 2020-02-20 08:57:26 -05:00
Matthew Amato 06a7763933 AnalyticalGraphicsInc -> CesiumGS
1. Update relevant AnalyticalGraphicsInc organization links to CesiumGS.

2. Remove Webstorm guide since it's unmaintained and reference an
unmaintained plugin

3. Update outdated email address in CODE_OF_CONDUCT.
2020-02-18 13:19:12 -05:00
Scott Hunter 8292804601 Remove `access_token` from gist loading.
GitHub has deprecated use of `access_token` in query parameters and is email spamming us nonstop about it.
Gists can be read anonymously with a rate-limit of 60 requests per hour per client IP address.

Since we stopped using gists for Sandcastle example code two years ago, the gist codepath is only for extremely old examples, so the rate limit is unlikely to be an issue in practice.
2020-02-13 14:42:48 -05:00
Matthew Amato 05b03be187 Workaround Chrome 79 bug. 2019-12-13 19:25:13 -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
hpinkos 1a8e2dd5a7 update node modules 2019-09-19 11:04:04 -04:00
Omar Shehata a92cf4c6fc
Merge pull request #8158 from AnalyticalGraphicsInc/no-source-in-sandcastle
Don't require individual source classes in sandcastle app
2019-09-17 09:10:37 -04:00
Matthew Amato 39fcb26c2d Run sortRequires, remove many unused modules
This is just some minor clean-up ahead of some ES6 work I'm going to be
doing. One benefit of moving to ES6 is that unused modules will be caught
by ESLint all of the time.
2019-09-16 14:15:53 -04:00
hpinkos ccd1507208 don't require cesium individual source classes in sandcastle app 2019-09-13 15:33:17 -04:00
Shehata 3a389ac5f4 Fix open in new window in shared examples 2019-01-07 07:48:45 -05:00
Omar Shehata bbc7df6eb0 Make it work for built Sandcastle 2018-12-14 15:29:46 -05:00
Omar Shehata d73a37371e Revert mutation observer fix 2018-12-14 13:39:25 -05:00
Omar Shehata 9711de3f89 Make sure standalone works in built/ie11 2018-11-20 14:43:55 -05:00
Omar Shehata 0914c4f84c Make sure open in new window works for development examples 2018-11-19 14:14:07 -05:00
Omar Shehata 73534fe015 Simplify and refactor standalone sandcastle 2018-11-14 13:42:17 -05:00
Omar Shehata cdd3350c17 Use standalone mode for open in new window 2018-11-08 12:48:22 -05:00
Shehata 54e9a55327 Add doc 2018-11-06 16:17:11 -05:00
Shehata f3f8af8824 Fix whitespace formatting 2018-11-06 16:11:25 -05:00
Shehata f55886b024 Wait for DOM to load before loading scripts 2018-11-06 11:01:12 -05:00
Matthew Amato 6e0911e110 Remove all double quote usage from JS code
99% of this PR was automatically fixed with eslint, I simply removed the
`"quotes": "off"` from Sandcastle and Specs which was ignoring the
standard rule of using single quotes.

Also added some Sandcastle generated files to .eslintignore.
2018-07-24 13:28:31 -04:00
Scott Hunter 88b56041a4 Fix back button in Sandcastle.
We store information in history state objects about the loaded demo.

Navigating to new demos calls pushState, and a fresh load
stores the demo specified via URL using replaceState.

Fixes #6509
2018-04-27 17:52:43 -04:00
Matthew Amato 20da7ce293 Fix built Sandcastle.
Cesium is not defined in the built version of Sandcastle.
2018-03-28 23:09:07 -04:00
Matthew Amato 94a2322f4a Auto-generate a label of new demos since last minor version.
If a new demo has been added since the latest minor version (i.e. 1.43.x
will include everything from 1.42.x as new) add it to a `New in 1.x` label.
Make this label always be second in the list after Showcases.
2018-03-28 22:08:20 -04:00
Matthew Amato 61cde1e413 Run sortRequires 2018-03-17 10:19:04 -04:00
Scott Hunter ea11d8a0cb Fix issue with loading HTML from URL.
The code path for loading a demo from the gallery was still being run
after we loaded from the URL, clobbering the URL data.  The gist
codepath only worked because the jsonp request made it so the gallery
demo load was then overwritten by the correct data.

Now we only parse and load from the demo if we actually need it.
2018-03-16 17:09:48 -04:00
Scott Hunter 30c047ed67 Share Sandcastle code using URL instead of gists.
Anonymous gist creation will be removed - #6232

Instead of publishing gists, when we share we now encode the code into
the URL fragment, in compressed Base64 encoded form.  (see code comments
for the exact format)

Existing gists still load as before.
2018-03-16 15:27:18 -04:00
Matthew Amato 0f7c75bd1a Tweak Sandcastle to use less verbose API. 2018-01-30 16:02:57 -05:00
Tom Fili eb19334fd3 Tweaks from PR comments. 2018-01-29 21:03:05 -05:00
Tom Fili 91d306d06a Deprecated low level load functions. 2018-01-22 17:19:18 -05:00
Matthew Amato 86ce911e16 Fix Sandcastle demo loading. 2018-01-18 15:49:24 -05:00
Matthew Amato a285bda500 Add ability to load Sandcastle demos encoded into a url 2018-01-18 15:28:10 -05:00
ggetz 830af5b516 Fix path, add link, build apps in paralell 2017-09-27 10:33:11 -04:00
ggetz b4069fb03e Built sandcastle using unminified cesium 2017-09-22 14:56:50 -04:00
Ottavio Hartman 41e95c3bc1 Fix merge conflicts 2017-06-23 09:22:53 -04:00
Ottavio Hartman 7a734ccc60 Enable block-scoped-var rule 2017-06-16 12:53:12 -04:00
Ottavio Hartman 80cfed7224 Enable no-use-before-define rule for classes and variables. Fix or suppress errors 2017-06-15 18:18:54 -04:00
Jason Wohlgemuth 1ea0bd2839 Inline enable and disable comments on new line 2017-05-23 19:29:52 -05:00
Jason Wohlgemuth 43578febf2 Replace JSHint with ESLint
- Added .eslintrc configuration files
- Added eslint and eslint-watch gulp tasks (added gulp-eslint and eslint-plugin-html deps)
- Removed jshint gulp tasks (and dependencies)
- Refactored inline disable comments in ESLint syntax
- Cleared all new lint errors
- Updated build and test documentation
- Added ESLint to license file
2017-05-18 20:11:17 -05:00
Rachel Hwang 3bf6d7841e sandcastle 403 error handling 2017-04-04 10:21:24 -04:00