Commit Graph

258 Commits

Author SHA1 Message Date
Adam Beili 34945ad3fa Fix missing tsconfig lib and other jsdoc error 2025-10-09 20:57:49 +03:00
jjspace ac3194cdad
update npm packages 2025-06-26 14:02:04 -04:00
jjspace 8bb9d95099
add quick search shortcut to docs 2025-02-18 14:14:50 -05:00
Jeshurun Hembd 1c892c87bd Fix linebreaks in jsdoc-default.css 2025-02-12 10:44:14 -05:00
jjspace 09a719b8fb
run prettier v3 2024-09-20 11:24:24 -04:00
Gabby Getz 8a5f6993bd Differentiate workspace APIs in ref docs 2022-11-01 16:13:09 -04:00
Sanjeet Suhag aaf6bd8a5c Adds engine and widgets workspaces 2022-11-01 15:39:57 -04:00
Peter Gagliardi 7b07a783f6 Explicitly label internal constructors 2022-09-09 17:07:09 -04:00
Peter Gagliardi 294f2728b2 Add some new JSDoc tags for better formatting 2022-09-09 15:35:19 -04:00
Sanjeet Suhag 5395940117 Removes Tools/eslint-config-cesium 2022-06-27 14:10:16 -04:00
Jeshurun Hembd 36be7b412b Import prism files from npm 2022-06-16 14:13:05 -04:00
Gabby Getz ba59bcccf5 Remove redudant "the" 2022-03-21 14:53:43 -04:00
Gabby Getz a4587abd6c Add forum link to docs 2022-03-21 14:43:04 -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
Gabby Getz 1034f73c02 Remove uneeded flag in tsconfig 2022-02-04 09:57:42 -05:00
Gabby Getz c240f4c104 Workaround ambiant const enum errors as per TS docs 2022-02-03 15:56:14 -05:00
Peter Gagliardi 16b3ad0b0d enable template literals in linter settings 2022-02-02 15:34:23 -05:00
Gabby Getz 3de446615c Update eslint config 2022-01-21 11:25:54 -05:00
Sean Lilley fe8fec2d51 master -> main 2021-07-16 19:01:30 -04:00
hpinkos 082dcbad5a change cesiumjs.org urls in docs to cesium.com 2021-03-13 12:52:56 -05:00
Ed Mackey 1512334963 Apparently this is "prettier" 2020-09-21 14:10:05 -04:00
Ed Mackey 598a5cde87 Add background color to doc nav bar, to help with horizontal scrolling. 2020-09-21 13:38:44 -04:00
Matthew Amato 4b6a4d104c More fixes found by Kevin. 2020-05-31 20:41:44 -04:00
Matthew Amato 31571eb22e Fix UrlTemplateImageryProvider
Also opt-in tsd-jsdoc so we can use @template in the future.
2020-05-31 15:43:24 -04:00
Matthew Amato d95eea02be Fix doc links that include a hash. 2020-05-30 02:01:38 -04:00
Kevin Ring 0b17c85168 Use tsconfig.json to avoid errors in some environments. 2020-05-27 17:17:03 +10:00
Kevin Ring d84166d2c5
Don't hardcode ./node_modules/tsd-jsdoc
It may be different in some environments. Instead, just use the normal module name, which will be resolved according to node's module resolution rules.
2020-05-27 15:36:56 +10:00
Matthew Amato 85c78edf31 Generate official TypeScript type definitions
It's been a long requested feature for us to have official TypeScript type
definitions.  While the community has done a yeoman's job of manually
supporting various efforts, the most recent incarnation of which is
`@types/cesium`, the sheer scale and ever-evolving nature of Cesium's code
base makes manual maintenance a Sisyphean task.

Thankfully, our decision to maintain meticulous JSDoc API documentation
continues to pay dividends and is what makes automatically generating
TypeScript definitions possible. Using the excellent
https://github.com/englercj/tsd-jsdoc project we can now automatically
generate and even partially validate official definitions as part of the
build process. (Thanks to @bampakoa who contributed some early PRs to both
CesiumJS and tsd-jsdoc over a year ago and is how I learned about
tsd-jsdoc)

While tsd-jsdoc output is mostly where we need it to be, we do
post-processing on it as well. This lets us clean up the output and also
make sure these definitions work whether users include cesium via module,
i.e. `import { Cartesian3 } from 'cesium'`, or individual files, i.e.
`'import Cartesian3 from 'cesium/Source/Core/Cartesian3'`. There were also
some quirks of tsd-jsdoc output we fixed that may eventually turn into a PR
into that project from us. The post-processing is part typescript compiler
API, part string manipulation. It works and is straightforward but we might
want to go full TS api in the future if we decide we need to do more
complicated tasks. The output of tsd-jsdoc is currently a little noisy
because of some incorrect error reporting, but I'm talking with the
maintainer in https://github.com/englercj/tsd-jsdoc/issues/133 to get them
fixed. No need to hold up this PR for it though.

