@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.
- package/LICENSE +21 -0
- package/README.md +210 -0
- package/bin/vertigis-web-sdk.js +17 -0
- package/config/eslint.config.js +201 -0
- package/config/eslint.config.js.template +11 -0
- package/config/tsconfig.json +3 -0
- package/config/tsconfig.json.template +9 -0
- package/config/webpack.config.js +54 -0
- package/lib/index.ejs +133 -0
- package/package.json +72 -0
- package/scripts/build.js +48 -0
- package/scripts/create.js +113 -0
- package/scripts/start.js +41 -0
- package/scripts/upgrade.js +12 -0
- package/template/.prettierignore +1 -0
- package/template/.prettierrc +6 -0
- package/template/.vscode/extensions.json +3 -0
- package/template/README.md +51 -0
- package/template/app/app.json +1067 -0
- package/template/app/layout.xml +22 -0
- package/template/gitignore +2 -0
- package/template/package.json +27 -0
- package/template/src/components/PointsOfInterest/PointOfInterest.css +6 -0
- package/template/src/components/PointsOfInterest/PointOfInterest.tsx +50 -0
- package/template/src/components/PointsOfInterest/PointOfInterestModel.ts +13 -0
- package/template/src/components/PointsOfInterest/PointsOfInterest.css +4 -0
- package/template/src/components/PointsOfInterest/PointsOfInterest.tsx +44 -0
- package/template/src/components/PointsOfInterest/PointsOfInterestModel.ts +127 -0
- package/template/src/components/PointsOfInterest/index.ts +4 -0
- package/template/src/index.ts +26 -0
- package/template/webpack.config.js +5 -0
- package/template-custom/AGENTS.md +47 -0
- package/template-custom/app/app.json +1067 -0
- package/template-custom/app/layout.xml +22 -0
- package/template-custom/build.bat +11 -0
- package/template-custom/build.sh +15 -0
- package/template-custom/certs/generate-cert.bat +14 -0
- package/template-custom/certs/generate-cert.sh +14 -0
- package/template-custom/src/components/CustomWidget/CustomWidget.tsx +70 -0
- package/template-custom/src/components/CustomWidget/CustomWidgetModel.ts +15 -0
- package/template-custom/src/components/CustomWidget/components/CustomWidgetErrorBoundary.tsx +57 -0
- package/template-custom/src/components/CustomWidget/index.ts +3 -0
- package/template-custom/src/hooks/index.ts +1 -0
- package/template-custom/src/hooks/useIsDarkTheme.ts +56 -0
- package/template-custom/src/index.ts +20 -0
- package/template-custom/src/tokens/index.ts +24 -0
- package/template-custom/src/tokens/typography.ts +33 -0
- package/template-custom/src/tokens/ui.ts +60 -0
- package/template-custom/src/utils/index.ts +1 -0
- package/template-custom/src/utils/themeDetection.ts +56 -0
- package/template-custom/start.bat +17 -0
- package/template-custom/start.sh +23 -0
- package/template-custom/webpack.config.js +121 -0
- package/test/index.js +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 VertiGIS Studio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://geosynk.com.au/" target="_blank" rel="noopener noreferrer">
|
|
3
|
+
<img src="https://geosynk.com.au/images/logo/LOGO_MAIN1.svg" alt="Geosynk" width="380" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# VertiGIS Studio Web SDK (Enterprise Edition)
|
|
8
|
+
|
|
9
|
+
[](https://geosynk.com.au/)
|
|
10
|
+
[](https://www.npmjs.com/package/@geosynk/vertigis-web-sdk)
|
|
11
|
+
[](https://github.com/vertigis/vertigis-web-sdk)
|
|
12
|
+
[](#enterprise-architectural-features)
|
|
13
|
+
[](#1-centralized-design-token-subsystem)
|
|
14
|
+
|
|
15
|
+
An enterprise-enhanced fork of the official [VertiGIS Studio Web SDK](https://vertigisstudio.com/products/vertigis-studio-web/), maintained and engineered by [Geosynk](https://geosynk.com.au/) (Davood Kazemi). This repository bootstraps production-grade extension libraries pre-configured with centralized design tokens, dynamic light/dark theming, strict anti-god-component architecture, automated OpenSSL certificates, and AI assistant directives (`AGENTS.md`), while preserving 100% compatibility with official VertiGIS upstream updates.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Enterprise Architectural Features
|
|
20
|
+
|
|
21
|
+
Every project scaffolded from this repository includes:
|
|
22
|
+
|
|
23
|
+
1. **Centralized Design Token Subsystem (`src/tokens/`)**:
|
|
24
|
+
- `tokens/ui.ts`: 35+ semantic tokens with **100% safe fallbacks** (`var(--primaryBackground, #ffffff)`), guaranteeing visual resilience in unit tests and Storybook sandboxes.
|
|
25
|
+
- `tokens/typography.ts`: Standardized font stack (`var(--defaultFont)`), font scale, and line heights.
|
|
26
|
+
- `tokens/index.ts`: Native CSS `color-mix(in srgb, ...)` utilities (`alphaMix` and `surfaceMix`) for dynamic, cross-theme tints, hover states, and muted borders without manual media queries.
|
|
27
|
+
|
|
28
|
+
2. **Dynamic Dual-Theme System (`src/hooks/useIsDarkTheme.ts`)**:
|
|
29
|
+
- Reactive React hook tracking active theme mode via MUI theme, OS `prefers-color-scheme`, and `MutationObserver` on `.vsw-app`/DOM.
|
|
30
|
+
- `src/utils/themeDetection.ts`: Standalone `isDarkTheme()` utility with ITU-R BT.709 perceived luminance calculation for non-CSS engines (HTML5 canvas, Plotly charts, and PDF exports).
|
|
31
|
+
|
|
32
|
+
3. **Anti-God-Component Architecture (150–250 Line Ceilings)**:
|
|
33
|
+
- Sample widget (`src/components/CustomWidget/`) cleanly decomposed into MobX Model (`CustomWidgetModel.ts`), React View (`CustomWidget.tsx`), and error boundary (`components/CustomWidgetErrorBoundary.tsx`).
|
|
34
|
+
- Strict separation of concerns between VertiGIS service state, presentation, and pure utilities.
|
|
35
|
+
|
|
36
|
+
4. **Automated Development SSL Certificates (`certs/`)**:
|
|
37
|
+
- Zero-configuration HTTPS: automated OpenSSL certificate generation via `certs/generate-cert.sh` / `certs/generate-cert.bat`.
|
|
38
|
+
- Automatically executed on project creation or during first startup.
|
|
39
|
+
|
|
40
|
+
5. **Cross-Platform Startup & Build Scripts**:
|
|
41
|
+
- `start.sh` / `start.bat`: Checks and kills stale port 3000 processes, verifies SSL certificates, and launches the development server.
|
|
42
|
+
- `build.sh` / `build.bat`: Compiles and validates production bundles into `dist/`.
|
|
43
|
+
|
|
44
|
+
6. **Coding Assistant Governance (`AGENTS.md`)**:
|
|
45
|
+
- Pre-injected VertiGIS Web SDK directives ensuring AI coding assistants (such as Antigravity, Claude Code, Cursor, Copilot) strictly follow typography rules, token usage, and file size limits.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Creating a New Project
|
|
50
|
+
|
|
51
|
+
### Option A: From NPM Registry (Recommended)
|
|
52
|
+
```bash
|
|
53
|
+
npx @geosynk/vertigis-web-sdk create my-web-library
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Option B: Direct from GitHub (Zero Registry / No NPM Publish Required)
|
|
57
|
+
```bash
|
|
58
|
+
npx github:davekazemi/vertigis-web-sdk create my-web-library
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Option C: Local Linked SDK (Instant Local Development)
|
|
62
|
+
Inside this repository:
|
|
63
|
+
```bash
|
|
64
|
+
npm link
|
|
65
|
+
```
|
|
66
|
+
Then anywhere on your machine:
|
|
67
|
+
```bash
|
|
68
|
+
vertigis-web-sdk create my-web-library
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Scaffolded Project Structure
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
my-web-library/
|
|
77
|
+
├── .vscode/ ← VS Code recommended extensions
|
|
78
|
+
├── certs/ ← Self-signed SSL certs for HTTPS devServer
|
|
79
|
+
│ ├── cert.pem
|
|
80
|
+
│ ├── key.pem
|
|
81
|
+
│ └── generate-cert.sh / .bat
|
|
82
|
+
├── app/
|
|
83
|
+
│ ├── app.json ← VertiGIS Studio Web app configuration
|
|
84
|
+
│ └── layout.xml ← Layout XML defining slots and panels
|
|
85
|
+
├── src/
|
|
86
|
+
│ ├── index.ts ← Library entry point registering extensions
|
|
87
|
+
│ ├── tokens/ ← Centralized design tokens subsystem
|
|
88
|
+
│ │ ├── ui.ts ← Semantic color tokens with safe fallbacks
|
|
89
|
+
│ │ ├── typography.ts ← Font families, scales, and line heights
|
|
90
|
+
│ │ └── index.ts ← Barrel export + color-mix utilities
|
|
91
|
+
│ ├── hooks/
|
|
92
|
+
│ │ ├── useIsDarkTheme.ts ← Reactive light/dark theme tracking
|
|
93
|
+
│ │ └── index.ts
|
|
94
|
+
│ ├── components/
|
|
95
|
+
│ │ └── CustomWidget/ ← Decomposed component template
|
|
96
|
+
│ │ ├── CustomWidget.tsx
|
|
97
|
+
│ │ ├── CustomWidgetModel.ts
|
|
98
|
+
│ │ ├── index.ts
|
|
99
|
+
│ │ └── components/ ← Presentational subcomponents & ErrorBoundary
|
|
100
|
+
│ └── utils/
|
|
101
|
+
│ ├── themeDetection.ts ← Standalone luminance-based theme detector
|
|
102
|
+
│ └── index.ts
|
|
103
|
+
├── AGENTS.md ← AI assistant development directives
|
|
104
|
+
├── start.sh / start.bat ← Port killer + SSL check + dev server runner
|
|
105
|
+
├── build.sh / build.bat ← Production compilation script
|
|
106
|
+
├── package.json ← Includes @mui/material, @emotion/react, and @emotion/styled
|
|
107
|
+
└── webpack.config.js
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Available Scripts (in Scaffolded Project)
|
|
113
|
+
|
|
114
|
+
- **`./start.sh` (or `start.bat`)**: Kills stale port 3000 processes, generates SSL certificates if missing, and runs `npm start`.
|
|
115
|
+
- **`npm start`**: Runs the project in development mode with hot reloading.
|
|
116
|
+
- **`npm run build`** (or `./build.sh`): Generates an optimized production bundle in `dist/`.
|
|
117
|
+
- **`npm run cert:gen`**: Regenerates development SSL certificates in `certs/`.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Developer Guide: Building & Deploying Web Extensions
|
|
122
|
+
|
|
123
|
+
> Official Reference: [VertiGIS Studio Web SDK Overview](https://developers.vertigisstudio.com/docs/web/overview/) & [Workflow TypeScript SDK Overview](https://developers.vertigisstudio.com/docs/workflow/sdk-web-overview)
|
|
124
|
+
|
|
125
|
+
### 1. Extension Architecture & Decomposition
|
|
126
|
+
The Web SDK compiles custom UI widgets, services, and commands into a loadable VertiGIS Studio Web library:
|
|
127
|
+
- **MobX Component Models (`*Model.ts`)**: Encapsulate application state, services injection, and event management.
|
|
128
|
+
- **React Views (`*.tsx`)**: Presentational UI wrapping controls with accessibility attributes, design tokens (`src/tokens/`), and dynamic theme adaptation (`useIsDarkTheme`).
|
|
129
|
+
- **Error Boundaries**: Isolate widget failures to avoid crashing the surrounding VertiGIS Studio Web shell.
|
|
130
|
+
- **Custom Services & Commands**: Register app-wide singleton services and commands via `@vertigis/web/messaging`.
|
|
131
|
+
|
|
132
|
+
### 2. Simultaneous Dual-Port Development Server
|
|
133
|
+
Start the development server with automatic SAN SSL certificate validation:
|
|
134
|
+
```bash
|
|
135
|
+
./start.sh # Linux / macOS
|
|
136
|
+
start.bat # Windows
|
|
137
|
+
# or: npm start
|
|
138
|
+
```
|
|
139
|
+
- **Dual-Port Accessibility**:
|
|
140
|
+
- Primary endpoint: `https://localtest.me:3001/main.js` (avoids ArcGIS Portal private network & CORS restrictions).
|
|
141
|
+
- Auxiliary bridge: `https://localhost:3000/main.js` (guarantees legacy app configuration compatibility).
|
|
142
|
+
- Pre-configured with CORS and Private Network Access (`Access-Control-Allow-Private-Network: true`) headers.
|
|
143
|
+
|
|
144
|
+
### 3. Registering Custom Web Extensions in VertiGIS Studio Web
|
|
145
|
+
To consume your custom extensions inside VertiGIS Studio Web applications:
|
|
146
|
+
1. Open your target application in **VertiGIS Studio Web Designer**.
|
|
147
|
+
2. Navigate to **App Settings** > **Custom Libraries**.
|
|
148
|
+
3. Add your development URL:
|
|
149
|
+
- `https://localtest.me:3001/main.js` (or `https://localhost:3000/main.js`)
|
|
150
|
+
4. Add the component to your application layout XML (`layout.xml`) or configuration (`app.json`).
|
|
151
|
+
5. Reload the Designer app to view live hot-reloaded changes.
|
|
152
|
+
|
|
153
|
+
### 4. Production Build & Hosting
|
|
154
|
+
Compile production artifacts:
|
|
155
|
+
```bash
|
|
156
|
+
./build.sh # Linux / macOS
|
|
157
|
+
build.bat # Windows
|
|
158
|
+
# or: npm run build
|
|
159
|
+
```
|
|
160
|
+
Outputs optimized bundles to `build/`:
|
|
161
|
+
- `build/main.js` & `build/<project-name>.js`: Minified production bundle
|
|
162
|
+
- `build/<project-name>.js.txt`: Script text artifact for hosting in strict web environments requiring `.txt` extensions
|
|
163
|
+
|
|
164
|
+
**Hosting Requirements**:
|
|
165
|
+
- Host over **HTTPS** with a valid SSL certificate.
|
|
166
|
+
- Configure web server headers for Cross-Origin Resource Sharing (`Access-Control-Allow-Origin: *`).
|
|
167
|
+
- Update your VertiGIS Web Designer custom library URL to point to your production URL `https://your-server.com/path/<project-name>.js`.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Upstream Synchronization
|
|
172
|
+
|
|
173
|
+
This fork tracks official updates from `https://github.com/vertigis/vertigis-web-sdk.git`. Because enterprise templates are maintained in the isolated `template-custom/` overlay directory, upstream merges execute cleanly without merge conflicts:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
git fetch upstream
|
|
177
|
+
git merge upstream/master --no-edit
|
|
178
|
+
git push origin master
|
|
179
|
+
```
|
|
180
|
+
Or run the parent batch synchronizer:
|
|
181
|
+
```bash
|
|
182
|
+
./sync.sh
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Documentation
|
|
188
|
+
|
|
189
|
+
- [VertiGIS Studio Web Developer Center](https://developers.vertigisstudio.com/docs/web/overview/)
|
|
190
|
+
- [VertiGIS Studio Workflow TypeScript SDK Overview](https://developers.vertigisstudio.com/docs/workflow/sdk-web-overview)
|
|
191
|
+
- [VertiGIS Web SDK Skill Reference Guide](https://github.com/davekazemi/vertigis-sdk-skills)
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## About Geosynk
|
|
196
|
+
|
|
197
|
+
[Geosynk](https://geosynk.com.au/) is an Australian geospatial engineering and software consultancy founded by Davood Kazemi, delivering enterprise GIS architecture, custom VertiGIS solutions, and modern web applications.
|
|
198
|
+
|
|
199
|
+
### Core Capabilities & Topics
|
|
200
|
+
|
|
201
|
+
- **VertiGIS Studio Engineering**: Turnkey Web SDK components, custom Workflow activities, accessible form elements, report templates, and automated printing services.
|
|
202
|
+
- **Esri ArcGIS Enterprise**: End-to-end cloud and on-premises architecture, Enterprise Geodatabase design, Utility Network migrations, and ArcGIS Experience Builder extensions.
|
|
203
|
+
- **Full-Stack Spatial Systems**: High-performance React, TypeScript, Node.js, WebGL, and Leaflet/Mapbox interactive web applications.
|
|
204
|
+
- **Spatial DevOps & Automation**: Automated CI/CD pipelines, automated testing, containerized GIS deployments, and infrastructure as code across AWS and Microsoft Azure.
|
|
205
|
+
|
|
206
|
+
### Connect with Geosynk
|
|
207
|
+
- **Website**: [https://geosynk.com.au](https://geosynk.com.au/)
|
|
208
|
+
- **Contact**: [Davood Kazemi](mailto:dave.kazemi@gmail.com)
|
|
209
|
+
|
|
210
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-check
|
|
3
|
+
// Necessary to turn this into a module, which allows top-level await.
|
|
4
|
+
export {};
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
|
|
8
|
+
const scriptIndex = args.findIndex(
|
|
9
|
+
x => x === "build" || x === "create" || x === "start" || x === "upgrade"
|
|
10
|
+
);
|
|
11
|
+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
|
12
|
+
|
|
13
|
+
if (["build", "create", "start", "upgrade"].includes(script)) {
|
|
14
|
+
await import(`../scripts/${script}.js`);
|
|
15
|
+
} else {
|
|
16
|
+
console.error(`Unknown script '${script}'.`);
|
|
17
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import baseConfig from "@vertigis/sdk-library/config/eslint.base.config.js";
|
|
2
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Adds rules specific to the Web SDK.
|
|
6
|
+
*/
|
|
7
|
+
export default defineConfig([
|
|
8
|
+
globalIgnores(["**/*.cjs"]),
|
|
9
|
+
baseConfig,
|
|
10
|
+
{
|
|
11
|
+
name: "vertigis/web-sdk/recommended",
|
|
12
|
+
rules: {
|
|
13
|
+
"@typescript-eslint/array-type": "warn",
|
|
14
|
+
"@typescript-eslint/consistent-type-definitions": ["warn", "interface"],
|
|
15
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
16
|
+
"warn",
|
|
17
|
+
{ disallowTypeAnnotations: false },
|
|
18
|
+
],
|
|
19
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
20
|
+
"@typescript-eslint/member-ordering": [
|
|
21
|
+
"warn",
|
|
22
|
+
{
|
|
23
|
+
default: [
|
|
24
|
+
// Index signature
|
|
25
|
+
"signature",
|
|
26
|
+
// Fields
|
|
27
|
+
"public-static-field",
|
|
28
|
+
"protected-static-field",
|
|
29
|
+
"private-static-field",
|
|
30
|
+
"public-field",
|
|
31
|
+
"protected-field",
|
|
32
|
+
"private-field",
|
|
33
|
+
// Constructors
|
|
34
|
+
"public-constructor",
|
|
35
|
+
"protected-constructor",
|
|
36
|
+
"private-constructor",
|
|
37
|
+
// Methods
|
|
38
|
+
"public-static-method",
|
|
39
|
+
"protected-static-method",
|
|
40
|
+
"private-static-method",
|
|
41
|
+
"public-method",
|
|
42
|
+
"protected-method",
|
|
43
|
+
"private-method",
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
"@typescript-eslint/no-dupe-class-members": "warn",
|
|
48
|
+
"@typescript-eslint/no-duplicate-type-constituents": "off",
|
|
49
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
50
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
51
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
52
|
+
"@typescript-eslint/no-invalid-this": "warn",
|
|
53
|
+
"@typescript-eslint/no-misused-promises": [
|
|
54
|
+
"warn",
|
|
55
|
+
{
|
|
56
|
+
checksVoidReturn: false,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
60
|
+
"@typescript-eslint/no-unnecessary-condition": "off",
|
|
61
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
62
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
63
|
+
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
64
|
+
"@typescript-eslint/no-unsafe-function-type": "warn",
|
|
65
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
66
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
67
|
+
"@typescript-eslint/no-unused-vars": [
|
|
68
|
+
"warn",
|
|
69
|
+
{
|
|
70
|
+
args: "none",
|
|
71
|
+
ignoreRestSiblings: true,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
"@typescript-eslint/no-useless-constructor": "warn",
|
|
75
|
+
"@typescript-eslint/no-wrapper-object-types": "warn",
|
|
76
|
+
"@typescript-eslint/prefer-for-of": "warn",
|
|
77
|
+
"@typescript-eslint/prefer-function-type": "warn",
|
|
78
|
+
"@typescript-eslint/prefer-includes": "warn",
|
|
79
|
+
"@typescript-eslint/prefer-optional-chain": "warn",
|
|
80
|
+
"@typescript-eslint/prefer-readonly": "warn",
|
|
81
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "warn",
|
|
82
|
+
"@typescript-eslint/prefer-regexp-exec": "off",
|
|
83
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
|
|
84
|
+
"@typescript-eslint/no-floating-promises": "warn",
|
|
85
|
+
"@typescript-eslint/promise-function-async": "off",
|
|
86
|
+
"@typescript-eslint/restrict-template-expressions": "off",
|
|
87
|
+
"@typescript-eslint/require-await": "off",
|
|
88
|
+
"@typescript-eslint/switch-exhaustiveness-check": "warn",
|
|
89
|
+
"accessor-pairs": "warn",
|
|
90
|
+
"array-callback-return": "warn",
|
|
91
|
+
"arrow-body-style": "warn",
|
|
92
|
+
complexity: "off",
|
|
93
|
+
"default-case-last": "warn",
|
|
94
|
+
"default-param-last": "warn",
|
|
95
|
+
eqeqeq: [
|
|
96
|
+
"warn",
|
|
97
|
+
"always",
|
|
98
|
+
{
|
|
99
|
+
null: "ignore",
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
"grouped-accessor-pairs": ["warn", "getBeforeSet"],
|
|
103
|
+
"import/default": "off",
|
|
104
|
+
"import/export": "off",
|
|
105
|
+
"import/namespace": "off",
|
|
106
|
+
"import/no-amd": "off",
|
|
107
|
+
"import/no-commonjs": "off",
|
|
108
|
+
"import/no-duplicates": "warn",
|
|
109
|
+
"import/no-named-as-default": "off",
|
|
110
|
+
"import/no-named-as-default-member": "off",
|
|
111
|
+
"import/no-namespace": "off",
|
|
112
|
+
"import/no-unresolved": "off",
|
|
113
|
+
"import/order": [
|
|
114
|
+
"warn",
|
|
115
|
+
{
|
|
116
|
+
alphabetize: {
|
|
117
|
+
order: "asc",
|
|
118
|
+
},
|
|
119
|
+
"newlines-between": "always",
|
|
120
|
+
groups: ["builtin", "external", ["parent", "sibling", "index"]],
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
"max-depth": ["warn", 4],
|
|
124
|
+
"max-params": ["warn", 4],
|
|
125
|
+
"no-alert": "warn",
|
|
126
|
+
"no-await-in-loop": "warn",
|
|
127
|
+
"no-caller": "warn",
|
|
128
|
+
"no-constant-condition": [
|
|
129
|
+
"warn",
|
|
130
|
+
{
|
|
131
|
+
checkLoops: false,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
"no-constructor-return": "warn",
|
|
135
|
+
"no-duplicate-imports": "off",
|
|
136
|
+
"no-eval": "warn",
|
|
137
|
+
"no-extend-native": "warn",
|
|
138
|
+
"no-extra-bind": "warn",
|
|
139
|
+
"no-implied-eval": "warn",
|
|
140
|
+
"no-labels": "warn",
|
|
141
|
+
"no-lonely-if": "warn",
|
|
142
|
+
"no-nested-ternary": "off",
|
|
143
|
+
"no-new-object": "warn",
|
|
144
|
+
"no-new-wrappers": "warn",
|
|
145
|
+
"no-param-reassign": "warn",
|
|
146
|
+
"no-promise-executor-return": "warn",
|
|
147
|
+
"no-proto": "warn",
|
|
148
|
+
"no-prototype-builtins": "off",
|
|
149
|
+
"no-restricted-imports": [
|
|
150
|
+
"warn",
|
|
151
|
+
{
|
|
152
|
+
patterns: [
|
|
153
|
+
{
|
|
154
|
+
group: ["@mui/material/*", "@vertigis/react-ui/*"],
|
|
155
|
+
message:
|
|
156
|
+
"React UI components should always be imported from '@vertigis/web/ui' when used in a Web library.",
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
"no-return-assign": "warn",
|
|
162
|
+
"no-return-await": "off",
|
|
163
|
+
"no-self-compare": "warn",
|
|
164
|
+
"no-sequences": "warn",
|
|
165
|
+
"no-template-curly-in-string": "warn",
|
|
166
|
+
"no-unmodified-loop-condition": "warn",
|
|
167
|
+
"no-unneeded-ternary": "warn",
|
|
168
|
+
"no-unused-vars": "off",
|
|
169
|
+
"no-useless-call": "warn",
|
|
170
|
+
"no-useless-computed-key": "warn",
|
|
171
|
+
"no-useless-concat": "warn",
|
|
172
|
+
"no-useless-rename": "warn",
|
|
173
|
+
"no-useless-return": "warn",
|
|
174
|
+
"no-var": "warn",
|
|
175
|
+
"no-void": "warn",
|
|
176
|
+
"object-shorthand": "warn",
|
|
177
|
+
"prefer-arrow-callback": "warn",
|
|
178
|
+
"prefer-const": "warn",
|
|
179
|
+
"prefer-object-spread": "warn",
|
|
180
|
+
"prefer-regex-literals": "warn",
|
|
181
|
+
"prefer-rest-params": "warn",
|
|
182
|
+
"prefer-spread": "warn",
|
|
183
|
+
"prefer-template": "warn",
|
|
184
|
+
"react/display-name": "off",
|
|
185
|
+
"react/no-array-index-key": "off",
|
|
186
|
+
"react/no-find-dom-node": "off",
|
|
187
|
+
"react/no-children-prop": "off",
|
|
188
|
+
"react/no-mutation-state": "off",
|
|
189
|
+
"react/require-render-return": "off",
|
|
190
|
+
"react-hooks/rules-of-hooks": "error",
|
|
191
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
192
|
+
"react/jsx-boolean-value": "warn",
|
|
193
|
+
"react/jsx-key": ["warn", { checkFragmentShorthand: true }],
|
|
194
|
+
"react/no-deprecated": "warn",
|
|
195
|
+
"react/react-in-jsx-scope": "off",
|
|
196
|
+
"react/prop-types": "off",
|
|
197
|
+
"require-await": "off",
|
|
198
|
+
"spaced-comment": "warn",
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
2
|
+
import baseConfig from "@vertigis/web-sdk/config/eslint.config.js";
|
|
3
|
+
|
|
4
|
+
export default defineConfig([
|
|
5
|
+
globalIgnores(["**/*.js", "**/*.d.ts"]),
|
|
6
|
+
baseConfig,
|
|
7
|
+
{
|
|
8
|
+
// Add your custom rules or other eslint config overrides here.
|
|
9
|
+
rules: {}
|
|
10
|
+
}
|
|
11
|
+
]);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
|
|
3
|
+
import paths from "@vertigis/sdk-library/config/paths.js";
|
|
4
|
+
import baseConfig from "@vertigis/sdk-library/config/webpack.base.config.js";
|
|
5
|
+
import HtmlWebPackPlugin from "html-webpack-plugin";
|
|
6
|
+
import { merge } from "webpack-merge";
|
|
7
|
+
|
|
8
|
+
const isEnvDevelopment = process.env.NODE_ENV === "development";
|
|
9
|
+
const isEnvProduction = process.env.NODE_ENV === "production";
|
|
10
|
+
|
|
11
|
+
export { merge };
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Add customizations for Web SDK libraries to the base config.
|
|
15
|
+
*/
|
|
16
|
+
export default merge(baseConfig, {
|
|
17
|
+
resolve: {
|
|
18
|
+
alias: {
|
|
19
|
+
esri: "@arcgis/core",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
externals: [
|
|
23
|
+
/^@arcgis\/core\/.+$/,
|
|
24
|
+
/^esri\/.+$/,
|
|
25
|
+
/^@vertigis\/arcgis-extensions\/.+$/,
|
|
26
|
+
/^@vertigis\/viewer-spec\/.+$/,
|
|
27
|
+
/^@vertigis\/web\/.+$/,
|
|
28
|
+
/^@vertigis\/workflow\/.+$/,
|
|
29
|
+
/^react(\/.+)*$/,
|
|
30
|
+
/^react-dom(\/.+)*$/,
|
|
31
|
+
],
|
|
32
|
+
output: {
|
|
33
|
+
// Use "/" in dev so hot updates are requested from server root instead
|
|
34
|
+
// of from "viewer" relative path.
|
|
35
|
+
publicPath: isEnvProduction ? "." : "/",
|
|
36
|
+
},
|
|
37
|
+
plugins: [
|
|
38
|
+
// Generates an `index.html` file with the <script> injected.
|
|
39
|
+
isEnvDevelopment &&
|
|
40
|
+
new HtmlWebPackPlugin({
|
|
41
|
+
inject: false,
|
|
42
|
+
template: path.resolve(paths.ownPath, "./lib/web/index.ejs"),
|
|
43
|
+
additionalLibs: process.env.ADDITIONAL_LIBS,
|
|
44
|
+
}),
|
|
45
|
+
].filter(Boolean),
|
|
46
|
+
resolveLoader: {
|
|
47
|
+
modules: [
|
|
48
|
+
"node_modules/@vertigis/web-sdk/node_modules/@vertigis/sdk-library/node_modules/",
|
|
49
|
+
"node_modules/@vertigis/web-sdk/node_modules",
|
|
50
|
+
"node_modules/@vertigis/sdk-library/node_modules",
|
|
51
|
+
"node_modules",
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
});
|
package/lib/index.ejs
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
|
7
|
+
<title>VertiGIS Studio Web SDK Preview</title>
|
|
8
|
+
<style>
|
|
9
|
+
body,
|
|
10
|
+
html {
|
|
11
|
+
height: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
body {
|
|
15
|
+
padding: 0;
|
|
16
|
+
margin: 0;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
iframe {
|
|
21
|
+
display: block;
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
border: none;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
</head>
|
|
28
|
+
<body>
|
|
29
|
+
<script>
|
|
30
|
+
function iframeLoaded(event) {
|
|
31
|
+
const webpackFiles = <%= JSON.stringify(htmlWebpackPlugin.files) %>;
|
|
32
|
+
const additionalLibs = <%= (htmlWebpackPlugin.options.additionalLibs ?? "[]") %>;
|
|
33
|
+
const iframeDocument = event.target.contentDocument;
|
|
34
|
+
const iframeWindow = event.target.contentWindow;
|
|
35
|
+
|
|
36
|
+
if (!iframeWindow.require) {
|
|
37
|
+
console.error("VertiGIS Studio Web frame failed to load");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Proxy postMessage events when the SDK preview is embedded in another page.
|
|
42
|
+
// This is for development purposes only. Using "*" is NOT recommended for production
|
|
43
|
+
// for security reasons.
|
|
44
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage.
|
|
45
|
+
if (window.parent) {
|
|
46
|
+
const handlePostMessage = (event) => {
|
|
47
|
+
// Event came from parent. Forward to viewer frame.
|
|
48
|
+
if (event.source === window.parent) {
|
|
49
|
+
iframeWindow.postMessage(event.data, "*");
|
|
50
|
+
}
|
|
51
|
+
// Event came from viewer. Forward to parent.
|
|
52
|
+
else if (event.source === iframeWindow) {
|
|
53
|
+
window.parent.postMessage(event.data, "*")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
window.addEventListener("message", handlePostMessage);
|
|
58
|
+
|
|
59
|
+
// If we don't remove the event listener, we can end up with multiple
|
|
60
|
+
// listeners attached when the iframe is reloaded, such as when
|
|
61
|
+
// triggered via webpack hot module reload.
|
|
62
|
+
iframeWindow.addEventListener("unload", () => {
|
|
63
|
+
window.removeEventListener("message", handlePostMessage)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
iframeWindow.require(["require", "web"], function(require, webViewer) {
|
|
68
|
+
function getAbsoluteUrl(relativePath) {
|
|
69
|
+
const a = document.createElement("a");
|
|
70
|
+
a.href = relativePath;
|
|
71
|
+
return a.href;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Fetch the application config
|
|
75
|
+
async function getAppConfig() {
|
|
76
|
+
return (await fetch(getAbsoluteUrl("app.json"))).json();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Load common web libs as well as our custom bundle
|
|
80
|
+
require([
|
|
81
|
+
"@vertigis/web-libraries!/common",
|
|
82
|
+
"@vertigis/web-libraries!/web",
|
|
83
|
+
webpackFiles.js[0],
|
|
84
|
+
...additionalLibs
|
|
85
|
+
], (
|
|
86
|
+
...libs
|
|
87
|
+
) => {
|
|
88
|
+
getAppConfig().then((appConfig) => {
|
|
89
|
+
webViewer.bootstrap({
|
|
90
|
+
appConfig,
|
|
91
|
+
layout: getAbsoluteUrl("layout.xml"),
|
|
92
|
+
libraries: libs.map(lib => lib.default),
|
|
93
|
+
});
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function injectIframe() {
|
|
100
|
+
const iframe = document.createElement("iframe");
|
|
101
|
+
iframe.name = "viewer";
|
|
102
|
+
|
|
103
|
+
const selfUrl = new URL(location);
|
|
104
|
+
const iframeSrc = new URL("/viewer/index.html?debug=true#no-bootstrap", selfUrl.origin);
|
|
105
|
+
// Forward all query params to viewer
|
|
106
|
+
for (const [key, value] of selfUrl.searchParams) {
|
|
107
|
+
iframeSrc.searchParams.set(key, value);
|
|
108
|
+
}
|
|
109
|
+
iframe.src = iframeSrc;
|
|
110
|
+
|
|
111
|
+
iframe.addEventListener("load", iframeLoaded);
|
|
112
|
+
document.body.appendChild(iframe);
|
|
113
|
+
|
|
114
|
+
iframe.contentWindow.addEventListener("DOMContentLoaded", () => {
|
|
115
|
+
// Hook in React Dev Tools support
|
|
116
|
+
iframe.contentWindow.__REACT_DEVTOOLS_GLOBAL_HOOK__ =
|
|
117
|
+
window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Instead of letting the frame reload via HMR, remove and
|
|
121
|
+
// inject a new iframe. This allows us to once again inject the
|
|
122
|
+
// react devtools hook so the devtools continue to work after
|
|
123
|
+
// reloading the frame.
|
|
124
|
+
iframe.contentWindow.addEventListener("beforeunload", () => {
|
|
125
|
+
document.body.removeChild(iframe);
|
|
126
|
+
injectIframe();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
injectIframe();
|
|
131
|
+
</script>
|
|
132
|
+
</body>
|
|
133
|
+
</html>
|