@geosynk/vertigis-web-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +210 -0
  3. package/bin/vertigis-web-sdk.js +17 -0
  4. package/config/eslint.config.js +201 -0
  5. package/config/eslint.config.js.template +11 -0
  6. package/config/tsconfig.json +3 -0
  7. package/config/tsconfig.json.template +9 -0
  8. package/config/webpack.config.js +54 -0
  9. package/lib/index.ejs +133 -0
  10. package/package.json +72 -0
  11. package/scripts/build.js +48 -0
  12. package/scripts/create.js +113 -0
  13. package/scripts/start.js +41 -0
  14. package/scripts/upgrade.js +12 -0
  15. package/template/.prettierignore +1 -0
  16. package/template/.prettierrc +6 -0
  17. package/template/.vscode/extensions.json +3 -0
  18. package/template/README.md +51 -0
  19. package/template/app/app.json +1067 -0
  20. package/template/app/layout.xml +22 -0
  21. package/template/gitignore +2 -0
  22. package/template/package.json +27 -0
  23. package/template/src/components/PointsOfInterest/PointOfInterest.css +6 -0
  24. package/template/src/components/PointsOfInterest/PointOfInterest.tsx +50 -0
  25. package/template/src/components/PointsOfInterest/PointOfInterestModel.ts +13 -0
  26. package/template/src/components/PointsOfInterest/PointsOfInterest.css +4 -0
  27. package/template/src/components/PointsOfInterest/PointsOfInterest.tsx +44 -0
  28. package/template/src/components/PointsOfInterest/PointsOfInterestModel.ts +127 -0
  29. package/template/src/components/PointsOfInterest/index.ts +4 -0
  30. package/template/src/index.ts +26 -0
  31. package/template/webpack.config.js +5 -0
  32. package/template-custom/AGENTS.md +47 -0
  33. package/template-custom/app/app.json +1067 -0
  34. package/template-custom/app/layout.xml +22 -0
  35. package/template-custom/build.bat +11 -0
  36. package/template-custom/build.sh +15 -0
  37. package/template-custom/certs/generate-cert.bat +14 -0
  38. package/template-custom/certs/generate-cert.sh +14 -0
  39. package/template-custom/src/components/CustomWidget/CustomWidget.tsx +70 -0
  40. package/template-custom/src/components/CustomWidget/CustomWidgetModel.ts +15 -0
  41. package/template-custom/src/components/CustomWidget/components/CustomWidgetErrorBoundary.tsx +57 -0
  42. package/template-custom/src/components/CustomWidget/index.ts +3 -0
  43. package/template-custom/src/hooks/index.ts +1 -0
  44. package/template-custom/src/hooks/useIsDarkTheme.ts +56 -0
  45. package/template-custom/src/index.ts +20 -0
  46. package/template-custom/src/tokens/index.ts +24 -0
  47. package/template-custom/src/tokens/typography.ts +33 -0
  48. package/template-custom/src/tokens/ui.ts +60 -0
  49. package/template-custom/src/utils/index.ts +1 -0
  50. package/template-custom/src/utils/themeDetection.ts +56 -0
  51. package/template-custom/start.bat +17 -0
  52. package/template-custom/start.sh +23 -0
  53. package/template-custom/webpack.config.js +121 -0
  54. package/test/index.js +22 -0
