Skip to content

Commit

Permalink
Merge branch 'minor' into admin-roles-param
Browse files Browse the repository at this point in the history
  • Loading branch information
RobAndrewHurst authored Jan 10, 2025
2 parents 3bc3d1e + 494e713 commit e8af809
Show file tree
Hide file tree
Showing 185 changed files with 4,365 additions and 2,644 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ public/js/*
!tests/**
!package.json
!jsdoc*.json
!codi.json
!codi.json
!.prettierrc.json
15 changes: 15 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"printWidth": 80,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"proseWrap": "preserve",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf",
"embeddedLanguageFormatting": "auto"
}
101 changes: 56 additions & 45 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ You will start by

The minimum requirements are:

* Git
* [Node.js](https://nodejs.org/) (version 18 and above)
- Git
- [Node.js](https://nodejs.org/) (version 18 and above)

The executables `git` and `node` should be in your `PATH`.

Expand Down Expand Up @@ -44,51 +44,42 @@ The development environment uses nodemon to watch for changes and automatically

```json
{
"watch": [
"lib/**/*",
"tests/**/*",
"public/css/*",
"../xyz_resources/**/*"
],
"ext": ".js,.mjs,.json,.css,.svg",
"ignore": [
"public/js/**/*",
"public/css/mapp.css",
"public/css/ui.css"
],
"env": {
"NODE_ENV": "DEVELOPMENT"
},
"exec": "npx concurrently \"node esbuild.config.mjs\" \"npm run ui_css\" \"npm run mapp_css\"",
"events": {
"start": "echo \"Watching for changes...\"",
"exit": "echo \"Build complete\""
}
"watch": ["lib/**/*", "tests/**/*", "public/css/*", "../xyz_resources/**/*"],
"ext": ".js,.mjs,.json,.css,.svg",
"ignore": ["public/js/**/*", "public/css/mapp.css", "public/css/ui.css"],
"env": {
"NODE_ENV": "DEVELOPMENT"
},
"exec": "npx concurrently \"node esbuild.config.mjs\" \"npm run ui_css\" \"npm run mapp_css\"",
"events": {
"start": "echo \"Watching for changes...\"",
"exit": "echo \"Build complete\""
}
}
```

#### Watched Directories

* `lib/**/*`: All files in the lib directory
* `tests/**/*`: All test files
* `public/css/*`: CSS source files
* `../xyz_resources/**/*`: External resource files.
- `lib/**/*`: All files in the lib directory
- `tests/**/*`: All test files
- `public/css/*`: CSS source files
- `../xyz_resources/**/*`: External resource files.

#### File Types Watched

* JavaScript files (`.js`)
* ES Modules (`.mjs`)
* JSON files (`.json`)
* CSS files (`.css`)
* SVG files (`.svg`)
- JavaScript files (`.js`)
- ES Modules (`.mjs`)
- JSON files (`.json`)
- CSS files (`.css`)
- SVG files (`.svg`)

#### Ignored Files

* Built JavaScript files (`public/js/**/*`)
- Built JavaScript files (`public/js/**/*`)

* Compiled CSS files:
* `public/css/mapp.css`
* `public/css/ui.css`
- Compiled CSS files:
- `public/css/mapp.css`
- `public/css/ui.css`

#### Automatic Actions

Expand All @@ -108,23 +99,25 @@ When changes are detected:
```

2. Nodemon will:
* Set `NODE_ENV` to "DEVELOPMENT"
* Watch for file changes
* Automatically rebuild affected files
* Display "Watching for changes..." when started
* Show "Build complete" after each rebuild

- Set `NODE_ENV` to "DEVELOPMENT"
- Watch for file changes
- Automatically rebuild affected files
- Display "Watching for changes..." when started
- Show "Build complete" after each rebuild

3. The application will rebuild automatically when you:
* Modify test files
* Change source code
* Update CSS
* Modify resources
- Modify test files
- Change source code
- Update CSS
- Modify resources

This ensures that your test environment always has the latest changes without manual rebuilds.

### VSCode Tasks & Launch

A task can be added to the `.vscode/tasks.json` to execute `nodemon` and `browser-sync` concurrently. This will allow VSCode to rebuild the application on script changes in the editor.
Along side this there is an optional `kill-watch` task that is used to tear down the `start-watch` process once finished with debugging.

