Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
updated to JS API 4.24 and 3.41
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinr-maps committed Jul 1, 2022
1 parent 9aaf301 commit 45f9a1b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- default to JSAPI 4.24; update docs w/ latest version numbers - @gavinr

### Changed
- fix build by not compiling @types
- update TypeScript and karma-typescript dependencies
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ For example, the snippet below configures esri-loader to use the [latest 3.x rel
// app.js
import { setDefaultOptions } from 'esri-loader';

// configure esri-loader to use version 3.40 from the ArcGIS CDN
// configure esri-loader to use version 3.41 from the ArcGIS CDN
// NOTE: make sure this is called once before any calls to loadModules()
setDefaultOptions({ version: '3.40' })
setDefaultOptions({ version: '3.41' })
```

Then later, for example after a map component has mounted, you would use `loadModules()` as normal, except in this case you'd be using the [3.x `Map` class](https://developers.arcgis.com/javascript/3/jsapi/map-amd.html) instead of the 4.x classes.
Expand Down Expand Up @@ -195,7 +195,7 @@ import { loadCss } from 'esri-loader';
loadCss();

// or for a specific CDN version
loadCss('3.40');
loadCss('3.41');

// or a from specific URL, like a locally hosted version
loadCss('http://server/path/to/esri/css/main.css');
Expand Down Expand Up @@ -398,7 +398,7 @@ As mentioned above, you can call `setDefaultOptions()` to configure [how esri-lo
| Name | Type | Default Value | Description |
| ----------------- | --------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `version` | `string` | `'4.23'` | The version of the ArcGIS API hosted on Esri's CDN to use. |
| `version` | `string` | `'4.24'` | The version of the ArcGIS API hosted on Esri's CDN to use. |
| `url` | `string` | `undefined` | The URL to a hosted build of the ArcGIS API to use. If both `version` and `url` are passed, `url` will be used. |
| `css` | `string` or `boolean` | `undefined` | If a `string` is passed it is assumed to be the URL of a CSS file to load. Use `css: true` to load the `version`'s CSS from the CDN. |
| `insertCssBefore` | `string` | `undefined` | When using `css`, the `<link>` to the stylesheet will be inserted before the first element that matches this [CSS Selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors). See [Overriding ArcGIS Styles](#overriding-arcgis-styles). |
Expand All @@ -412,9 +412,9 @@ If your application only has a single call to `loadModules()`, you do not need `
```js
import { loadModules } from 'esri-loader';

// configure esri-loader to use version 3.40
// configure esri-loader to use version 3.41
// and the CSS for that version from the ArcGIS CDN
const options = { version: '3.40', css: true };
const options = { version: '3.41', css: true };

loadModules(['esri/map'], options)
.then(([Map]) => {
Expand Down Expand Up @@ -509,7 +509,7 @@ It is possible to use this library only to load modules (i.e. not to lazy load o
```html
<!-- index.html -->
<script src="https://js.arcgis.com/4.23/" data-esri-loader="loaded"></script>
<script src="https://js.arcgis.com/4.24/" data-esri-loader="loaded"></script>
```
### Without a module bundler
Expand Down
8 changes: 4 additions & 4 deletions src/script.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('when loading the script', function() {
});
});
it('should default to latest version', function() {
expect(scriptEl.src).toEqual('https://js.arcgis.com/4.23/');
expect(scriptEl.src).toEqual('https://js.arcgis.com/4.24/');
});
it('should not have called loadCss', function() {
expect((cssUtils.loadCss as jasmine.Spy).calls.any()).toBeFalsy();
Expand Down Expand Up @@ -94,12 +94,12 @@ describe('when loading the script', function() {
});
});
describe('with a specific version from the CDN', function() {
const expected = 'https://js.arcgis.com/3.40/';
const expected = 'https://js.arcgis.com/3.41/';
let scriptEl;
beforeAll(function(done) {
fakeLoading();
loadScript({
version: '3.40'
version: '3.41'
})
.then((script) => {
// hold onto script element for assertions below
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('when loading the script', function() {
});
});
describe('with a specific version from the CDN', () => {
const version = '3.40';
const version = '3.41';
beforeAll(function(done) {
fakeLoading();
loadScript({
Expand Down
6 changes: 3 additions & 3 deletions src/utils/css.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { loadCss } from './css';

describe('when loading the css', () => {
describe('with no arguments', () => {
const url = 'https://js.arcgis.com/4.23/esri/themes/light/main.css';
const url = 'https://js.arcgis.com/4.24/esri/themes/light/main.css';
let link;
beforeAll(() => {
spyOn(document.head, 'appendChild').and.stub();
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('when loading the css', () => {
});
describe('when called twice', () => {
describe('when loading the same url', () => {
const url = 'https://js.arcgis.com/4.23/esri/themes/light/main.css';
const url = 'https://js.arcgis.com/4.24/esri/themes/light/main.css';
let link;
let link2;
beforeAll(() => {
Expand All @@ -93,7 +93,7 @@ describe('when loading the css', () => {
});
});
describe('when inserting before an existing node', () => {
const url = 'https://js.arcgis.com/4.23/esri/themes/light/main.css';
const url = 'https://js.arcgis.com/4.24/esri/themes/light/main.css';
// insert before the first <style> tag
const before = 'style';
let link;
Expand Down
8 changes: 4 additions & 4 deletions src/utils/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ describe ('when getting CDN URLs', () => {
describe('for the script', () => {
describe('with no arguments', () => {
it('should default to latest 4.x URL', () => {
expect(getCdnUrl()).toEqual('https://js.arcgis.com/4.23/');
expect(getCdnUrl()).toEqual('https://js.arcgis.com/4.24/');
});
});
describe('with a valid version', () => {
it('should return URL for that version', () => {
expect(getCdnUrl('3.40')).toEqual('https://js.arcgis.com/3.40/');
expect(getCdnUrl('3.41')).toEqual('https://js.arcgis.com/3.41/');
});
});
// TODO: what about an invalid version? should we throw?
});
describe('for the CSS', () => {
describe('with no arguments', () => {
it('should default to the latest 4.x CSS URL', () => {
expect(getCdnCssUrl()).toEqual('https://js.arcgis.com/4.23/esri/themes/light/main.css');
expect(getCdnCssUrl()).toEqual('https://js.arcgis.com/4.24/esri/themes/light/main.css');
});
});
describe('for 3.x version >= 3.11', () => {
it('should return the CSS URL for that version', () => {
expect(getCdnCssUrl('3.40')).toEqual('https://js.arcgis.com/3.40/esri/css/esri.css');
expect(getCdnCssUrl('3.41')).toEqual('https://js.arcgis.com/3.41/esri/css/esri.css');
});
});
describe('for version < 3.11', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/url.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
* Apache-2.0 */

const DEFAULT_VERSION = '4.23';
const DEFAULT_VERSION = '4.24';
const NEXT = 'next';

export function parseVersion(version) {
Expand All @@ -19,7 +19,7 @@ export function parseVersion(version) {
/**
* Get the CDN url for a given version
*
* @param version Ex: '4.23' or '3.40'. Defaults to the latest 4.x version.
* @param version Ex: '4.24' or '3.41'. Defaults to the latest 4.x version.
*/
export function getCdnUrl(version = DEFAULT_VERSION) {
return `https://js.arcgis.com/${version}/`;
Expand All @@ -28,7 +28,7 @@ export function getCdnUrl(version = DEFAULT_VERSION) {
/**
* Get the CDN url for a the CSS for a given version and/or theme
*
* @param version Ex: '4.23', '3.40', or 'next'. Defaults to the latest 4.x version.
* @param version Ex: '4.24', '3.41', or 'next'. Defaults to the latest 4.x version.
*/
export function getCdnCssUrl(version = DEFAULT_VERSION) {
const baseUrl = getCdnUrl(version);
Expand Down

0 comments on commit 45f9a1b

Please sign in to comment.