The definition is generated as a single `Cesium.d.ts` file in Source, so it
lives alongside Cesium.js. It is ignored by git but generated by a separate
`build-ts` task as part of CI and makeZipFile. This task also validates the
file by compiling it with TypeScript, so if a developer does anything too
egregious, the build will fail. Definitions are automatically included in
our npm packages and release zips and will be automatically used by IDEs
thanks to the `types` setting in package.json. This means that IDEs such as
VS Code will prefer these types over the existing `@types/cesium` version
by default.

I didn't want to slow the `build` step down, so I made this a separate
step, but in the future we could consider running it by default and we
could also unignore this file in Git so that PR reviewers can see the
impact, if any, our code changes have on the generated definitions. This
might be a good idea as an additional sanity check and should only actually
change when the public API itself changes. But the issue would be
remembering to run it before submitting the code (or we could use git hooks
I suppose?) I just don't want to slow down devs so I'm hesitant to do
anything like this out of the gate. We can definitely revisit in the
future.

A particular exciting thing about this approach is that it exposed a ton of
badness in our current JSDoc markup, which is now fixed. Previously, our
only concern was "does the doc look right" and we didn't pay attention to
whether the meta information generated by JSDoc correctly captured type
information (because up until it didn't matter). We leaned particular hard
on `@exports` which acted as a catch-all but has now been completely
removed from the codebase. All this means is that our documentation as a
whole has now improved greatly and will continue to be maintained at this
new higher level thanks to incorporating TS definition creation into our
pipeline!

One minor caveat here is that obviously we changed our JSDoc usage to both
make it correct and also accommodate TypeScript. The main drawback to these
fixes is that enums are now generated as globals in the doc, rather than
modules. This means they no longer have their own dedicated page and are
instead on the globals page, but I changed the code to ensure they are
still in the table of contents that we generate. I think this trade-off is
perfectly fine, but I wanted to mention it since it does change the doc
some. We can certainly look into whether we can generate enums on their own
page if we think that makes sense. (I actually like this approach a little
better personally).

Last major piece, the actual code. 99% of the changes in this PR only
affect the JSDoc. There are two exceptions:

A few of our enums also have private functions tacked onto them. I had to
move these functions to be outside the initializer but otherwise they are
unchanged.  This ensures that a valid TS enum is generated from our code, since you can't have functions globbed onto enums in the TS world. If we were writing TS code by hand, we could use  declaration merging with a namespace, but the toolchain we are using doesn't have a way to express that right now.  There were two cases where these extra functions weren't private, `ComponentDataType` and `IndexDataType`. That means that as far as the TS definitions goes, the helper methods don't exist.  I consder this an edge case and we can write up issues to investigate later.  I'm actually not even sure if these functions are public on purposes, @lilleyse can you confirm?

We had a few places where we had method signatures with optional parameters
that came _before_ required parameters, which is silly. This is invalid
TypeScript (and not good API design no matter the language). In 99% of
cases this was `equalsEpsilon` style functions where the lhs/rhs were
optional but the epsilon was not. I remember the discussion around this
when we first did it because we were paranoid about defaulting to 0, but
it's an edge case and it's silly so I just changed the epsilon functions
to default to zero now, problem solved.

Here's a high level summary of the JS changes:

* Use proper `@enum` notation instead of `@exports` for enums.

* Use proper `@namespace` instead of `@exports` for static classes.

* Use proper `@function` instead of `@exports` for standalone functions.

* Fix `Promise` markup to actually include the type in all cases, i.e.
`Promise` => `Promise<void>` or `Promise<Cartesian3[]>`.

* Fix bad markup that referenced types that do not exist (or no longer
exist) at the spec level, `Image` => `HTMLImageElement`,
`Canvas` => `HTMLCanvasElement`, etc.. `TypedArray` in particular does not
exist and much be expressed as a lsit of all applicable types,
`Int8Array|Uint8Array|Int16Array|Uint16Array...`.

* Use dot notation instead of tilde in callbacks, to better support
TypeScript, i.e. `EasingFunction~Callback` becomes
`EasingFunction.Callback`. The only exception is when we had a callback
type that was i.e. `exportKml~ModelCallback` becomes
`exportKmlModelCallback` (a module global type rather than a type on
exportKml). This is because it's not possible to have exportKml be both a
function and a namespace in this current toolchain.  Not a big deal either
way since these are meta-types used for defining callbacks but I wanted to
mention it.

* There were some edge cases where private types that were referenced in
the public API but don't exist in the JSDoc. These were trivial to fix by
either tweaking the JSDoc to avoid leaking the type or in some cases, just
as `PixelDataType`, simply exposing the private type as public.  I also
found a few cases where things were accidentally public, I marked these as
private (these were extreme edge cases so I'm not concerned about breaking
changes). Appearances took an optional `RenderState` in their options, I
just changed the type to `Object` which we can clean up further later if
we need to.

* Lots of other little misc JSDoc issues that became obvious once we
started to generate definitions (duplicate parameters for example).

Thanks again to the community for helping generate ideas and discussions
around TS definitions over the last few years and a big thanks to @javagl
for helping behind the scenes on this specific effort by evaluating a few
different approaches and workaround before we settled on this one (I'm
working on a blog with all of the gory details for those interested).

Finally, while I'm thrilled with how this turned out (all ~41000 lines
and 1.9MB of it), I can guarantee we will uncover some issues with the
type definitions as more people use it. The good news is that improving it
is now just a matter of fixing the JSDoc, which will benefit the community
as a whole and not just TS users.