@@ -0,0 +1,22 @@
1
+ <layout xmlns="https://geocortex.com/layout/v1" id="layout-4f5dc45c">
2
+ <split id="split-a5817a92" resizable="true" config="root">
3
+ <tabs xmlns="https://geocortex.com/layout/web/v1" id="tabs-543112c0" config="589a9171-58ec-426f-8d3c-c9360652a9ba" grow="0" width="30.714285714285715">
4
+ <workflow xmlns="https://geocortex.com/layout/v1" id="workflow-3581b6f4" active="false" config="workflow-config-1"/>
5
+ <results-list xmlns="https://geocortex.com/layout/v1" id="results-list-b080e39e" config="d14a8d22-a132-47cf-9d50-b9c759a97ebd"/>
6
+ <results-list xmlns="https://geocortex.com/layout/v1" id="results-list-3662ab43" config="4a52c284-ccb6-4a55-a8d6-94b632d838ed"/>
7
+ <feature-details xmlns="https://geocortex.com/layout/v1" id="feature-details-ec4c6c29" config="333edeb8-b651-4d17-b361-46fc5603c71d"/>
8
+ <legend xmlns="https://geocortex.com/layout/v1" id="legend-ab7f8a19" config="e1c66411-032e-412a-b41f-b9892dd5246d" models="#map-primary"/>
9
+ <layer-list xmlns="https://geocortex.com/layout/v1" id="layer-list-826e9f3a" config="c1aa340a-8a4c-4034-b397-f46157b14217" models="#map-primary"/>
10
+ </tabs>
11
+ <map id="map-primary" config="default" grow="100">
12
+ <search id="search-2557a463" config="search-config-1" width="20" slot="top-end"/>
13
+ <button id="button-3c133eaf" config="a4f5334d-96c3-41e9-983e-75f10fc8b1c8"/>
14
+ <button id="button-9119cbb6" config="931927bb-e741-4ae8-ba08-e22b3daf8aa1"/>
15
+ <map-3d-toggle xmlns="https://geocortex.com/layout/web/v1" id="map-3d-toggle-376f6dd3" config="map-3d-toggle-config-1" slot="top-end"/>
16
+ <compass id="compass-b4586b9f" config="compass-config-1" slot="top-start"/>
17
+ <scalebar id="scalebar-39a846f2" config="scalebar-config-1" slot="bottom-start"/>
18
+ <button id="button-eb8881da" config="measure-button-config" show-title="false" slot="bottom-start"/>
19
+ <button id="button-801867d1" config="get-user-coordinates-button-config" show-title="false" slot="bottom-start"/>
20
+ </map>
21
+ </split>
22
+ </layout>
@@ -0,0 +1,2 @@
1
+ build/
2
+ node_modules/
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "vertigis-studio-web-project",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "description": "",
6
+ "license": "UNLICENSED",
7
+ "author": "",
8
+ "type": "module",
9
+ "scripts": {
10
+ "build": "vertigis-web-sdk build",
11
+ "start": "vertigis-web-sdk start",
12
+ "lint": "eslint --ext .ts,.tsx",
13
+ "prettier": "prettier --write \"**/*.json\" \"**/*.js\" \"**/*.ts\" \"**/*.tsx\""
14
+ },
15
+ "dependencies": {},
16
+ "devDependencies": {
17
+ "typescript": "^5.4.0",
18
+ "prettier": "~3.5.3"
19
+ },
20
+ "overrides": {
21
+ "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
22
+ },
23
+ "allowScripts": {
24
+ "@mui/x-telemetry": false,
25
+ "@vaadin/vaadin-usage-statistics": false
26
+ }
27
+ }
@@ -0,0 +1,6 @@
1
+ .PointOfInterest-swatch {
2
+ height: 20px;
3
+ width: 20px;
4
+ border-radius: 50%;
5
+ margin-right: 16px;
6
+ }
@@ -0,0 +1,50 @@
1
+ import { xyToLngLat } from "@arcgis/core/geometry/support/webMercatorUtils";
2
+ import { format as formatNumber } from "@vertigis/arcgis-extensions/utilities/format/number";
3
+ import { useWatchAndRerender } from "@vertigis/web/ui";
4
+ import Box from "@vertigis/web/ui/Box";
5
+ import DynamicIcon from "@vertigis/web/ui/DynamicIcon";
6
+ import IconButton from "@vertigis/web/ui/IconButton";
7
+ import ListItemText from "@vertigis/web/ui/ListItemText";
8
+ import type { MenuItemProps } from "@vertigis/web/ui/MenuItem";
9
+ import MenuItem from "@vertigis/web/ui/MenuItem";
10
+ import MenuItemSecondaryAction from "@vertigis/web/ui/MenuItemSecondaryAction";
11
+ import type { FC } from "react";
12
+
13
+ import type PointOfInterestModel from "./PointOfInterestModel";
14
+ import "./PointOfInterest.css";
15
+
16
+ function formatLatLon(n: number): string {
17
+ // formatNumber() respects locale and the app's configured region settings.
18
+ return `${formatNumber({ fractionalDigits: 2 }, n)}°`;
19
+ }
20
+
21
+ export interface PointOfInterestProps extends MenuItemProps {
22
+ model: PointOfInterestModel;
23
+ onDelete?: () => void;
24
+ }
25
+
26
+ const PointOfInterest: FC<PointOfInterestProps> = ({ model, onDelete, ...other }) => {
27
+ const { title, geometry, color } = model;
28
+
29
+ // Re-render whenever any of these properties change. Notice how you can
30
+ // deeply watch properties like "geometry.x", which will update whenever
31
+ // anything along the path changes.
32
+ useWatchAndRerender(model, ["title", "geometry.x", "geometry.y", "color"]);
33
+ const [lon, lat] = xyToLngLat(geometry.x, geometry.y);
34
+ return (
35
+ <MenuItem {...other}>
36
+ <Box className="PointOfInterest-swatch" style={{ backgroundColor: color.toCss() }} />
37
+ <ListItemText
38
+ primary={title}
39
+ secondary={`Lat: ${formatLatLon(lat)}, Lon: ${formatLatLon(lon)}`}
40
+ />
41
+ <MenuItemSecondaryAction>
42
+ <IconButton onClick={onDelete} title="Delete">
43
+ <DynamicIcon src="trash" />
44
+ </IconButton>
45
+ </MenuItemSecondaryAction>
46
+ </MenuItem>
47
+ );
48
+ };
49
+
50
+ export default PointOfInterest;
@@ -0,0 +1,13 @@
1
+ import type Color from "@arcgis/core/Color";
2
+ import type Point from "@arcgis/core/geometry/Point";
3
+ import { ModelBase, serializable } from "@vertigis/web/models";
4
+
5
+ /**
6
+ * A single point of interest on the map.
7
+ */
8
+ @serializable
9
+ export default class PointOfInterestModel extends ModelBase {
10
+ title: string;
11
+ color: Color;
12
+ geometry: Point;
13
+ }
@@ -0,0 +1,4 @@
1
+ .PointsOfInterest {
2
+ background-color: var(--primaryBackground);
3
+ padding: 1rem;
4
+ }
@@ -0,0 +1,44 @@
1
+ import type { LayoutElementProperties } from "@vertigis/web/components";
2
+ import { LayoutElement } from "@vertigis/web/components";
3
+ import { useWatchCollectionAndRerender } from "@vertigis/web/ui";
4
+ import MenuList from "@vertigis/web/ui/MenuList";
5
+ import Typography from "@vertigis/web/ui/Typography";
6
+ import type { FC } from "react";
7
+
8
+ import PointOfInterest from "./PointOfInterest";
9
+ import type PointsOfInterestModel from "./PointsOfInterestModel";
10
+ import "./PointsOfInterest.css";
11
+
12
+ const PointsOfInterest: FC<LayoutElementProperties<PointsOfInterestModel>> = props => {
13
+ const { model } = props;
14
+ // Re-render whenever points of interest are added or removed from the
15
+ // collection.
16
+ useWatchCollectionAndRerender(model.pointsOfInterest);
17
+ return (
18
+ <LayoutElement {...props} stretch className="PointsOfInterest">
19
+ <Typography variant="h2">Points of Interest</Typography>
20
+ <MenuList>
21
+ {model.pointsOfInterest.toArray().map(poi => (
22
+ <PointOfInterest
23
+ key={poi.id}
24
+ model={poi}
25
+ onClick={() => {
26
+ // This function returns `Promise<void>` which
27
+ // resolves when the map is done zooming, but in
28
+ // this case we only need to kick it off and don't
29
+ // need to wait for it to finish.
30
+ //
31
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
32
+ model.goto(poi);
33
+ }}
34
+ onDelete={() => {
35
+ model.pointsOfInterest.remove(poi);
36
+ }}
37
+ />
38
+ ))}
39
+ </MenuList>
40
+ </LayoutElement>
41
+ );
42
+ };
43
+
44
+ export default PointsOfInterest;
@@ -0,0 +1,127 @@
1
+ import Collection from "@arcgis/core/core/Collection";
2
+ import type Point from "@arcgis/core/geometry/Point";
3
+ import type { ChangeEvent } from "@vertigis/arcgis-extensions/support/esri";
4
+ import type { LocationMarkerEvent } from "@vertigis/viewer-spec/messaging/registry/location-marker";
5
+ import { toColor } from "@vertigis/web/branding";
6
+ import type { MapModel } from "@vertigis/web/mapping";
7
+ import { command, type HasGeometry } from "@vertigis/web/messaging";
8
+ import { ComponentModelBase, serializable, type ComponentModelProperties, importModel } from "@vertigis/web/models";
9
+
10
+ import PointOfInterestModel from "./PointOfInterestModel";
11
+
12
+ export type PointsOfInterestModelProperties = ComponentModelProperties;
13
+
14
+ const colors = [
15
+ "#0000ff",
16
+ "#ff0000",
17
+ "#33ff00",
18
+ "#0066ff",
19
+ "#ff0099",
20
+ "#ccff00",
21
+ "#00ffff",
22
+ "#cc00ff",
23
+ "#ff9900",
24
+ "#00ff66",
25
+ ];
26
+
27
+ @serializable
28
+ export default class PointsOfInterestModel extends ComponentModelBase<PointsOfInterestModelProperties> {
29
+ // Declares a dependency on the map component. The value of `map` is
30
+ // automatically managed by the framework.
31
+ @importModel("map-extension")
32
+ map: MapModel;
33
+
34
+ // Using an esri Collection instead of an array allows us to watch for
35
+ // changes.
36
+ readonly pointsOfInterest = new Collection<PointOfInterestModel>();
37
+ private _nextId = 1;
38
+
39
+ /**
40
+ * Creates a new point of interest at the specified location.
41
+ */
42
+ @command("points-of-interest.create")
43
+ async createNew(location: HasGeometry): Promise<void> {
44
+ const id = this._nextId++;
45
+
46
+ // Prompt the user for a name using the built-in ui.prompt operation.
47
+ const title = await this.messages.operations.ui.prompt.execute({
48
+ title: "New Point",
49
+ message: "Name",
50
+ });
51
+ if (!title) {
52
+ // User canceled or didn't type anything.
53
+ return;
54
+ }
55
+ const color = colors[id % colors.length];
56
+ const poi = new PointOfInterestModel({
57
+ id: id.toString(),
58
+ });
59
+ poi.title = title;
60
+ poi.color = toColor(color);
61
+ poi.geometry = location.geometry as Point;
62
+ this.pointsOfInterest.add(poi);
63
+ }
64
+
65
+ /**
66
+ * Zooms the map to the specified point of interest.
67
+ */
68
+ async goto(poi: PointOfInterestModel): Promise<void> {
69
+ await this.messages.commands.map.zoomToViewpoint.execute({
70
+ viewpoint: { targetGeometry: poi.geometry, scale: 50000000 },
71
+ });
72
+ }
73
+
74
+ protected override async _onInitialize(): Promise<void> {
75
+ // This method is invoked automatically when the model is first created.
76
+ // It gives you an opportunity to perform async initialization. It is
77
+ // also the first opportunity to use injected dependencies such as the
78
+ // message bus. Remember to always invoke the super version when you
79
+ // override a method.
80
+ await super._onInitialize();
81
+
82
+ // Everything that extends `ComponentModelBase` will have a special
83
+ // collection attached called `_handles`. You can add the results of
84
+ // any event subscriptions here and they will be cleaned up
85
+ // automatically.
86
+ this._handles.add(
87
+ this.messages.events.locationMarker.updated.subscribe(this._onMarkerUpdated),
88
+ this.pointsOfInterest.on("change", this._onPointOfInterestsChange)
89
+ );
90
+ }
91
+
92
+ private readonly _onMarkerUpdated = (e: LocationMarkerEvent): void => {
93
+ const matchingPoi = this.pointsOfInterest.find(poi => poi.id === e.id);
94
+ if (matchingPoi) {
95
+ matchingPoi.geometry = e.geometry as Point;
96
+ }
97
+ };
98
+
99
+ private readonly _onPointOfInterestsChange = async (e: ChangeEvent<PointOfInterestModel>): Promise<void> => {
100
+ // Add or remove markers on the map as appropriate whenever the
101
+ // collection changes.
102
+ if (e.added?.length) {
103
+ await Promise.all(
104
+ e.added.map(poi =>
105
+ this.messages.commands.locationMarker.create.execute({
106
+ id: poi.id,
107
+ geometry: poi.geometry,
108
+ maps: this.map,
109
+ color: poi.color,
110
+ userDraggable: true,
111
+ scale: 1.5,
112
+ })
113
+ )
114
+ );
115
+ }
116
+ if (e.removed?.length) {
117
+ await Promise.all(
118
+ e.removed.map(poi =>
119
+ this.messages.commands.locationMarker.remove.execute({
120
+ id: poi.id,
121
+ maps: this.map,
122
+ })
123
+ )
124
+ );
125
+ }
126
+ };
127
+ }
@@ -0,0 +1,4 @@
1
+ import PointsOfInterestModel from "./PointsOfInterestModel";
2
+
3
+ export { default } from "./PointsOfInterest";
4
+ export { PointsOfInterestModel };
@@ -0,0 +1,26 @@
1
+ import type { LibraryRegistry } from "@vertigis/web/config";
2
+
3
+ import PointsOfInterest, { PointsOfInterestModel } from "./components/PointsOfInterest";
4
+
5
+ const LAYOUT_NAMESPACE = "custom.foo";
6
+
7
+ export default function (registry: LibraryRegistry): void {
8
+ registry.registerComponent({
9
+ // Show in the `map` category of the component toolbox.
10
+ category: "map",
11
+ iconId: "station-locator",
12
+ name: "points-of-interest",
13
+ namespace: LAYOUT_NAMESPACE,
14
+ getComponentType: () => PointsOfInterest,
15
+ itemType: "points-of-interest-model",
16
+ title: "Points of Interest",
17
+ });
18
+ registry.registerModel({
19
+ getModel: config => new PointsOfInterestModel(config),
20
+ itemType: "points-of-interest-model",
21
+ });
22
+ registry.registerCommand({
23
+ name: "points-of-interest.create",
24
+ itemType: "points-of-interest-model",
25
+ });
26
+ }
@@ -0,0 +1,5 @@
1
+ import defaultWebpackConfig, { merge } from "@vertigis/web-sdk/config/webpack.config.js";
2
+
3
+ export default merge(defaultWebpackConfig, {
4
+ // Add custom webpack configuration for your project here.
5
+ });
@@ -0,0 +1,47 @@
1
+ # Repository Agent Directives
2
+
3
+ <!-- vertigis-web-sdk:start -->
4
+ # VertiGIS Studio Web SDK Development Directives
5
+
6
+ > **Mandatory Agent Directive**: Whenever you make any change to or create any web component in this repository, ALWAYS check and verify it against VertiGIS Web SDK standards (LayoutElement wrapper, MobX observer, MUI components with sx tokens, zero hardcoded colors, design token architecture, dual-theme adaptation, strict 150–250 line component modularity, and ErrorBoundary wrapper).
7
+
8
+ ## 1. Typography System
9
+ - **Strict ban on raw HTML text elements**: Never use raw `<span>`, `<p>`, or `<h1>`-`<h6>` tags.
10
+ - **MUI Typography Component**: Always use `@mui/material` `<Typography variant="...">`:
11
+ - `h5`, `h6`: Widget titles and primary container headers.
12
+ - `subtitle1`, `subtitle2`: Section headers, grouping titles, and card subheadings.
13
+ - `body1`, `body2`: Primary and secondary descriptive body text.
14
+ - `caption`, `overline`: Microcopy, timestamps, metadata labels, and status badges.
15
+ - **Semantic Text Color Tokens**: Always pair Typography variants with semantic foreground tokens via `sx`:
16
+ - Primary text: `color: "var(--primaryForeground, #1e1e1e)"`
17
+ - Secondary/muted text: `color: "var(--secondaryForeground, #666666)"`
18
+ - Inactive/disabled text: `color: "var(--disabledForeground, #9e9e9e)"`
19
+ - **Font Family**: Use `fontFamily: "var(--defaultFont)"` (inherited automatically through MUI components).
20
+
21
+ ## 2. Color & Design Tokens Subsystem
22
+ - **Zero Hardcoded Colors**: Strict ban on hardcoded hex (`#ffffff`), RGB (`rgb(...)`), or HSL color values for UI chrome, backgrounds, text, and borders.
23
+ - **Safe Fallback Requirement**: ALWAYS provide safe fallbacks for CSS variable tokens (e.g., `var(--primaryBackground, #ffffff)`) to ensure resilient rendering in headless, disconnected, or preview environments.
24
+ - **Standardized Token Architecture**: Group all tokens under a `tokens/` directory:
25
+ - `tokens/ui.ts`: Surface, border, foreground, accent, interactive, and alert tokens.
26
+ - `tokens/typography.ts`: Typography hierarchy, font families, and weights.
27
+ - `tokens/index.ts`: Central barrel export and `color-mix()` dynamic tinting utilities.
28
+ - **Dynamic Dual-Theme Adaptation**:
29
+ - Use `color-mix(in srgb, ...)` for derived tints, hover states, muted borders, and transparent overlays to adapt automatically to light and dark themes without manual CSS overrides.
30
+ - Use the canonical reactive `useIsDarkTheme()` hook for DOM/shell theme detection.
31
+ - Use `isDarkTheme()` standalone utility for non-CSS contexts (Plotly, canvas renderers, third-party iframe bridges, PDF exports).
32
+ - **MUI Theme Integration**: Apply `createTheme` overrides and `ThemeProvider` to align composite controls (sliders, toggle buttons, pickers) with VertiGIS shell branding.
33
+ - **GIS Visual Hierarchy**: Keep UI chrome neutral and subdued so the GIS map canvas remains the focal point. Ensure WCAG AA contrast compliance (minimum 4.5:1 for normal text, 3:1 for large text).
34
+
35
+ ## 3. Strict Component Modularity & Anti-God-Component Architecture
36
+ - **Strict File Size Thresholds**: Max 150–250 lines per file. Any file exceeding 250 lines MUST be refactored and decomposed.
37
+ - **Standard Directory Blueprint**: Decompose complex components into:
38
+ - `components/`: Presentational, stateless sub-components.
39
+ - `hooks/`: Custom React hooks for state, lifecycle subscriptions, and business logic.
40
+ - `tokens/`: Centralized design token definitions and theme utilities.
41
+ - `services/`: Component-level services and integrations.
42
+ - `utils/`: Pure helper functions, defaults, formatters, and algorithms.
43
+ - `types/`: Shared domain models and TypeScript interfaces.
44
+ - **Model vs View Separation**:
45
+ - Component Model (`*Model.ts`): Inherits `ComponentModelBase`, decorates with `@serializable` / `@importModel`, and manages VertiGIS lifecycle hooks (`_onInitialize`, `_load`, `_unload`, `_onDestroy`).
46
+ - Component View (`*.tsx`): Pure React component wrapped in `observer()`, wrapped in `<LayoutElement {...props}>`, and encapsulated inside `<ErrorBoundary>`.
47
+ <!-- vertigis-web-sdk:end -->