@geosynk/vertigis-web-sdk 1.0.11 → 1.1.1
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/README.md +72 -9
- package/package.json +6 -6
- package/scripts/create.js +12 -2
- package/template/package.json +1 -1
- package/template-custom/AGENTS.md +86 -33
- package/template-custom/Dockerfile.build +46 -0
- package/template-custom/build.bat +84 -5
- package/template-custom/build.sh +82 -2
- package/template-custom/certs/generate-cert.bat +10 -9
- package/template-custom/certs/generate-cert.sh +1 -0
- package/template-custom/project.config +107 -0
- package/template-custom/scripts/configure-portal.js +56 -7
- package/template-custom/scripts/load-config.bat +12 -0
- package/template-custom/scripts/load-config.sh +26 -0
- package/template-custom/scripts/remote-sync.bat +12 -0
- package/template-custom/scripts/remote-sync.sh +42 -0
- package/template-custom/scripts/verify_zero_cosmetic_sx.py +419 -0
- package/template-custom/src/auth/index.ts +18 -1
- package/template-custom/src/components/CustomWidget/CustomWidget.css +1 -0
- package/template-custom/src/components/CustomWidget/CustomWidget.tsx +28 -49
- package/template-custom/src/components/CustomWidget/components/CustomWidgetErrorBoundary.css +0 -0
- package/template-custom/src/components/CustomWidget/components/CustomWidgetErrorBoundary.tsx +12 -19
- package/template-custom/src/index.ts +4 -1
- package/template-custom/src/tokens/VertiGisThemeProvider.tsx +14 -0
- package/template-custom/src/tokens/index.ts +3 -0
- package/template-custom/src/tokens/muiTheme.ts +61 -0
- package/template-custom/src/tokens/spacing.ts +24 -0
- package/template-custom/src/tokens/typography.ts +0 -4
- package/template-custom/src/tokens/ui.ts +58 -3
- package/template-custom/start.bat +24 -1
- package/template-custom/start.sh +35 -0
- package/template-custom/webpack.config.js +47 -161
package/README.md
CHANGED
|
@@ -46,8 +46,9 @@ Every project scaffolded from this repository includes:
|
|
|
46
46
|
- Automatically executed on project creation or during first startup.
|
|
47
47
|
|
|
48
48
|
5. **Cross-Platform Startup & Build Scripts**:
|
|
49
|
-
- `start.sh` / `start.bat`: Checks and kills stale
|
|
50
|
-
- `build.sh` / `build.bat`: Compiles and validates production bundles into `
|
|
49
|
+
- `start.sh` / `start.bat`: Checks and kills stale processes on ports 3001 and 3000, verifies SSL certificates, and launches the development server. `remote` mode keeps the checkout in sync with `origin/<branch>` while the server runs.
|
|
50
|
+
- `build.sh` / `build.bat`: Compiles and validates production bundles into `build/`. `upload-gc [public-url]` also uploads the bundle to Google Cloud Storage.
|
|
51
|
+
- `project.config`: One commented file for all script values (build name, upload URL, remote sync, portal authentication). See [Project Configuration](#project-configuration-projectconfig).
|
|
51
52
|
|
|
52
53
|
6. **Coding Assistant Governance (`AGENTS.md`)**:
|
|
53
54
|
- 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.
|
|
@@ -124,15 +125,22 @@ my-web-library/
|
|
|
124
125
|
│ ├── components/
|
|
125
126
|
│ │ └── CustomWidget/ ← Decomposed component template
|
|
126
127
|
│ │ ├── CustomWidget.tsx
|
|
128
|
+
│ │ ├── CustomWidget.css ← Co-located styles (validator rule COMPONENT_CSS_PAIR)
|
|
127
129
|
│ │ ├── CustomWidgetModel.ts
|
|
128
130
|
│ │ ├── index.ts
|
|
129
131
|
│ │ └── components/ ← Presentational subcomponents & ErrorBoundary
|
|
130
132
|
│ └── utils/
|
|
131
133
|
│ ├── themeDetection.ts ← Standalone luminance-based theme detector
|
|
132
134
|
│ └── index.ts
|
|
135
|
+
├── scripts/
|
|
136
|
+
│ ├── load-config.sh / .bat ← Reads project.config for the .sh and .bat scripts
|
|
137
|
+
│ ├── remote-sync.sh / .bat ← Fast-forward sync with origin (start.sh remote)
|
|
138
|
+
│ ├── configure-portal.js ← Portal OAuth configurator (npm run auth:portal)
|
|
139
|
+
│ └── verify_zero_cosmetic_sx.py ← Style audit (npm run verify:styles)
|
|
133
140
|
├── AGENTS.md ← AI assistant development directives
|
|
134
|
-
├──
|
|
135
|
-
├──
|
|
141
|
+
├── project.config ← Values for the scripts (build, upload, remote sync, portal auth)
|
|
142
|
+
├── start.sh / start.bat ← Port killer + SSL check + dev server runner (+ remote mode)
|
|
143
|
+
├── build.sh / build.bat ← Production compilation script (+ upload-gc)
|
|
136
144
|
├── package.json ← Includes @mui/material, @emotion/react, and @emotion/styled
|
|
137
145
|
└── webpack.config.js
|
|
138
146
|
```
|
|
@@ -141,14 +149,54 @@ my-web-library/
|
|
|
141
149
|
|
|
142
150
|
## Available Scripts (in Scaffolded Project)
|
|
143
151
|
|
|
144
|
-
- **`./start.sh` (or `start.bat`)**: Kills stale
|
|
152
|
+
- **`./start.sh` (or `start.bat`)**: Kills stale processes on ports 3001 and 3000, generates SSL certificates if missing, and runs `npm start`.
|
|
153
|
+
- **`./start.sh remote [branch] [seconds]`** (or `start.bat remote [branch]`, or `npm run start:remote`): Pulls `origin/<branch>` first, then fetches it again each 5 seconds (default, `REMOTE_INTERVAL`) while the dev server runs. Fast-forward only: local commits and uncommitted changes are never overwritten. When `package.json` or a lockfile changes, it tells you to run `npm install`.
|
|
145
154
|
- **`npm start`**: Runs the project in development mode with hot reloading.
|
|
146
|
-
- **`npm run auth:portal`**: Interactive wizard to configure ArcGIS Enterprise Portal / AGOL OAuth authentication and secured web maps.
|
|
147
|
-
- **`npm run build`** (or `./build.sh`): Generates an optimized production bundle in `
|
|
155
|
+
- **`npm run auth:portal`**: Interactive wizard to configure ArcGIS Enterprise Portal / AGOL OAuth authentication and secured web maps. If `PORTAL_URL` and `PORTAL_CLIENT_ID` are set in `project.config`, it runs without questions.
|
|
156
|
+
- **`npm run build`** (or `./build.sh [name]`): Generates an optimized production bundle in `build/`.
|
|
157
|
+
- **`./build.sh upload-gc [public-url] [name]`** (or `build.bat upload-gc [public-url] [name]`): Builds, then uploads `build/<name>.js` to Google Cloud Storage with `gcloud`. If you do not give the URL, the script uses `GC_UPLOAD_URL` from `project.config`. The URL is `https://storage.googleapis.com/<bucket>/<path>` or `gs://<bucket>/<path>`. If it ends with `.js`, it is the file name. Otherwise it is a folder. The bucket must already allow public read.
|
|
148
158
|
- **`npm run cert:gen`**: Regenerates development SSL certificates in `certs/`.
|
|
149
159
|
|
|
150
160
|
---
|
|
151
161
|
|
|
162
|
+
## Project Configuration (`project.config`)
|
|
163
|
+
|
|
164
|
+
Each scaffolded project has a `project.config` file in its root. It contains all the values that the scripts use, with a comment for each value. Change the values in this file, so that you do not have to type them on the command line each time.
|
|
165
|
+
|
|
166
|
+
| Key | Used by | Description | Default |
|
|
167
|
+
| :--- | :--- | :--- | :--- |
|
|
168
|
+
| `BUILD_NAME` | `build.sh` / `build.bat` | Name of the built library: `build/<BUILD_NAME>.js` and `.js.txt` | Project folder name |
|
|
169
|
+
| `GC_UPLOAD_URL` | `build.sh upload-gc` | Upload target: `https://storage.googleapis.com/<bucket>/<path>` or `gs://<bucket>/<path>`. A value that ends with `.js` is the file name. Other values are a folder. | Not set |
|
|
170
|
+
| `GC_CACHE_CONTROL` | `build.sh upload-gc` | `Cache-Control` header of the uploaded file | `no-cache` |
|
|
171
|
+
| `REMOTE_SYNC` | `start.sh` / `start.bat` | `true` = use remote mode also without the `remote` argument | `false` |
|
|
172
|
+
| `REMOTE_BRANCH` | `start.sh remote` | Branch to sync with | Current branch |
|
|
173
|
+
| `REMOTE_INTERVAL` | `start.sh remote` | Seconds between two fetches | `5` |
|
|
174
|
+
| `PORTAL_URL` | `npm run auth:portal` | ArcGIS Enterprise portal or ArcGIS Online URL | Not set |
|
|
175
|
+
| `PORTAL_CLIENT_ID` | `npm run auth:portal` | OAuth application Client ID | Not set |
|
|
176
|
+
| `PORTAL_ACCOUNT_ID` | `npm run auth:portal` | Account ID (organization identifier) | `enterprise` |
|
|
177
|
+
| `PORTAL_WEBMAP` | `npm run auth:portal` | Web map item ID or URL to set in `app/app.json` | Not set (no change) |
|
|
178
|
+
| `PORTAL_PREVIEW_ORIGINS` | `npm run auth:portal` | More preview origins to register in the portal, separated by commas | `https://preview.kw11.org` |
|
|
179
|
+
|
|
180
|
+
Rules:
|
|
181
|
+
- One `KEY=VALUE` on each line. Do not put spaces around `=`, quotes around a value, or a comment after a value. Do not use `!` in a value (Windows `.bat` scripts remove it).
|
|
182
|
+
- Lines that start with `#` are comments. An empty value (`KEY=`) means "not set", so the script uses its default.
|
|
183
|
+
- Priority: a command-line argument, then `project.config`, then the default in the script.
|
|
184
|
+
- The scripts only read `KEY=VALUE` lines. They do not run the file as code.
|
|
185
|
+
- The file is committed to git and shared with your team. Do not put passwords or tokens in it.
|
|
186
|
+
|
|
187
|
+
Example:
|
|
188
|
+
```ini
|
|
189
|
+
BUILD_NAME=my-library
|
|
190
|
+
GC_UPLOAD_URL=https://storage.googleapis.com/my-bucket/libs/
|
|
191
|
+
REMOTE_SYNC=true
|
|
192
|
+
REMOTE_BRANCH=main
|
|
193
|
+
PORTAL_URL=https://gis.example.com/portal
|
|
194
|
+
PORTAL_CLIENT_ID=myClientId123
|
|
195
|
+
```
|
|
196
|
+
With these values, `./build.sh upload-gc` builds and uploads `my-library.js`, `./start.sh` starts in remote mode on `main`, and `npm run auth:portal` configures the portal without questions.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
152
200
|
## Developer Guide: Building & Deploying Web Extensions
|
|
153
201
|
|
|
154
202
|
> 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)
|
|
@@ -193,6 +241,18 @@ Outputs optimized bundles to `build/`:
|
|
|
193
241
|
- `build/<project-name>.js` (named bundle for ArcGIS portal hosting)
|
|
194
242
|
- `build/<project-name>.js.txt` (raw text bundle for script upload workflows)
|
|
195
243
|
|
|
244
|
+
`build.sh`, `build.bat`, and `Dockerfile.build` stop with an error if `build/main.js` contains `localtest.me` or `oauth_callback`. These strings show that the dev OAuth code (`src/auth`) is in the production bundle.
|
|
245
|
+
|
|
246
|
+
Build and upload to a public Google Cloud Storage bucket (needs the [Google Cloud CLI](https://cloud.google.com/sdk/docs/install) and `gcloud auth login`):
|
|
247
|
+
```bash
|
|
248
|
+
./build.sh upload-gc https://storage.googleapis.com/my-bucket/libs/
|
|
249
|
+
# Uploads build/<project-name>.js to gs://my-bucket/libs/<project-name>.js with Cache-Control: no-cache,
|
|
250
|
+
# then prints the public URL to add in Designer > App Settings > Custom Libraries.
|
|
251
|
+
|
|
252
|
+
# Or set GC_UPLOAD_URL=https://storage.googleapis.com/my-bucket/libs/ in project.config, then:
|
|
253
|
+
./build.sh upload-gc
|
|
254
|
+
```
|
|
255
|
+
|
|
196
256
|
---
|
|
197
257
|
|
|
198
258
|
### 5. ArcGIS Enterprise & Secured Portal Authentication
|
|
@@ -225,7 +285,9 @@ If your ArcGIS Enterprise Portal restricts cross-domain requests, you must white
|
|
|
225
285
|
> **Note**: ArcGIS Enterprise requires a fully qualified domain name (FQDN) containing a domain suffix (e.g., `localtest.me:3001`). Bare hostnames like `localhost` and wildcard `*` machine names are rejected by Portal security. In production, VertiGIS Studio Web is deployed directly within your GIS environment, so only the development origin needs whitelisting.
|
|
226
286
|
|
|
227
287
|
#### Step 2: Run the Automated Portal Configurator
|
|
228
|
-
|
|
288
|
+
Option 1: set `PORTAL_URL`, `PORTAL_CLIENT_ID`, and optionally `PORTAL_ACCOUNT_ID` and `PORTAL_WEBMAP` in `project.config` (see [Project Configuration](#project-configuration-projectconfig)). Then `npm run auth:portal` runs without questions.
|
|
289
|
+
|
|
290
|
+
Option 2: run the interactive configurator in your project:
|
|
229
291
|
```bash
|
|
230
292
|
npm run auth:portal
|
|
231
293
|
```
|
|
@@ -296,8 +358,9 @@ This fork tracks official updates from `https://github.com/vertigis/vertigis-web
|
|
|
296
358
|
|
|
297
359
|
```bash
|
|
298
360
|
git fetch upstream
|
|
361
|
+
git checkout main
|
|
299
362
|
git merge upstream/master --no-edit
|
|
300
|
-
git push origin
|
|
363
|
+
git push origin main
|
|
301
364
|
```
|
|
302
365
|
Or run the parent batch synchronizer:
|
|
303
366
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geosynk/vertigis-web-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Enterprise SDK for extending VertiGIS Studio Web",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"create": "cross-env SDK_LOCAL_DEV=true node bin/vertigis-web-sdk.js create",
|
|
37
37
|
"test": "node ./test/index.js",
|
|
38
|
-
"prettier": "prettier --write \"**/*.json\" \"**/*.js\" \"**/*.ts\" \"**/*.tsx\""
|
|
38
|
+
"prettier": "prettier --write \"**/*.json\" \"**/*.js\" \"**/*.ts\" \"**/*.tsx\" \"**/*.md\""
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@vertigis/sdk-library": "~2.1.
|
|
41
|
+
"@vertigis/sdk-library": "~2.1.6",
|
|
42
42
|
"html-webpack-plugin": "^5.6.4",
|
|
43
43
|
"webpack-merge": "~6.0.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "~22.13.14",
|
|
47
|
-
"@vertigis/web": "^5.
|
|
47
|
+
"@vertigis/web": "^5.43.1",
|
|
48
48
|
"conventional-changelog-conventionalcommits": "7.0.2",
|
|
49
49
|
"cross-env": "7.0.3",
|
|
50
50
|
"eslint": "^9.37.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"node-fetch": "^2.7.0",
|
|
55
55
|
"prettier": "3.2.5",
|
|
56
56
|
"simple-git-hooks": "~2.12.1",
|
|
57
|
-
"typescript": "
|
|
57
|
+
"typescript": "^6.0.3"
|
|
58
58
|
},
|
|
59
59
|
"simple-git-hooks": {
|
|
60
60
|
"pre-commit": "npx lint-staged"
|
|
@@ -69,4 +69,4 @@
|
|
|
69
69
|
"simple-git-hooks": false,
|
|
70
70
|
"unrs-resolver": false
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|
package/scripts/create.js
CHANGED
|
@@ -101,6 +101,8 @@ const customTemplateDir = path.join(rootDir, "template-custom");
|
|
|
101
101
|
if (fs.existsSync(customTemplateDir)) {
|
|
102
102
|
console.log("[ENTERPRISE] Applying VertiGIS Studio Web SDK Enterprise Template Overlay...");
|
|
103
103
|
fs.cpSync(customTemplateDir, targetPath, { recursive: true, force: true });
|
|
104
|
+
// The overlay's src/index.ts replaces the base registration, leaving the upstream sample orphaned.
|
|
105
|
+
fs.rmSync(path.join(targetPath, "src/components/PointsOfInterest"), { recursive: true, force: true });
|
|
104
106
|
|
|
105
107
|
// Ensure shell scripts are executable on POSIX systems
|
|
106
108
|
if (process.platform !== "win32") {
|
|
@@ -109,6 +111,7 @@ if (fs.existsSync(customTemplateDir)) {
|
|
|
109
111
|
path.join(targetPath, "start.sh"),
|
|
110
112
|
path.join(targetPath, "build.sh"),
|
|
111
113
|
path.join(targetPath, "scripts/configure-portal.js"),
|
|
114
|
+
path.join(targetPath, "scripts/remote-sync.sh"),
|
|
112
115
|
];
|
|
113
116
|
for (const exe of executables) {
|
|
114
117
|
if (fs.existsSync(exe)) {
|
|
@@ -121,9 +124,13 @@ if (fs.existsSync(customTemplateDir)) {
|
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
// Configure build scripts with user-selected project name
|
|
127
|
+
// Configure build scripts and project.config with user-selected project name
|
|
125
128
|
const projectName = path.basename(targetPath);
|
|
126
|
-
const buildScripts = [
|
|
129
|
+
const buildScripts = [
|
|
130
|
+
path.join(targetPath, "build.sh"),
|
|
131
|
+
path.join(targetPath, "build.bat"),
|
|
132
|
+
path.join(targetPath, "project.config"),
|
|
133
|
+
];
|
|
127
134
|
for (const bs of buildScripts) {
|
|
128
135
|
if (fs.existsSync(bs)) {
|
|
129
136
|
try {
|
|
@@ -170,7 +177,9 @@ if (fs.existsSync(pkgPath)) {
|
|
|
170
177
|
|
|
171
178
|
pkg.scripts = pkg.scripts || {};
|
|
172
179
|
pkg.scripts["cert:gen"] = "bash ./certs/generate-cert.sh";
|
|
180
|
+
pkg.scripts["verify:styles"] = "python3 scripts/verify_zero_cosmetic_sx.py";
|
|
173
181
|
pkg.scripts["auth:portal"] = "node ./scripts/configure-portal.js";
|
|
182
|
+
pkg.scripts["start:remote"] = "bash ./start.sh remote";
|
|
174
183
|
pkg.scripts["skill:add"] =
|
|
175
184
|
"npx --yes skills add geosynk-lab/vertigis-sdk-skills --skill vertigis-web-sdk-skill -y";
|
|
176
185
|
pkg.scripts["skills:add"] = "npx --yes skills add geosynk-lab/vertigis-sdk-skills -y";
|
|
@@ -312,6 +321,7 @@ console.log(" - Anti-God Component: src/components/CustomWidget/ (ErrorB
|
|
|
312
321
|
console.log(" - Portal Auth Config: npm run auth:portal (Enterprise Portal / AGOL OAuth)");
|
|
313
322
|
console.log(" - AI Assistant Skill: npm run skill:add (install/update from vertigis-sdk-skills)");
|
|
314
323
|
console.log(" - Development Scripts: start.sh / start.bat, build.sh / build.bat");
|
|
324
|
+
console.log(" - Script Configuration: project.config (build name, upload URL, remote sync, portal auth)");
|
|
315
325
|
console.log(" - AI Directives: AGENTS.md pre-configured for coding assistants");
|
|
316
326
|
if (packageManager === "none") {
|
|
317
327
|
console.log(" - Monorepo Mode: Run 'npm install' or 'pnpm install' at workspace root");
|
package/template/package.json
CHANGED
|
@@ -3,45 +3,98 @@
|
|
|
3
3
|
<!-- vertigis-web-sdk:start -->
|
|
4
4
|
# VertiGIS Studio Web SDK Development Directives
|
|
5
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,
|
|
7
|
-
|
|
8
|
-
## 1. Typography System
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- **
|
|
29
|
-
|
|
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).
|
|
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, semantic HTML with co-located namespaced CSS, two-tier theming architecture via VertiGisThemeProvider for MUI, zero @vertigis/web/ui UI controls, strict 150–250 line component modularity, and ErrorBoundary wrapper).
|
|
7
|
+
|
|
8
|
+
## 1. Typography System & Shell Inheritance
|
|
9
|
+
- **Typography Components vs Raw CSS Bloat**: Prefer `@mui/material` `<Typography variant="...">` (`h5`/`h6` for titles, `subtitle1`/`subtitle2` for section headers, `body1`/`body2` for reading text, `caption`/`overline` for metadata/badges) paired with semantic text color tokens (`var(--primaryForeground, #212121)`, `var(--secondaryForeground, #666666)`). Using `<Typography>` completely eliminates the need to invent repetitive CSS text classes (`.Component-title`, `.Component-type`, etc.) and deletes boilerplate font-size, line-height, and font-family declarations.
|
|
10
|
+
- **Strict Ban on `@vertigis/web/ui` UI Controls**: NEVER import UI controls (`Button`, `Typography`, `DynamicIcon`, `Box`, `TitleBar`, etc.) from `@vertigis/web/ui`. These internal components depend on `useUIContext()`, which is undefined in unit tests (`vitest run`), detached React portals, or custom modals, causing fatal `TypeError: Cannot read properties of undefined (reading 'translate')` crashes. Reserve `@vertigis/web/ui` strictly for non-UI SDK hooks when needed (e.g. `useWatchAndRerender`).
|
|
11
|
+
- **Zero `font-family` (No Exceptions)**: The host application shell (`.vsw-app`) strictly owns and injects the global font stack. **NEVER declare `font-family`, the `font:` shorthand, or `fontFamily` anywhere**: CSS, `sx`, `style`, token files (no font-stack tokens, including `var(--codeFont)`/monospace stacks). The single allowed line is `typography: { fontFamily: "inherit" }` in the `createTheme` theme provider (or a chart library theme such as Nivo).
|
|
12
|
+
- **Semantic Typography Palette Props**: Primary text has no `color` prop: it inherits the host foreground (`color="text.primary"` is redundant). Use `color="text.secondary"` (captions, subtitles, helper microcopy), `color="inherit"` (inside a coloured surface that sets its own foreground), and `color="error"` (validation). NEVER write bespoke CSS classes or inline `sx={{ color: ... }}` solely to set secondary/helper text colors.
|
|
13
|
+
- **Top-Level Package Exports Only**: Always import directly from package roots (`import { Box, Typography, Dialog } from "@mui/material"`; `import { createTheme, ThemeProvider } from "@mui/material/styles"`). Deep imports (e.g. `@mui/material/styles/createTheme`) are deprecated in MUI v7 and break under modern bundlers.
|
|
14
|
+
|
|
15
|
+
## 2. Host-Governed Styling (Zero Cosmetic `sx`)
|
|
16
|
+
- **Six Principles**:
|
|
17
|
+
1. **Host governs cosmetics**: VertiGIS Studio Web supplies MUI ThemeProvider + portal branding CSS variables. Components inherit surface, elevation, borders and typography.
|
|
18
|
+
2. **Zero cosmetic properties in component `sx`, `style`, `styles` dictionaries and `styled()`**: Banned: `border*`, `outline*`, `borderRadius*`, `background*`, `bgcolor`, `backdropFilter`, `boxShadow`, `textShadow`, `filter`, `color`, `textColor`, `textDecoration`, `textTransform`, `fontFamily`, `fontSize`, `fontWeight`, `lineHeight`, `letterSpacing`. These live ONLY in `src/tokens/muiTheme.ts` (`createTheme` `components.*.styleOverrides`) or are inherited. Text uses `<Typography variant>` and `color="text.secondary"`.
|
|
19
|
+
3. **Canonical layout, gap over margin**: 1D rows/columns -> `<Stack direction spacing alignItems justifyContent>`. 2D -> `<Box sx={{ display: "flex", flexDirection, gap, alignItems }}>` or `<Grid container spacing>`. Space siblings using parent `gap` or `Stack spacing`, never child `margin`. Allowed `sx` keys: display, flex*, align*, justify*, grid*, spacing keys, sizing (width/height/min/max), positioning (position/top/bottom/left/right/zIndex), and overflow*.
|
|
20
|
+
4. **8px grid spacing**: All spacing (`p*`, `m*`, `gap`, `spacing`) must use canonical 8px grid steps: `0, 0.5, 1, 1.5, 2, 2.5, 3, 4` (negatives, `"auto"`, and responsive objects allowed). Raw pixel strings (`"13px"`) and arbitrary decimals (`0.35`) are banned. Do NOT set `spacing: 5` in createTheme.
|
|
21
|
+
5. **Declarative state via data attributes**: Express dynamic status via `<Card data-status={status}>`. Style `&[data-status="..."]` centrally in `src/tokens/muiTheme.ts`.
|
|
22
|
+
6. **Containment**: `<canvas>`, `<img>`, `<iframe>` must be contained inside `<Paper variant="outlined">` or `<Card>` (or CardContent/CardMedia/CardActionArea); child keeps only functional dimensions (`style={{ width: "100%" }}`).
|
|
23
|
+
- **Zero Hardcoded Colors & Shapes**: Strict ban on hardcoded hex (`#ffffff`), RGB (`rgb(...)`), or HSL color values, and hardcoded corner radii (e.g. `border-radius: 4px;`). Always use unified shape tokens: `var(--borderRadius, 4px)` (standard), `var(--borderRadiusSm, 2px)` (micro), `var(--borderRadiusLarge, 8px)` / `var(--borderRadiusLg, 8px)` (cards/dialogs), and `50%` / `9999px` (pills/rounds).
|
|
24
|
+
- **Crash Prevention**: NEVER pass raw `var(...)` strings (including any `UI_TOKENS.*` value) into `palette.primary.main` or `palette.error.main` (causes MUI `augmentColor()` to crash). Attach CSS variables via component `styleOverrides` (e.g. `MuiRadio: { styleOverrides: { root: { "&.Mui-checked": { color: "var(--primaryAccent, #007ac2)" } } } }`). Use `color-mix(in srgb, ...)` instead of `alpha()`, and configure `MuiLink` `styleOverrides` in `src/tokens/muiTheme.ts`.
|
|
25
|
+
- **No Text on Accent Fills**: NEVER put text on a `--primaryAccent` background (`UI_TOKENS.accent.primary`). No host foreground token is paired with it. Brand themes can give `--primaryAccent` and `--emphasizedButtonForeground` the same colour (for example black on black). For an emphasized fill, use `--emphasizedButtonBackground` with `--emphasizedButtonForeground`. For a selected toggle or list item, use `UI_TOKENS.control.itemSelected` with the inherited text and `UI_TOKENS.accent.primary` only as the border (write `UI_TOKENS.text.primary` only inside `createTheme` `styleOverrides`). The validator rule `TOKEN_PAIRING` reports this.
|
|
26
|
+
- **Minimal CSS Injection**: CSS files are optional and carry no component chrome (cosmetics belong in `muiTheme.ts`). When used, strictly namespace classes (e.g. `.CustomWidget-body`) and never declare `:root`.
|
|
27
|
+
- **MUI Portal Containment**: Configure `MuiPopover.defaultProps.container` to return `.vsw-app` so popovers mount inside the host shell.
|
|
28
|
+
- **Strict Ban on `<CssBaseline />`**: NEVER mount `<CssBaseline />` under `VertiGisThemeProvider` or anywhere in extensions.
|
|
29
|
+
- **MUI v7 `slotProps` Standardization**: Use `slotProps` for composite controls (`<Dialog slotProps={{ paper: { ... } }}>`, `<TextField slotProps={{ input: { readOnly } }}>`).
|
|
34
30
|
|
|
35
31
|
## 3. Strict Component Modularity & Anti-God-Component Architecture
|
|
36
32
|
- **Strict File Size Thresholds**: Max 150–250 lines per file. Any file exceeding 250 lines MUST be refactored and decomposed.
|
|
33
|
+
- **JSX Only in `.tsx`**: Any file containing JSX MUST use the `.tsx` extension; never put JSX in a `.ts` file.
|
|
37
34
|
- **Standard Directory Blueprint**: Decompose complex components into:
|
|
38
35
|
- `components/`: Presentational, stateless sub-components.
|
|
39
36
|
- `hooks/`: Custom React hooks for state, lifecycle subscriptions, and business logic.
|
|
40
|
-
- `tokens/`: Centralized design token definitions and theme utilities.
|
|
41
37
|
- `services/`: Component-level services and integrations.
|
|
42
|
-
- `utils/`: Pure
|
|
43
|
-
- `
|
|
38
|
+
- `utils/` / `helpers/`: Pure functions, calculations, and zero-dependency helpers.
|
|
39
|
+
- `tokens/`: Design tokens and theme mappings.
|
|
40
|
+
- `types/`: Type contracts, interfaces, and serialization models.
|
|
44
41
|
- **Model vs View Separation**:
|
|
45
|
-
- Component
|
|
46
|
-
-
|
|
42
|
+
- MobX Component Models (`*Model.ts`): State, observables, service injection, and lifecycle hooks (`_onInitialize()`, `_onDestroy()`).
|
|
43
|
+
- React Views (`*.tsx`): Visual rendering, layout slotting wrapped in `<LayoutElement {...props}>`, `observer()`, and `<ErrorBoundary>`.
|
|
44
|
+
- **Extraction Heuristics**:
|
|
45
|
+
- Extract sub-views when JSX nesting exceeds 3 levels or individual visual sections emerge.
|
|
46
|
+
- Extract event listeners, timers, and data operations into custom hooks.
|
|
47
|
+
- Extract data formatting and business logic into pure, testable utility functions.
|
|
48
|
+
|
|
49
|
+
## 4. Component Architecture & Container Shell Contracts
|
|
50
|
+
- **`<LayoutElement {...props}>` Root**: Every React component view MUST wrap all JSX within `<LayoutElement {...props}>` from `@vertigis/web/components` for layout slotting and Designer support.
|
|
51
|
+
- **MobX `observer()`**: Wrap all React views that read model observables with `observer()` from `mobx-react-lite`.
|
|
52
|
+
- **`<ErrorBoundary>` Wrapping**: Wrap custom widget contents in an `<ErrorBoundary>` component to isolate runtime faults and protect host application stability.
|
|
53
|
+
- **Symmetric Lifecycle Sequencing**: In `_onInitialize()`, ALWAYS call `await super._onInitialize()` FIRST before setting up component resources. In `_onDestroy()`, ALWAYS clean up child subscriptions, intervals, and map layers FIRST, and invoke `await super._onDestroy()` LAST.
|
|
54
|
+
- **Strict Ban on Custom `_handles` Property**: NEVER declare a property named `_handles` (e.g., `private _handles = []`). Base `InitializableBase` / `HandlesMixin` initializes `this._handles` as an `@arcgis/core/core/Handles` instance. Declaring `_handles` in derived classes clobbers the base instance under ES2022 class field semantics, causing `TypeError: this._handles.destroy is not a function` during Designer unmount or deployment packaging. Use domain-specific names (e.g., `_eventHandles`, `_sketchHandles`, `_disposables`) or use inherited `this._handles.add(...)`.
|
|
55
|
+
- **Dev OAuth Isolation (Production Builds)**: Call `initPortalAuth()` only inside `if (process.env.NODE_ENV !== "production") { ... }` in `src/index.ts`, and start `initPortalAuth()` with `if (process.env.NODE_ENV === "production") return;`. Use `window.location.origin` for the OAuth callback URL, never a hardcoded `localtest.me:3001`. After the build, `build/main.js` MUST NOT contain `localtest.me` or `oauth_callback` (`build.sh`, `build.bat` and `Dockerfile.build` check this). The validator rule `UNGUARDED_DEV_AUTH` reports a missing guard.
|
|
56
|
+
- **Host Container Shell Contracts**:
|
|
57
|
+
- **Tabs (`<tab-container>` / `<tabs>`)**: NEVER return `<LayoutElement style={{ display: "none" }} />` or an empty placeholder when `props.active === false`. Inactive tabs receive `active="false"`; the host tab container handles hiding and tab switching. Hiding the component internally leaves the tab blank white on click!
|
|
58
|
+
- **Panels vs Bare Split Components**: In a `<panel>`, manage visibility via `ui.activate`/`ui.deactivate` on the **panel layout ID**. Bare in a `<split>`, manage visibility internally and invoke `ui.activate`/`ui.deactivate` on the **component ID**.
|
|
59
|
+
- **Dialogs & Full-Height Stretches**: Custom dialog views MUST use `<LayoutElement {...props} stretch style={{ height: "100%", width: "100%", display: "flex", flexDirection: "column", flex: 1, minHeight: 0 }}>`. STRICT BAN on injecting `<GlobalStyles !important>` targeting host dialog chrome.
|
|
60
|
+
|
|
61
|
+
## 5. Web Designer Settings Schema Protocol & XML Attribute Lifecycle
|
|
62
|
+
When exposing customizable component properties to the VertiGIS Studio Web Designer inspector panel:
|
|
63
|
+
- **Schema Declaration (`getLayoutDesignerSettingsSchema`)**: Return a `SettingsSchema` declaring setting fields (`id`, `type` such as `text`, `number`, `checkbox`, `select`, `displayName`, `description`).
|
|
64
|
+
- **Current Value Extraction (`getLayoutDesignerSettings`)**: Read XML attributes from layout node (`args.node.attributes.get(...)`) and map them to the Designer settings form state. Support both kebab-case (`telemetry-layout-id`) and camelCase (`telemetryLayoutId`).
|
|
65
|
+
- **Persisting Changes (`applyLayoutDesignerSettings`)**:
|
|
66
|
+
- **Safe Trimming & Explicit Attribute Deletion**: NEVER write empty strings (`node.attributes.set(key, "")`). Writing empty strings creates sticky XML attributes that resurrect default values on reload. Always trim string inputs (`safeTrim`); if a value is present, call `node.attributes.set(kebabKey, val)`; if empty or cleared, call `node.attributes.delete(kebabKey)`.
|
|
67
|
+
- **Live Model Synchronization**: Propagate configuration changes into the active model instance via `model.updateConfig(...)`.
|
|
68
|
+
- **Lifecycle Initialization from XML Node**: In `_onInitialize()`, component models must read `(this as any).node?.attributes` to guarantee that attributes declared in `layout.xml` are loaded immediately on startup even before the designer inspector is opened.
|
|
69
|
+
|
|
70
|
+
## 6. Feature Actions, Commands, & Arcade Scripting Protocol
|
|
71
|
+
- **Layer Filtering via `arcade.run`**: When configuring feature actions in Web Designer to trigger custom commands, always wrap the execution filter in `arcade.run` with a robust `canExecuteScript` using `HasKey($feature, 'Field')`:
|
|
72
|
+
```json
|
|
73
|
+
[
|
|
74
|
+
{
|
|
75
|
+
"name": "arcade.run",
|
|
76
|
+
"arguments": {
|
|
77
|
+
"canExecuteScript": "(HasKey($feature, 'GFID') || HasKey($feature, 'gfid'))"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"your-command.display"
|
|
81
|
+
]
|
|
82
|
+
```
|
|
83
|
+
- **Command Execution Contract**: Custom commands registered via `registerCommandHandler` must gracefully accept either an ArcGIS Graphic/Feature object (`target.attributes`) or a plain parameter map (`target.id`).
|
|
84
|
+
- **Host Command Interception**: When a model hooks a built-in command with `@command("<host.command>", ...)` (for example `layer-comparison.set-mode`), ALWAYS pass `{ targetInactive: true }`, because a component inside a collapsed `<expand>` or a closed panel is inactive and its handler does not run. ALWAYS forward the same arguments with `await context?.next?.(args)` before you change your own state: `context.next()` without `args` sends `undefined` to the host handler and crashes VertiGIS. Accept both payload shapes (`true`/`false` and `{ active }`).
|
|
85
|
+
|
|
86
|
+
## 7. Gradual Verification Protocol & Mandatory Micro-Gates
|
|
87
|
+
Never treat verification as a single end-of-task formality. Enforce the **6-Tier Gradual Verification Gate** after every code edit. Run every tier, including the Rule Validator; a passing build and lint is NOT a passing gate. Report the exit code of each tier. Skip a tier only when its script does not exist in `package.json`, and say so:
|
|
88
|
+
1. **Fast Typecheck**: `tsc --noEmit` (clean types).
|
|
89
|
+
2. **Lint**: `npm run lint` (zero errors).
|
|
90
|
+
3. **Zero-Cosmetic-SX Check**: `npm run verify:styles` (= `python3 scripts/verify_zero_cosmetic_sx.py`) MUST exit 0.
|
|
91
|
+
4. **Unit & Contract Tests**: Test component logic AND Designer attribute persistence (asserting that empty strings delete XML attributes and kebab-case attributes map to camelCase).
|
|
92
|
+
5. **Production Build**: `npm run build` or `pnpm run build` (clean compilation).
|
|
93
|
+
6. **Rule Validator**: `python3 <skill-dir>/scripts/validate_web_sdk.py --path .` MUST exit 0, where `<skill-dir>` is the installed `vertigis-web-sdk-skill` folder (e.g. `~/.agents/skills/vertigis-web-sdk-skill`). Suppress a rule only with a written reason: `// vertigis-rule-disable RULE_ID -- <reason>`.
|
|
94
|
+
- **2-Strike Halt Gate**: If a fix fails verification twice on the same step, STOP. Report what was tried, what failed, and ask for guidance.
|
|
95
|
+
|
|
96
|
+
## 8. Ponytail Code Minimization & Zero-Garbage Invariant
|
|
97
|
+
- **Native Platform & MUI First**: Use native MUI controls (`IconButton`, `Typography`, `Box`, `Alert`) with VertiGIS theme tokens. NEVER write 30+ lines of custom CSS with `!important` to replicate native MUI buttons or toggles.
|
|
98
|
+
- **Deletion-First Refactoring**: When replacing an implementation or abandoning an API, delete the old implementation and all unused helper files FIRST. Verify with `knip` before authoring new code.
|
|
99
|
+
- **Zero Untracked Garbage**: Never leave experimental scrapers, orphan test fixtures, or dead wrappers in the codebase.
|
|
47
100
|
<!-- vertigis-web-sdk:end -->
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1.4
|
|
2
|
+
# Multi-stage Dockerfile for building VertiGIS Studio Web SDK extensions in clean CI/CD environments.
|
|
3
|
+
#
|
|
4
|
+
# Build and extract compiled bundle directly to host filesystem:
|
|
5
|
+
# docker build -f Dockerfile.build --target exporter --output build/ .
|
|
6
|
+
# Or build standard container image:
|
|
7
|
+
# docker build -f Dockerfile.build -t vertigis-extension:prod .
|
|
8
|
+
|
|
9
|
+
FROM node:20-alpine AS builder
|
|
10
|
+
|
|
11
|
+
WORKDIR /app
|
|
12
|
+
|
|
13
|
+
# Enable corepack for pnpm support
|
|
14
|
+
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
15
|
+
|
|
16
|
+
# Layer 1: Cached dependencies
|
|
17
|
+
COPY package.json pnpm-lock.yaml* package-lock.json* ./
|
|
18
|
+
RUN if [ -f pnpm-lock.yaml ]; then \
|
|
19
|
+
pnpm install --frozen-lockfile; \
|
|
20
|
+
elif [ -f package-lock.json ]; then \
|
|
21
|
+
npm ci; \
|
|
22
|
+
else \
|
|
23
|
+
npm install; \
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# Layer 2: Source compilation
|
|
27
|
+
COPY . .
|
|
28
|
+
ENV NODE_ENV=production
|
|
29
|
+
RUN if [ -f pnpm-lock.yaml ]; then \
|
|
30
|
+
pnpm run build; \
|
|
31
|
+
else \
|
|
32
|
+
npm run build; \
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# Layer 3: Sanity audit (verify zero dev OAuth URLs leaked into production bundle).
|
|
36
|
+
# "localtest.me" is the dev host and "oauth_callback" is the dev popup callback page.
|
|
37
|
+
RUN for marker in localtest.me oauth_callback; do \
|
|
38
|
+
if grep -Fq "$marker" build/main.js; then \
|
|
39
|
+
echo "FATAL: dev OAuth URL ($marker) detected in build/main.js! Dev OAuth hijacked production bundle." >&2; \
|
|
40
|
+
exit 1; \
|
|
41
|
+
fi; \
|
|
42
|
+
done
|
|
43
|
+
|
|
44
|
+
# Layer 4: Minimal scratch exporter (extracts build/ directory via BuildKit)
|
|
45
|
+
FROM scratch AS exporter
|
|
46
|
+
COPY --from=builder /app/build/ /
|
|
@@ -1,11 +1,90 @@
|
|
|
1
1
|
@echo off
|
|
2
|
+
setlocal enabledelayedexpansion
|
|
3
|
+
rem Usage: build.bat [name]
|
|
4
|
+
rem Build build\<name>.js and build\<name>.js.txt.
|
|
5
|
+
rem build.bat upload-gc [public-url] [name]
|
|
6
|
+
rem Build, then upload build\<name>.js to Google Cloud Storage with gcloud.
|
|
7
|
+
rem
|
|
8
|
+
rem Values that you do not give on the command line come from project.config:
|
|
9
|
+
rem BUILD_NAME, GC_UPLOAD_URL, GC_CACHE_CONTROL. See project.config for the description of each value.
|
|
10
|
+
rem
|
|
11
|
+
rem <public-url> is https://storage.googleapis.com/<bucket>/<path> or gs://<bucket>/<path>.
|
|
12
|
+
rem If the URL ends with ".js", it is the object name. Otherwise it is a folder and the file is <name>.js in it.
|
|
13
|
+
rem The bucket must already allow public read (allUsers: Storage Object Viewer). This script does not change access.
|
|
14
|
+
|
|
15
|
+
cd /d "%~dp0"
|
|
16
|
+
call scripts\load-config.bat
|
|
17
|
+
|
|
18
|
+
set "UPLOAD="
|
|
19
|
+
set "UPLOAD_URL="
|
|
2
20
|
set "NAME=%~1"
|
|
3
|
-
if "
|
|
21
|
+
if /i not "%~1"=="upload-gc" goto :name
|
|
22
|
+
set "UPLOAD=1"
|
|
23
|
+
set "UPLOAD_URL=%~2"
|
|
24
|
+
set "NAME=%~3"
|
|
25
|
+
if "!UPLOAD_URL!"=="" set "UPLOAD_URL=!CFG_GC_UPLOAD_URL!"
|
|
26
|
+
if "!UPLOAD_URL!"=="" (
|
|
27
|
+
echo Usage: build.bat upload-gc ^<public-url^> [name]
|
|
28
|
+
echo Or set GC_UPLOAD_URL in project.config and run: build.bat upload-gc
|
|
29
|
+
exit /b 1
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
:name
|
|
33
|
+
if "!NAME!"=="" set "NAME=!CFG_BUILD_NAME!"
|
|
34
|
+
if "!NAME!"=="" set "NAME=__PROJECT_NAME__"
|
|
35
|
+
set "CACHE_CONTROL=!CFG_GC_CACHE_CONTROL!"
|
|
36
|
+
if "!CACHE_CONTROL!"=="" set "CACHE_CONTROL=no-cache"
|
|
37
|
+
|
|
38
|
+
rem Check the upload settings before the build, so that a bad URL fails fast.
|
|
39
|
+
set "GS_OBJECT="
|
|
40
|
+
if "!UPLOAD!"=="" goto :build
|
|
41
|
+
set "GS_PATH="
|
|
42
|
+
if /i "!UPLOAD_URL:~0,5!"=="gs://" set "GS_PATH=!UPLOAD_URL:~5!"
|
|
43
|
+
if /i "!UPLOAD_URL:~0,31!"=="https://storage.googleapis.com/" set "GS_PATH=!UPLOAD_URL:~31!"
|
|
44
|
+
if "!GS_PATH!"=="" (
|
|
45
|
+
echo Error: the URL must start with https://storage.googleapis.com/ or gs:// and contain a bucket name
|
|
46
|
+
exit /b 1
|
|
47
|
+
)
|
|
48
|
+
if "!GS_PATH:~0,1!"=="/" (
|
|
49
|
+
echo Error: no bucket name in !UPLOAD_URL!
|
|
50
|
+
exit /b 1
|
|
51
|
+
)
|
|
52
|
+
if /i "!GS_PATH:~-3!"==".js" (
|
|
53
|
+
set "GS_OBJECT=!GS_PATH!"
|
|
54
|
+
) else if "!GS_PATH:~-1!"=="/" (
|
|
55
|
+
set "GS_OBJECT=!GS_PATH!!NAME!.js"
|
|
56
|
+
) else (
|
|
57
|
+
set "GS_OBJECT=!GS_PATH!/!NAME!.js"
|
|
58
|
+
)
|
|
59
|
+
where gcloud >nul 2>&1
|
|
60
|
+
if errorlevel 1 (
|
|
61
|
+
echo Error: gcloud not found. Install the Google Cloud CLI and run: gcloud auth login
|
|
62
|
+
exit /b 1
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
:build
|
|
4
66
|
call npm run build || exit /b 1
|
|
5
67
|
if not exist build\main.js (
|
|
6
|
-
echo Error: build\main.js not found
|
|
68
|
+
echo Error: build\main.js not found.
|
|
7
69
|
exit /b 1
|
|
8
70
|
)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
71
|
+
rem Production gate: the dev OAuth code (src\auth) must not be in the bundle. It is removed only when
|
|
72
|
+
rem NODE_ENV is "production" (the SDK build command sets it). "localtest.me" is the dev host, and
|
|
73
|
+
rem "oauth_callback" is the dev popup callback page. If your library uses its own OAuth callback in
|
|
74
|
+
rem production, rename that page or change this check.
|
|
75
|
+
for %%M in (localtest.me oauth_callback) do (
|
|
76
|
+
findstr /C:"%%M" build\main.js >nul
|
|
77
|
+
if not errorlevel 1 (
|
|
78
|
+
echo Error: dev OAuth URL ^(%%M^) detected in build\main.js. Dev OAuth hijacked production bundle.
|
|
79
|
+
exit /b 1
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
copy /y build\main.js "build\!NAME!.js" >nul
|
|
83
|
+
copy /y build\main.js "build\!NAME!.js.txt" >nul
|
|
84
|
+
echo Created build\!NAME!.js and build\!NAME!.js.txt (verified zero dev URLs)
|
|
85
|
+
|
|
86
|
+
if "!GS_OBJECT!"=="" exit /b 0
|
|
87
|
+
echo Uploading build\!NAME!.js to gs://!GS_OBJECT! (Cache-Control: !CACHE_CONTROL!)...
|
|
88
|
+
call gcloud storage cp "build\!NAME!.js" "gs://!GS_OBJECT!" --content-type=application/javascript "--cache-control=!CACHE_CONTROL!" || exit /b 1
|
|
89
|
+
echo Uploaded. Public URL (add it in Designer ^> App Settings ^> Custom Libraries):
|
|
90
|
+
echo https://storage.googleapis.com/!GS_OBJECT!
|