Fixes #2730
Fixes #5717
2020-05-26 22:40:05 -04:00
Jakub Vrána 9d82570dba Add space to JSDoc attributes
I select text using double click a lot - it selects whole words so that I don't need to be that precise in selecting the beginning of a word and the end of it. The words are delimited by a space, not by visual look. If I try to select e.g. `Cesium.Cartographic.ZERO` in the Cesium docs using this method then it results in `staticconstantCesium.Cartographic.ZERO` being selected because there are no spaces after `static` and `constant`. This commit adds the spaces there.

Tested: jsdoc -c Tools/jsdoc/conf.json
2020-05-10 16:26:33 +02:00
Matthew Amato 2fd0e8f7e4 Format all code with prettier 2020-04-16 20:31:36 -04:00
Matthew Amato f952f45368
Merge pull request #8678 from CesiumGS/doc-wrap
Fix long class name overlap in ref doc
2020-03-19 13:44:02 -04:00
Omar Shehata b8e9555207 Move custom style to jsdoc-default.css 2020-03-19 12:56:14 -04:00
Omar Shehata ec205bb226 Fix long class name overlap in ref doc 2020-03-12 11:12:27 -04:00
Kevin Ring 47fa26074b Fix Cesium in Node.js 12+. 2020-03-04 20:18:08 +11: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
Matthew Amato 4080bc16df Update eslint-config-cesium again 2019-10-23 14:07:17 -04:00
Matthew Amato 1b418c9777 Update eslint-config-cesium for release. 2019-10-23 13:16:28 -04:00
Ed Mackey 0a04deb1db Add abstract attribute 2019-10-11 10:07:30 -04:00
Ed Mackey 49eb21a3ef Add deprecated attribute to JSDoc type sig indicators. 2019-10-11 09:42: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
Matthew Amato de92ad61bf Update version, CHANGES, and ion token for release.
Also update autho metadata to Cesium GS, Inc.
2019-10-01 08:31:20 -04:00
hpinkos 1a8e2dd5a7 update node modules 2019-09-19 11:04:04 -04:00
Matthew Amato b9fe8f33f4 Replace jscoverage with karma-coverage
1. Replace our ancient, windows-only jscoverage implementation with
karma-coverage, which works on all platforms and does not require a
separate instrumentation step. You now run coverage by simply typing
`npm run coverage`. This also provides improved results, such as branch
coverage, which the old system did not.
2. Updated Testing Guide
3. Remove old instrument link from index.html
4. Remove jscoverage and related code.
2019-08-27 21:10:14 -04:00
Matthew Amato 8034629481 eslint configuration updates and fixes
* Update Node ecmaVersion to '2019'.
* Enable [no-tabs](https://eslint.org/docs/rules/no-tabs).
* Enabled [no-restricted-globals](https://eslint.org/docs/rules/no-restricted-globals) for jasmine `fit` and `fdescribe`.
* Remove existing tabs from code-base.
* Update eslint-config-cesium CHANGES and version

Closes #7785
2019-05-03 11:43:18 -04:00
Matthew Amato 593054aa71 eslint-config-cesium: Allow ES6 global variables in Node.js code.
Also bump version for release.
2019-01-23 13:24:04 -05:00
Omar Shehata 2137f1579b Tweak deprecated notice to add newline 2018-12-06 14:46:50 -05:00
Matthew Amato bbc31edfa1 ESLint updates
1. Update to eslint 5.2.0, which has some new default rules.
2. Disable `no-self-assign` in Cesium tests, this new rule is useful but
not in our specs.
3. Allow ES 2017 in node code, this includes async/await, which we have
started using in Cesium-related Node projects
4. Add `no-var` and `prefer-const` as rules for Node code, we've already
have been using them with success in other projects.
5. Bump eslint-config-cesium to 6.0.0 and update CHANGES so I can release
once this is merged.
2018-07-23 20:41:41 -04:00
Matthew Amato 62de9e0a04 Bump eslint-config-cesium version for Release.
Also update CHANGES.md
2018-06-01 11:05:16 -04:00
Shehzan Mohammed 6811863f65 Add empty last line always rule to eslint config, add new lines to generated files 2018-06-01 10:16:48 -04:00
Scott Hunter c0c0ffb890 Patch JSDoc template with additional changes from upstream.
Mostly non-visible changes to reduce other diff noise.
2018-05-16 10:59:27 -04:00