```json
{
Expand All @@ -145,12 +138,17 @@ A task can be added to the `.vscode/tasks.json` to execute `nodemon` and `browse
"endsPattern": "Build complete"
}
}
},
{
"label": "kill-watch",
"type": "shell",
"command": "pkill -f nodemon; pkill -f browser-sync"
}
]
}
```

`start-watch` is a `preLaunchTask` which must be added to the debug configuration in the `.vscode/launch.json`.
`start-watch` (preLaunchTask) and `kill-watch` (postDebugTask) must be added to your debug configuration in `.vscode/launch.json` to ensure the watch process starts before debugging and stops after each debugging session.

```json
{
Expand All @@ -161,6 +159,7 @@ A task can be added to the `.vscode/tasks.json` to execute `nodemon` and `browse
"preLaunchTask": "start-watch",
"console": "integratedTerminal",
"internalConsoleOptions": "openOnSessionStart",
"postDebugTask": "kill-watch",
"env": {}
}
```
Expand Down Expand Up @@ -240,6 +239,18 @@ eslint command with fix

There are other extensions you can use in your editor to get on the fly error highlighting where any rules are broken. Please look into what eslint supports in your environment.

## Prettier.io

For formatting we have implemented [prettier.io](prettier.io).
This is so we can ensure that there is consistent formatting across xyz.

To get prettier.io working in your editor you will need to follow one of the setups below:

- [VSCode](https://prettier.io/docs/en/editors#visual-studio-code)
- [Sublime](https://prettier.io/docs/en/editors#sublime-text)
- [Atom](https://prettier.io/docs/en/editors#atom)
- [Vim](https://prettier.io/docs/en/editors#vim)

## version.js hash

The mapp module object holds a hash of the latest release commit which can be generated by executing the version.js script in the root.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**v4.13.0-alpha**
**v4.13.0-beta**

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![Codi Unit Tests](https://github.com/GEOLYTIX/xyz/actions/workflows/unit_tests.yml/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const routes = {

process.env.COOKIE_TTL ??= '36000'

process.env.TITLE ??= 'GEOLYTIX | XYZ'
process.env.TITLE ??= 'XYZ | MAPP'

process.env.DIR ??= ''

Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default [
'max': 4
}
],
//'complexity': ['error', { 'max': 15 }],
// 'complexity': ['error', { 'max': 15 }],
'no-nested-ternary': 'error'
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/layer/decorate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The layer object is returned from the decorator.
The layer decorator method create mapp-layer typedef object from a json-layer.
@param {object} layer JSON layer.
@property {boolean} layer.featureLocation Locations will be gotten from layer.features.
@returns {layer} Decorated Mapp Layer.
*/
Expand Down Expand Up @@ -97,6 +98,9 @@ export default async function decorate(layer) {
.forEach(entry => entry.skipEntry = true)
}

//Remove edit property from infoj entries on featureLocation layer.
layer.featureLocation && layer?.infoj?.forEach(entry => delete entry.edit);

// Call layer and/or plugin methods.
Object.keys(layer).forEach((key) => {
typeof mapp.layer[key] === 'function' && mapp.layer[key]?.(layer);
Expand Down
8 changes: 4 additions & 4 deletions lib/layer/format/maplibre.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default async layer => {

layer.mapview.Map.getTargetElement().prepend(layer.container)

layer.Map = await MaplibreGL({
const maplibreMap = await MaplibreGL({
container: layer.container,
pixelRatio: 1,
style: layer.style.URL,
Expand All @@ -80,10 +80,10 @@ export default async layer => {
}
});

if (!layer.Map) return;
if (!Map) return;

// The Maplibre Map control must resize with mapview Map targetElement.
layer.mapview.Map.getTargetElement().addEventListener('resize', () => layer.Map.resize())
layer.mapview.Map.getTargetElement().addEventListener('resize', () => maplibreMap.resize())

// Handle layer.style.zIndex deprecation.
if (layer.style.zIndex) {
Expand All @@ -100,7 +100,7 @@ export default async layer => {
layer.container.style.visibility = 'visible';

// adjust view parameters in mapbox
layer.Map.jumpTo({
maplibreMap.jumpTo({
center: ol.proj.toLonLat(frameState.viewState.center),
zoom: frameState.viewState.zoom - 1,
bearing: (-frameState.viewState.rotation * 180) / Math.PI,
Expand Down
2 changes: 0 additions & 2 deletions lib/layer/format/mvt.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ export default function MVT(layer) {
layer.source.clear()
layer.source.refresh()

// Reset source tiles to force refresh.
layer.source.sourceTiles_ = {};
layer.featureSource.refresh()

if (callback instanceof Function) callback(layer)
Expand Down
Loading

0 comments on commit e8af809

Please sign in to comment.