@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
|
@@ -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,11 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
set "NAME=%~1"
|
|
3
|
+
if "%NAME%"=="" set "NAME=__PROJECT_NAME__"
|
|
4
|
+
call npm run build || exit /b 1
|
|
5
|
+
if not exist build\main.js (
|
|
6
|
+
echo Error: build\main.js not found!
|
|
7
|
+
exit /b 1
|
|
8
|
+
)
|
|
9
|
+
copy /y build\main.js "build\%NAME%.js" >nul
|
|
10
|
+
copy /y build\main.js "build\%NAME%.js.txt" >nul
|
|
11
|
+
echo Created build\%NAME%.js and build\%NAME%.js.txt
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
NAME="${1:-__PROJECT_NAME__}"
|
|
5
|
+
|
|
6
|
+
npm run build
|
|
7
|
+
|
|
8
|
+
if [ ! -f "build/main.js" ]; then
|
|
9
|
+
echo "Error: build/main.js not found!"
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
cp -f "build/main.js" "build/${NAME}.js"
|
|
14
|
+
cp -f "build/main.js" "build/${NAME}.js.txt"
|
|
15
|
+
echo "Created build/${NAME}.js and build/${NAME}.js.txt"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
set CERTS_DIR=%~dp0
|
|
4
|
+
if not exist "%CERTS_DIR%cert.pem" (
|
|
5
|
+
echo [INFO] Generating self-signed development SSL certificate via OpenSSL...
|
|
6
|
+
openssl req -x509 -newkey rsa:2048 -keyout "%CERTS_DIR%key.pem" -out "%CERTS_DIR%cert.pem" -days 365 -nodes -subj "/CN=localtest.me" -addext "subjectAltName=DNS:localtest.me,DNS:*.localtest.me,DNS:localhost,DNS:*.localhost,IP:127.0.0.1"
|
|
7
|
+
if %ERRORLEVEL% EQU 0 (
|
|
8
|
+
echo [SUCCESS] SSL certificate and private key generated in certs/ with SAN (localtest.me, localhost, 127.0.0.1)
|
|
9
|
+
) else (
|
|
10
|
+
echo [WARN] OpenSSL command failed. Please ensure openssl is installed and in your PATH.
|
|
11
|
+
)
|
|
12
|
+
) else (
|
|
13
|
+
echo [INFO] SSL certificate already exists in certs/
|
|
14
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
CERTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
|
|
6
|
+
if [ ! -f "$CERTS_DIR/cert.pem" ] || [ ! -f "$CERTS_DIR/key.pem" ]; then
|
|
7
|
+
echo "[INFO] Generating self-signed development SSL certificate via OpenSSL..."
|
|
8
|
+
openssl req -x509 -newkey rsa:2048 -keyout "$CERTS_DIR/key.pem" -out "$CERTS_DIR/cert.pem" -days 365 -nodes \
|
|
9
|
+
-subj "/CN=localtest.me" \
|
|
10
|
+
-addext "subjectAltName=DNS:localtest.me,DNS:*.localtest.me,DNS:localhost,DNS:*.localhost,IP:127.0.0.1"
|
|
11
|
+
echo "[SUCCESS] SSL certificate and private key generated in certs/ with SAN (localtest.me, localhost, 127.0.0.1)"
|
|
12
|
+
else
|
|
13
|
+
echo "[INFO] SSL certificate already exists in certs/"
|
|
14
|
+
fi
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Box, Typography } from "@mui/material";
|
|
3
|
+
import type { LayoutElementProperties } from "@vertigis/web/components";
|
|
4
|
+
import { LayoutElement } from "@vertigis/web/components";
|
|
5
|
+
import { tokens } from "../../tokens";
|
|
6
|
+
import type { CustomWidgetModel } from "./CustomWidgetModel";
|
|
7
|
+
import { CustomWidgetErrorBoundary } from "./components/CustomWidgetErrorBoundary";
|
|
8
|
+
|
|
9
|
+
export interface CustomWidgetProps extends LayoutElementProperties<CustomWidgetModel> {}
|
|
10
|
+
|
|
11
|
+
function CustomWidgetView(props: CustomWidgetProps): React.ReactElement {
|
|
12
|
+
const { model } = props;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<LayoutElement {...props}>
|
|
16
|
+
<Box
|
|
17
|
+
sx={{
|
|
18
|
+
p: 2,
|
|
19
|
+
backgroundColor: tokens.ui.surface.primary,
|
|
20
|
+
border: `1px solid ${tokens.ui.border.primary}`,
|
|
21
|
+
borderRadius: tokens.ui.shape.borderRadius,
|
|
22
|
+
boxShadow: tokens.ui.shape.shadowPrimary,
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
<Typography
|
|
26
|
+
variant="h6"
|
|
27
|
+
sx={{
|
|
28
|
+
color: tokens.ui.text.primary,
|
|
29
|
+
fontFamily: tokens.typography.fontFamily.primary,
|
|
30
|
+
mb: 0.5,
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
{model.title}
|
|
34
|
+
</Typography>
|
|
35
|
+
|
|
36
|
+
<Typography
|
|
37
|
+
variant="subtitle2"
|
|
38
|
+
sx={{
|
|
39
|
+
color: tokens.ui.text.secondary,
|
|
40
|
+
fontFamily: tokens.typography.fontFamily.primary,
|
|
41
|
+
mb: 1.5,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
Enterprise VertiGIS Component Architecture
|
|
45
|
+
</Typography>
|
|
46
|
+
|
|
47
|
+
<Box
|
|
48
|
+
sx={{
|
|
49
|
+
p: 1.5,
|
|
50
|
+
backgroundColor: tokens.ui.surface.secondary,
|
|
51
|
+
border: `1px solid ${tokens.ui.border.secondary}`,
|
|
52
|
+
borderRadius: tokens.ui.shape.borderRadius,
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<Typography variant="body2" sx={{ color: tokens.ui.text.primary }}>
|
|
56
|
+
This widget demonstrates centralized tokens, safe fallbacks, and error boundary encapsulation.
|
|
57
|
+
</Typography>
|
|
58
|
+
</Box>
|
|
59
|
+
</Box>
|
|
60
|
+
</LayoutElement>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default function CustomWidget(props: CustomWidgetProps): React.ReactElement {
|
|
65
|
+
return (
|
|
66
|
+
<CustomWidgetErrorBoundary>
|
|
67
|
+
<CustomWidgetView {...props} />
|
|
68
|
+
</CustomWidgetErrorBoundary>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentModelBase, serializable, importModel } from "@vertigis/web/models";
|
|
2
|
+
import type { MapModel } from "@vertigis/web/mapping";
|
|
3
|
+
|
|
4
|
+
@serializable
|
|
5
|
+
export class CustomWidgetModel extends ComponentModelBase {
|
|
6
|
+
@importModel("map-extension")
|
|
7
|
+
map?: MapModel;
|
|
8
|
+
|
|
9
|
+
protected override async _onInitialize(): Promise<void> {
|
|
10
|
+
await super._onInitialize();
|
|
11
|
+
this.title = "Custom Widget";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default CustomWidgetModel;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Box, Typography, Button } from "@mui/material";
|
|
3
|
+
import { tokens } from "../../../tokens";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface State {
|
|
10
|
+
hasError: boolean;
|
|
11
|
+
errorMessage: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class CustomWidgetErrorBoundary extends React.Component<Props, State> {
|
|
15
|
+
constructor(props: Props) {
|
|
16
|
+
super(props);
|
|
17
|
+
this.state = { hasError: false, errorMessage: "" };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static getDerivedStateFromError(error: Error): State {
|
|
21
|
+
return { hasError: true, errorMessage: error?.message || "Unknown error" };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
|
|
25
|
+
console.error("CustomWidget error:", error, errorInfo);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
handleRetry = (): void => {
|
|
29
|
+
this.setState({ hasError: false, errorMessage: "" });
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
render(): React.ReactNode {
|
|
33
|
+
if (this.state.hasError) {
|
|
34
|
+
return (
|
|
35
|
+
<Box
|
|
36
|
+
sx={{
|
|
37
|
+
p: 2,
|
|
38
|
+
backgroundColor: tokens.ui.status.errorBg,
|
|
39
|
+
border: `1px solid ${tokens.ui.status.errorBorder}`,
|
|
40
|
+
borderRadius: tokens.ui.shape.borderRadius,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<Typography variant="subtitle2" sx={{ color: tokens.ui.status.errorFg, fontWeight: "bold" }}>
|
|
44
|
+
Widget Display Error
|
|
45
|
+
</Typography>
|
|
46
|
+
<Typography variant="caption" sx={{ color: tokens.ui.text.primary, display: "block", my: 1 }}>
|
|
47
|
+
{this.state.errorMessage}
|
|
48
|
+
</Typography>
|
|
49
|
+
<Button size="small" variant="outlined" onClick={this.handleRetry}>
|
|
50
|
+
Retry
|
|
51
|
+
</Button>
|
|
52
|
+
</Box>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return this.props.children;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useIsDarkTheme";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useTheme } from "@mui/material/styles";
|
|
3
|
+
import { isDarkTheme } from "../utils/themeDetection";
|
|
4
|
+
|
|
5
|
+
export function useIsDarkTheme(): boolean {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const [isDark, setIsDark] = React.useState<boolean>(() => {
|
|
8
|
+
if (theme?.palette?.mode === "dark") return true;
|
|
9
|
+
if (theme?.palette?.mode === "light") return false;
|
|
10
|
+
return isDarkTheme();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (theme?.palette?.mode === "dark") {
|
|
15
|
+
setIsDark(true);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (theme?.palette?.mode === "light") {
|
|
19
|
+
setIsDark(false);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const updateDark = () => {
|
|
24
|
+
setIsDark(isDarkTheme());
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
updateDark();
|
|
28
|
+
|
|
29
|
+
const mql = typeof window !== "undefined" && window.matchMedia
|
|
30
|
+
? window.matchMedia("(prefers-color-scheme: dark)")
|
|
31
|
+
: null;
|
|
32
|
+
mql?.addEventListener?.("change", updateDark);
|
|
33
|
+
|
|
34
|
+
let observer: MutationObserver | null = null;
|
|
35
|
+
if (typeof MutationObserver !== "undefined" && typeof document !== "undefined") {
|
|
36
|
+
observer = new MutationObserver(updateDark);
|
|
37
|
+
const obsConfig = {
|
|
38
|
+
attributes: true,
|
|
39
|
+
attributeFilter: ["data-theme", "class", "style"],
|
|
40
|
+
};
|
|
41
|
+
if (document.documentElement) observer.observe(document.documentElement, obsConfig);
|
|
42
|
+
if (document.body) observer.observe(document.body, obsConfig);
|
|
43
|
+
const vswApp = document.querySelector(".vsw-app");
|
|
44
|
+
if (vswApp) observer.observe(vswApp, obsConfig);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return () => {
|
|
48
|
+
mql?.removeEventListener?.("change", updateDark);
|
|
49
|
+
observer?.disconnect();
|
|
50
|
+
};
|
|
51
|
+
}, [theme?.palette?.mode]);
|
|
52
|
+
|
|
53
|
+
return isDark;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default useIsDarkTheme;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LibraryRegistry } from "@vertigis/web/config";
|
|
2
|
+
import CustomWidget, { CustomWidgetModel } from "./components/CustomWidget";
|
|
3
|
+
|
|
4
|
+
const LAYOUT_NAMESPACE = "custom.foo";
|
|
5
|
+
|
|
6
|
+
export default function (registry: LibraryRegistry): void {
|
|
7
|
+
registry.registerComponent({
|
|
8
|
+
category: "map",
|
|
9
|
+
iconId: "widgets",
|
|
10
|
+
name: "custom-widget",
|
|
11
|
+
namespace: LAYOUT_NAMESPACE,
|
|
12
|
+
getComponentType: () => CustomWidget,
|
|
13
|
+
itemType: "custom-widget-model",
|
|
14
|
+
title: "Custom Widget",
|
|
15
|
+
});
|
|
16
|
+
registry.registerModel({
|
|
17
|
+
getModel: config => new CustomWidgetModel(config),
|
|
18
|
+
itemType: "custom-widget-model",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { UI_TOKENS } from "./ui";
|
|
2
|
+
import { TYPOGRAPHY_TOKENS } from "./typography";
|
|
3
|
+
|
|
4
|
+
export { UI_TOKENS } from "./ui";
|
|
5
|
+
export { TYPOGRAPHY_TOKENS } from "./typography";
|
|
6
|
+
|
|
7
|
+
export function alphaMix(token: string, opacityPercent: number): string {
|
|
8
|
+
const clamped = Math.max(0, Math.min(100, opacityPercent));
|
|
9
|
+
return `color-mix(in srgb, ${token} ${clamped}%, transparent)`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function surfaceMix(fgToken: string, bgToken: string, weightPercent: number): string {
|
|
13
|
+
const clamped = Math.max(0, Math.min(100, weightPercent));
|
|
14
|
+
return `color-mix(in srgb, ${fgToken} ${clamped}%, ${bgToken})`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const tokens = {
|
|
18
|
+
ui: UI_TOKENS,
|
|
19
|
+
typography: TYPOGRAPHY_TOKENS,
|
|
20
|
+
alphaMix,
|
|
21
|
+
surfaceMix,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default tokens;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typography Tokens for VertiGIS Studio Web SDK
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const TYPOGRAPHY_TOKENS = {
|
|
6
|
+
fontFamily: {
|
|
7
|
+
primary: "var(--defaultFont, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif)",
|
|
8
|
+
mono: "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
|
|
9
|
+
},
|
|
10
|
+
fontSize: {
|
|
11
|
+
h5: "1.5rem",
|
|
12
|
+
h6: "1.25rem",
|
|
13
|
+
subtitle1: "1rem",
|
|
14
|
+
subtitle2: "0.875rem",
|
|
15
|
+
body1: "1rem",
|
|
16
|
+
body2: "0.875rem",
|
|
17
|
+
caption: "0.75rem",
|
|
18
|
+
overline: "0.625rem",
|
|
19
|
+
},
|
|
20
|
+
fontWeight: {
|
|
21
|
+
regular: 400,
|
|
22
|
+
medium: 500,
|
|
23
|
+
semibold: 600,
|
|
24
|
+
bold: 700,
|
|
25
|
+
},
|
|
26
|
+
lineHeight: {
|
|
27
|
+
tight: 1.25,
|
|
28
|
+
normal: 1.5,
|
|
29
|
+
relaxed: 1.625,
|
|
30
|
+
},
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
export default TYPOGRAPHY_TOKENS;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI Design Tokens for VertiGIS Studio Web SDK
|
|
3
|
+
* Maps official VertiGIS CSS custom properties with safe WCAG AA fallbacks.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const UI_TOKENS = {
|
|
7
|
+
surface: {
|
|
8
|
+
primary: "var(--primaryBackground, #ffffff)",
|
|
9
|
+
secondary: "var(--secondaryBackground, #f5f5f5)",
|
|
10
|
+
overlay: "var(--overlayBackground, rgba(0, 0, 0, 0.5))",
|
|
11
|
+
inverse: "var(--primaryForeground, #212121)",
|
|
12
|
+
},
|
|
13
|
+
text: {
|
|
14
|
+
primary: "var(--primaryForeground, #212121)",
|
|
15
|
+
secondary: "var(--secondaryForeground, #666666)",
|
|
16
|
+
disabled: "var(--disabledForeground, #9e9e9e)",
|
|
17
|
+
inverse: "var(--primaryBackground, #ffffff)",
|
|
18
|
+
},
|
|
19
|
+
border: {
|
|
20
|
+
primary: "var(--primaryBorder, #e0e0e0)",
|
|
21
|
+
secondary: "var(--secondaryBorder, #eeeeee)",
|
|
22
|
+
focus: "var(--focusBorder, #007ac2)",
|
|
23
|
+
},
|
|
24
|
+
accent: {
|
|
25
|
+
primary: "var(--primaryAccent, #007ac2)",
|
|
26
|
+
hover: "var(--primaryAccentHover, #005a91)",
|
|
27
|
+
light: "var(--primaryAccentLight, #e1f5fe)",
|
|
28
|
+
contrastText: "var(--buttonForeground, #ffffff)",
|
|
29
|
+
},
|
|
30
|
+
control: {
|
|
31
|
+
buttonBackground: "var(--emphasizedButtonBackground, var(--primaryAccent, #007ac2))",
|
|
32
|
+
buttonForeground: "var(--buttonForeground, #ffffff)",
|
|
33
|
+
itemHover: "var(--itemHoverBackground, rgba(0, 0, 0, 0.04))",
|
|
34
|
+
itemSelected: "var(--itemSelectedBackground, rgba(0, 122, 194, 0.12))",
|
|
35
|
+
},
|
|
36
|
+
status: {
|
|
37
|
+
errorBg: "var(--alertRedBackground, #fdecea)",
|
|
38
|
+
errorFg: "var(--alertRedForeground, #d32f2f)",
|
|
39
|
+
errorBorder: "var(--alertRedBorder, #f5c2c7)",
|
|
40
|
+
successBg: "var(--alertGreenBackground, #edf7ed)",
|
|
41
|
+
successFg: "var(--alertGreenForeground, #2e7d32)",
|
|
42
|
+
successBorder: "var(--alertGreenBorder, #c3e6cb)",
|
|
43
|
+
warningBg: "var(--alertAmberBackground, #fff4e5)",
|
|
44
|
+
warningFg: "var(--alertAmberForeground, #ed6c02)",
|
|
45
|
+
warningBorder: "var(--alertAmberBorder, #ffeeba)",
|
|
46
|
+
infoBg: "var(--alertGrayBackground, #e8f4fd)",
|
|
47
|
+
infoFg: "var(--alertGrayForeground, #0288d1)",
|
|
48
|
+
infoBorder: "var(--alertGrayBorder, #bee5eb)",
|
|
49
|
+
},
|
|
50
|
+
shape: {
|
|
51
|
+
borderRadius: "var(--borderRadius, 4px)",
|
|
52
|
+
borderRadiusSm: "var(--borderRadiusSm, 2px)",
|
|
53
|
+
borderRadiusLg: "var(--borderRadiusLg, 8px)",
|
|
54
|
+
borderRadiusPill: "9999px",
|
|
55
|
+
shadowPrimary: "var(--shadowPrimary, 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24))",
|
|
56
|
+
shadowElevated: "var(--shadowElevated, 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23))",
|
|
57
|
+
},
|
|
58
|
+
} as const;
|
|
59
|
+
|
|
60
|
+
export default UI_TOKENS;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./themeDetection";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export function calculatePerceivedLuminance(r: number, g: number, b: number): number {
|
|
2
|
+
const normalize = (val: number) => {
|
|
3
|
+
const s = val / 255;
|
|
4
|
+
return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
|
|
5
|
+
};
|
|
6
|
+
return 0.2126 * normalize(r) + 0.7152 * normalize(g) + 0.0722 * normalize(b);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function parseRgbComponents(colorStr: string): [number, number, number] | null {
|
|
10
|
+
if (!colorStr) return null;
|
|
11
|
+
const clean = colorStr.trim().toLowerCase();
|
|
12
|
+
|
|
13
|
+
if (clean.startsWith("#")) {
|
|
14
|
+
const hex = clean.slice(1);
|
|
15
|
+
if (hex.length === 3) {
|
|
16
|
+
return [parseInt(hex[0] + hex[0], 16), parseInt(hex[1] + hex[1], 16), parseInt(hex[2] + hex[2], 16)];
|
|
17
|
+
}
|
|
18
|
+
if (hex.length >= 6) {
|
|
19
|
+
return [parseInt(hex.slice(0, 2), 16), parseInt(hex.slice(2, 4), 16), parseInt(hex.slice(4, 6), 16)];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const match = clean.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);
|
|
24
|
+
if (match) {
|
|
25
|
+
if (match[4] !== undefined && parseFloat(match[4]) === 0) return null;
|
|
26
|
+
return [parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10)];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isDarkTheme(): boolean {
|
|
33
|
+
if (typeof window === "undefined" || typeof document === "undefined") return false;
|
|
34
|
+
const docEl = document.documentElement;
|
|
35
|
+
const body = document.body;
|
|
36
|
+
|
|
37
|
+
if (docEl.getAttribute("data-theme") === "dark" || body.getAttribute("data-theme") === "dark") return true;
|
|
38
|
+
|
|
39
|
+
const darkClasses = ["dark", "theme-dark", "vsw-theme-dark"];
|
|
40
|
+
for (const cls of darkClasses) {
|
|
41
|
+
if (docEl.classList.contains(cls) || body.classList.contains(cls)) return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const testTarget = document.querySelector(".vsw-app") || body || docEl;
|
|
46
|
+
const style = window.getComputedStyle(testTarget);
|
|
47
|
+
const bgVal = style.getPropertyValue("--primaryBackground").trim();
|
|
48
|
+
if (bgVal) {
|
|
49
|
+
const rgb = parseRgbComponents(bgVal);
|
|
50
|
+
if (rgb) return calculatePerceivedLuminance(rgb[0], rgb[1], rgb[2]) < 0.5;
|
|
51
|
+
}
|
|
52
|
+
} catch {}
|
|
53
|
+
|
|
54
|
+
if (window.matchMedia?.("(prefers-color-scheme: dark)").matches) return true;
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal enabledelayedexpansion
|
|
3
|
+
echo ========================================================
|
|
4
|
+
echo VertiGIS Studio Web SDK Development Server
|
|
5
|
+
echo Serving: https://localtest.me:3001 & https://localhost:3000
|
|
6
|
+
echo ========================================================
|
|
7
|
+
for %%P in (3001 3000) do (
|
|
8
|
+
for /f "tokens=5" %%a in ('netstat -aon ^| findstr ":%%P " ^| findstr "LISTENING"') do (
|
|
9
|
+
echo Terminating PID %%a on port %%P...
|
|
10
|
+
taskkill /F /PID %%a >nul 2>&1
|
|
11
|
+
)
|
|
12
|
+
)
|
|
13
|
+
if exist "certs\generate-cert.bat" (
|
|
14
|
+
call "certs\generate-cert.bat"
|
|
15
|
+
)
|
|
16
|
+
echo Starting development server (npm start)...
|
|
17
|
+
npm start
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
echo "========================================================"
|
|
5
|
+
echo " VertiGIS Studio Web SDK Development Server"
|
|
6
|
+
echo " Serving: https://localtest.me:3001 & https://localhost:3000"
|
|
7
|
+
echo "========================================================"
|
|
8
|
+
|
|
9
|
+
# Free both port 3001 and port 3000 if occupied
|
|
10
|
+
for p in 3001 3000; do
|
|
11
|
+
PID=$(lsof -ti :$p 2>/dev/null || true)
|
|
12
|
+
if [ -n "$PID" ]; then
|
|
13
|
+
echo "Killing stale process on port $p (PID $PID)..."
|
|
14
|
+
kill -9 $PID 2>/dev/null || true
|
|
15
|
+
fi
|
|
16
|
+
done
|
|
17
|
+
|
|
18
|
+
if [ -f "./certs/generate-cert.sh" ]; then
|
|
19
|
+
bash ./certs/generate-cert.sh
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
echo "Starting development server (npm start)..."
|
|
23
|
+
npm start
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import https from "node:https";
|
|
4
|
+
import defaultWebpackConfig, { merge } from "@vertigis/web-sdk/config/webpack.config.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Starts a lightweight zero-dependency dual-port forwarder on port 3000 forwarding to port 3001.
|
|
8
|
+
* This makes the extension simultaneously reachable at both https://localtest.me:3001 and
|
|
9
|
+
* https://localhost:3000 (preventing CORS / port mismatch issues in ArcGIS Enterprise/Portal).
|
|
10
|
+
*/
|
|
11
|
+
let bridgeStarted = false;
|
|
12
|
+
function setupDualPortBridge(targetPort = 3001, bridgePort = 3000) {
|
|
13
|
+
if (bridgeStarted) return;
|
|
14
|
+
bridgeStarted = true;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const certPath = path.resolve(process.cwd(), "certs/cert.pem");
|
|
18
|
+
const keyPath = path.resolve(process.cwd(), "certs/key.pem");
|
|
19
|
+
if (!fs.existsSync(certPath) || !fs.existsSync(keyPath)) return;
|
|
20
|
+
|
|
21
|
+
const options = {
|
|
22
|
+
cert: fs.readFileSync(certPath),
|
|
23
|
+
key: fs.readFileSync(keyPath),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const server = https.createServer(options, (req, res) => {
|
|
27
|
+
const clientReq = https.request(
|
|
28
|
+
{
|
|
29
|
+
hostname: "127.0.0.1",
|
|
30
|
+
port: targetPort,
|
|
31
|
+
path: req.url,
|
|
32
|
+
method: req.method,
|
|
33
|
+
headers: { ...req.headers, host: `localhost:${targetPort}` },
|
|
34
|
+
rejectUnauthorized: false,
|
|
35
|
+
},
|
|
36
|
+
clientRes => {
|
|
37
|
+
res.writeHead(clientRes.statusCode || 200, {
|
|
38
|
+
...clientRes.headers,
|
|
39
|
+
"Access-Control-Allow-Origin": "*",
|
|
40
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
41
|
+
"Access-Control-Allow-Headers": "*",
|
|
42
|
+
"Access-Control-Allow-Private-Network": "true",
|
|
43
|
+
});
|
|
44
|
+
clientRes.pipe(res);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
clientReq.on("error", () => {
|
|
49
|
+
res.writeHead(502);
|
|
50
|
+
res.end("Bridge connection error");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
req.pipe(clientReq);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
server.on("upgrade", (req, socket) => {
|
|
57
|
+
const clientReq = https.request({
|
|
58
|
+
hostname: "127.0.0.1",
|
|
59
|
+
port: targetPort,
|
|
60
|
+
path: req.url,
|
|
61
|
+
method: req.method,
|
|
62
|
+
headers: req.headers,
|
|
63
|
+
rejectUnauthorized: false,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
clientReq.on("upgrade", (clientRes, clientSocket) => {
|
|
67
|
+
socket.write(
|
|
68
|
+
"HTTP/1.1 101 Switching Protocols\r\n" +
|
|
69
|
+
Object.entries(clientRes.headers)
|
|
70
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
71
|
+
.join("\r\n") +
|
|
72
|
+
"\r\n\r\n"
|
|
73
|
+
);
|
|
74
|
+
clientSocket.pipe(socket).pipe(clientSocket);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
clientReq.on("error", () => socket.destroy());
|
|
78
|
+
clientReq.end();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
server.listen(bridgePort, "0.0.0.0", () => {
|
|
82
|
+
console.log(
|
|
83
|
+
`<i> [dual-port-bridge] Also available at https://localhost:${bridgePort} & https://localtest.me:${bridgePort}`
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
server.on("error", err => {
|
|
88
|
+
console.log(
|
|
89
|
+
`<i> [dual-port-bridge] Port ${bridgePort} unavailable (${err.message}). Serving exclusively on :${targetPort}`
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
} catch {
|
|
93
|
+
// Silently skip if port forwarder cannot be initialized
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default merge(defaultWebpackConfig, {
|
|
98
|
+
devServer: {
|
|
99
|
+
allowedHosts: "all",
|
|
100
|
+
host: "0.0.0.0",
|
|
101
|
+
port: 3001,
|
|
102
|
+
server: "https",
|
|
103
|
+
headers: {
|
|
104
|
+
"Access-Control-Allow-Origin": "*",
|
|
105
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
106
|
+
"Access-Control-Allow-Headers": "*",
|
|
107
|
+
"Access-Control-Allow-Private-Network": "true",
|
|
108
|
+
},
|
|
109
|
+
client: {
|
|
110
|
+
webSocketURL: {
|
|
111
|
+
hostname: "localtest.me",
|
|
112
|
+
pathname: "/ws",
|
|
113
|
+
port: 3001,
|
|
114
|
+
protocol: "wss",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
onListening: function () {
|
|
118
|
+
setupDualPortBridge(3001, 3000);
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
});
|