@geosynk/vertigis-web-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +210 -0
  3. package/bin/vertigis-web-sdk.js +17 -0
  4. package/config/eslint.config.js +201 -0
  5. package/config/eslint.config.js.template +11 -0
  6. package/config/tsconfig.json +3 -0
  7. package/config/tsconfig.json.template +9 -0
  8. package/config/webpack.config.js +54 -0
  9. package/lib/index.ejs +133 -0
  10. package/package.json +72 -0
  11. package/scripts/build.js +48 -0
  12. package/scripts/create.js +113 -0
  13. package/scripts/start.js +41 -0
  14. package/scripts/upgrade.js +12 -0
  15. package/template/.prettierignore +1 -0
  16. package/template/.prettierrc +6 -0
  17. package/template/.vscode/extensions.json +3 -0
  18. package/template/README.md +51 -0
  19. package/template/app/app.json +1067 -0
  20. package/template/app/layout.xml +22 -0
  21. package/template/gitignore +2 -0
  22. package/template/package.json +27 -0
  23. package/template/src/components/PointsOfInterest/PointOfInterest.css +6 -0
  24. package/template/src/components/PointsOfInterest/PointOfInterest.tsx +50 -0
  25. package/template/src/components/PointsOfInterest/PointOfInterestModel.ts +13 -0
  26. package/template/src/components/PointsOfInterest/PointsOfInterest.css +4 -0
  27. package/template/src/components/PointsOfInterest/PointsOfInterest.tsx +44 -0
  28. package/template/src/components/PointsOfInterest/PointsOfInterestModel.ts +127 -0
  29. package/template/src/components/PointsOfInterest/index.ts +4 -0
  30. package/template/src/index.ts +26 -0
  31. package/template/webpack.config.js +5 -0
  32. package/template-custom/AGENTS.md +47 -0
  33. package/template-custom/app/app.json +1067 -0
  34. package/template-custom/app/layout.xml +22 -0
  35. package/template-custom/build.bat +11 -0
  36. package/template-custom/build.sh +15 -0
  37. package/template-custom/certs/generate-cert.bat +14 -0
  38. package/template-custom/certs/generate-cert.sh +14 -0
  39. package/template-custom/src/components/CustomWidget/CustomWidget.tsx +70 -0
  40. package/template-custom/src/components/CustomWidget/CustomWidgetModel.ts +15 -0
  41. package/template-custom/src/components/CustomWidget/components/CustomWidgetErrorBoundary.tsx +57 -0
  42. package/template-custom/src/components/CustomWidget/index.ts +3 -0
  43. package/template-custom/src/hooks/index.ts +1 -0
  44. package/template-custom/src/hooks/useIsDarkTheme.ts +56 -0
  45. package/template-custom/src/index.ts +20 -0
  46. package/template-custom/src/tokens/index.ts +24 -0
  47. package/template-custom/src/tokens/typography.ts +33 -0
  48. package/template-custom/src/tokens/ui.ts +60 -0
  49. package/template-custom/src/utils/index.ts +1 -0
  50. package/template-custom/src/utils/themeDetection.ts +56 -0
  51. package/template-custom/start.bat +17 -0
  52. package/template-custom/start.sh +23 -0
  53. package/template-custom/webpack.config.js +121 -0
  54. package/test/index.js +22 -0
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@geosynk/vertigis-web-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Enterprise SDK for extending VertiGIS Studio Web",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/davekazemi/vertigis-web-sdk.git"
11
+ },
12
+ "author": "VertiGIS Ltd. / Davood Kazemi (Geosynk)",
13
+ "license": "MIT",
14
+ "bugs": {
15
+ "url": "https://github.com/davekazemi/vertigis-web-sdk/issues"
16
+ },
17
+ "homepage": "https://github.com/davekazemi/vertigis-web-sdk#readme",
18
+ "files": [
19
+ "bin",
20
+ "config",
21
+ "lib",
22
+ "scripts",
23
+ "template",
24
+ "template-custom",
25
+ "test"
26
+ ],
27
+ "type": "module",
28
+ "engines": {
29
+ "node": ">=18",
30
+ "npm": ">=8"
31
+ },
32
+ "bin": {
33
+ "vertigis-web-sdk": "bin/vertigis-web-sdk.js"
34
+ },
35
+ "scripts": {
36
+ "create": "cross-env SDK_LOCAL_DEV=true node bin/vertigis-web-sdk.js create",
37
+ "test": "node ./test/index.js",
38
+ "prettier": "prettier --write \"**/*.json\" \"**/*.js\" \"**/*.ts\" \"**/*.tsx\""
39
+ },
40
+ "dependencies": {
41
+ "@vertigis/sdk-library": "~2.1.0",
42
+ "html-webpack-plugin": "^5.6.4",
43
+ "webpack-merge": "~6.0.1"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "~22.13.14",
47
+ "@vertigis/web": "^5.42.0",
48
+ "conventional-changelog-conventionalcommits": "7.0.2",
49
+ "cross-env": "7.0.3",
50
+ "eslint": "^9.37.0",
51
+ "eslint-import-resolver-typescript": "^4.4.4",
52
+ "execa": "^9.6.0",
53
+ "lint-staged": "~15.5.0",
54
+ "node-fetch": "^2.7.0",
55
+ "prettier": "3.2.5",
56
+ "simple-git-hooks": "~2.12.1",
57
+ "typescript": "~5.6.3"
58
+ },
59
+ "simple-git-hooks": {
60
+ "pre-commit": "npx lint-staged"
61
+ },
62
+ "lint-staged": {
63
+ "*.{js,json,ts,tsx,md,xml}": "prettier --write"
64
+ },
65
+ "allowScripts": {
66
+ "@mui/x-telemetry": false,
67
+ "@vaadin/vaadin-usage-statistics": false,
68
+ "playwright-chromium": true,
69
+ "simple-git-hooks": false,
70
+ "unrs-resolver": false
71
+ }
72
+ }
@@ -0,0 +1,48 @@
1
+ // @ts-check
2
+ "use strict";
3
+
4
+ import { existsSync } from "node:fs";
5
+ import path from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+
8
+ import paths from "@vertigis/sdk-library/config/paths.js";
9
+ import libPackage from "@vertigis/sdk-library/package.json" with { type: "json" };
10
+ import sdkBuild from "@vertigis/sdk-library/scripts/build.js";
11
+ import webPackage from "@vertigis/web/package.json" with { type: "json" };
12
+
13
+ import sdkPackage from "../package.json" with { type: "json" };
14
+
15
+ // These needs to be set prior to importing the webpack config. The only way to
16
+ // do that with ES modules is by using a dynamic import.
17
+ process.env.BABEL_ENV = "production";
18
+ process.env.NODE_ENV = "production";
19
+
20
+ // This information will be included in a banner comment.
21
+ process.env.SDK_PLATFORM = "web";
22
+ process.env.SDK_VERSION = sdkPackage.version;
23
+ process.env.SDK_LIBRARY_VERSION = libPackage.version;
24
+ process.env.PLATFORM_VERSION = webPackage.version;
25
+
26
+ // Load the webpack.config.js from the project folder if it exists.
27
+ const localWebPackPath = path.join(paths.projRoot, "webpack.config.js");
28
+ const webpackConfigUrl = existsSync(localWebPackPath)
29
+ ? pathToFileURL(localWebPackPath).href
30
+ : "../config/webpack.config.js";
31
+
32
+ const { default: webpackConfig } = await import(webpackConfigUrl);
33
+
34
+ // Makes the script crash on unhandled rejections instead of silently
35
+ // ignoring them. In the future, promise rejections that are not handled will
36
+ // terminate the Node.js process with a non-zero exit code.
37
+ process.on("unhandledRejection", err => {
38
+ throw err;
39
+ });
40
+
41
+ try {
42
+ await sdkBuild(webpackConfig);
43
+ } catch (e) {
44
+ if (e instanceof Error && e.message) {
45
+ console.error(e);
46
+ }
47
+ process.exit(1);
48
+ }
@@ -0,0 +1,113 @@
1
+ // @ts-check
2
+ "use strict";
3
+
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { execSync } from "node:child_process";
8
+
9
+ import sdkCreate from "@vertigis/sdk-library/scripts/create.js";
10
+
11
+ // Root of the SDK installation where the template is found.
12
+ const dirName = path.dirname(fileURLToPath(import.meta.url));
13
+ const rootDir = path.join(dirName, "..");
14
+
15
+ // Target directory name.
16
+ const createIndex = process.argv.findIndex(s => s.includes("create"));
17
+ const directoryName = process.argv[createIndex + 1];
18
+
19
+ if (!directoryName) {
20
+ console.error("Please specify the project directory name: vertigis-web-sdk create <project-name>");
21
+ process.exit(1);
22
+ }
23
+
24
+ const targetPath = path.resolve(directoryName);
25
+
26
+ // 1. Run standard VertiGIS base scaffolding
27
+ sdkCreate(rootDir, directoryName, "web");
28
+
29
+ // 2. Apply Enterprise Template Custom Overlay
30
+ const customTemplateDir = path.join(rootDir, "template-custom");
31
+ if (fs.existsSync(customTemplateDir) && fs.existsSync(targetPath)) {
32
+ console.log("\n[ENTERPRISE] Applying VertiGIS Studio Web SDK Enterprise Template Overlay...");
33
+ fs.cpSync(customTemplateDir, targetPath, { recursive: true, force: true });
34
+
35
+ // Ensure shell scripts are executable on POSIX systems
36
+ if (process.platform !== "win32") {
37
+ const executables = [
38
+ path.join(targetPath, "certs/generate-cert.sh"),
39
+ path.join(targetPath, "start.sh"),
40
+ path.join(targetPath, "build.sh"),
41
+ ];
42
+ for (const exe of executables) {
43
+ if (fs.existsSync(exe)) {
44
+ try {
45
+ fs.chmodSync(exe, 0o755);
46
+ } catch {
47
+ // Ignore chmod failures
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ // Configure build scripts with user-selected project name
54
+ const projectName = path.basename(targetPath);
55
+ const buildScripts = [
56
+ path.join(targetPath, "build.sh"),
57
+ path.join(targetPath, "build.bat"),
58
+ ];
59
+ for (const bs of buildScripts) {
60
+ if (fs.existsSync(bs)) {
61
+ try {
62
+ const scriptContent = fs.readFileSync(bs, "utf-8");
63
+ fs.writeFileSync(bs, scriptContent.replace(/__PROJECT_NAME__/g, projectName), "utf-8");
64
+ } catch {
65
+ // Ignore replacement failure
66
+ }
67
+ }
68
+ }
69
+
70
+ // 3. Merge enterprise dependencies into package.json
71
+ const pkgPath = path.join(targetPath, "package.json");
72
+ if (fs.existsSync(pkgPath)) {
73
+ try {
74
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
75
+ pkg.dependencies = pkg.dependencies || {};
76
+ pkg.dependencies["@mui/material"] = "^5.15.0";
77
+ pkg.dependencies["@emotion/react"] = "^11.11.0";
78
+ pkg.dependencies["@emotion/styled"] = "^11.11.0";
79
+
80
+ pkg.scripts = pkg.scripts || {};
81
+ pkg.scripts["cert:gen"] = "bash ./certs/generate-cert.sh";
82
+
83
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 4) + "\n", "utf-8");
84
+ console.log("[ENTERPRISE] Added enterprise dependencies (@mui/material, @emotion/*) to package.json");
85
+ } catch (e) {
86
+ console.warn("[WARN] Failed to merge enterprise package.json dependencies:", e);
87
+ }
88
+ }
89
+
90
+ // 4. Auto-generate development SSL certificate if openssl is available
91
+ const certScript = path.join(targetPath, "certs", process.platform === "win32" ? "generate-cert.bat" : "generate-cert.sh");
92
+ if (fs.existsSync(certScript)) {
93
+ try {
94
+ console.log("[ENTERPRISE] Checking development SSL certificate...");
95
+ if (process.platform === "win32") {
96
+ execSync(`cmd /c "${certScript}"`, { stdio: "inherit", cwd: targetPath });
97
+ } else {
98
+ execSync(`bash "${certScript}"`, { stdio: "inherit", cwd: targetPath });
99
+ }
100
+ } catch {
101
+ console.log("[INFO] Certificate generation skipped (OpenSSL will run automatically on first start).");
102
+ }
103
+ }
104
+
105
+ console.log("\n================================================================================");
106
+ console.log(" [ENTERPRISE] VertiGIS Studio Web Extension successfully configured!");
107
+ console.log(" - Centralized Design Tokens: src/tokens/ (100% safe fallbacks & color-mix)");
108
+ console.log(" - Dynamic Dark/Light Theme: src/hooks/useIsDarkTheme.ts & src/utils/");
109
+ console.log(" - Anti-God Component: src/components/CustomWidget/ (ErrorBoundary)");
110
+ console.log(" - Development Scripts: start.sh / start.bat, build.sh / build.bat");
111
+ console.log(" - AI Directives: AGENTS.md pre-configured for coding assistants");
112
+ console.log("================================================================================\n");
113
+ }
@@ -0,0 +1,41 @@
1
+ // @ts-check
2
+ "use strict";
3
+
4
+ import { existsSync } from "node:fs";
5
+ import path from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+
8
+ import paths from "@vertigis/sdk-library/config/paths.js";
9
+ import libPackage from "@vertigis/sdk-library/package.json" with { type: "json" };
10
+ import sdkStart from "@vertigis/sdk-library/scripts/start.js";
11
+ import webPackage from "@vertigis/web/package.json" with { type: "json" };
12
+
13
+ import sdkPackage from "../package.json" with { type: "json" };
14
+
15
+ // These needs to be set prior to importing the webpack config. The only way to
16
+ // do that with ES modules is by using a dynamic import.
17
+ process.env.BABEL_ENV = "development";
18
+ process.env.NODE_ENV = "development";
19
+
20
+ // This information will be included in a banner comment.
21
+ process.env.SDK_PLATFORM = "web";
22
+ process.env.SDK_VERSION = sdkPackage.version;
23
+ process.env.SDK_LIBRARY_VERSION = libPackage.version;
24
+ process.env.PLATFORM_VERSION = webPackage.version;
25
+
26
+ // Load the webpack.config.js from the project folder if it exists.
27
+ const localWebPackPath = path.join(paths.projRoot, "webpack.config.js");
28
+ const webpackConfigUrl = existsSync(localWebPackPath)
29
+ ? pathToFileURL(localWebPackPath).href
30
+ : "../config/webpack.config.js";
31
+
32
+ const { default: webpackConfig } = await import(webpackConfigUrl);
33
+
34
+ // Makes the script crash on unhandled rejections instead of silently
35
+ // ignoring them. In the future, promise rejections that are not handled will
36
+ // terminate the Node.js process with a non-zero exit code.
37
+ process.on("unhandledRejection", err => {
38
+ throw err;
39
+ });
40
+
41
+ sdkStart(webpackConfig, "web");
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ "use strict";
3
+
4
+ import * as path from "path";
5
+ import { fileURLToPath } from "url";
6
+
7
+ import sdkUpgrade from "@vertigis/sdk-library/scripts/upgrade.js";
8
+
9
+ const dirName = path.dirname(fileURLToPath(import.meta.url));
10
+ const ownPath = path.resolve(dirName, "..");
11
+
12
+ sdkUpgrade(ownPath, "web");
@@ -0,0 +1 @@
1
+ package-lock.json
@@ -0,0 +1,6 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "printWidth": 120,
4
+ "tabWidth": 4,
5
+ "trailingComma": "es5"
6
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["dbaeumer.vscode-eslint"]
3
+ }
@@ -0,0 +1,51 @@
1
+ This project was bootstrapped with the [VertiGIS Studio Web SDK](https://github.com/vertigis/vertigis-web-sdk).
2
+
3
+ ## Available Scripts
4
+
5
+ In the project directory, you can run:
6
+
7
+ ### `npm start`
8
+
9
+ Runs the project in development mode. Open [http://localhost:3001](http://localhost:3001) to view it in the browser.
10
+
11
+ The page will automatically reload if you make changes to the code. You will see build errors and warnings in the console.
12
+
13
+ #### Command Line Arguments
14
+
15
+ The `start` script supports the following optional arguments that are passed along to [webpack-dev-server](https://github.com/webpack/webpack-dev-server/tree/main?tab=readme-ov-file).
16
+
17
+ - `--allowed-hosts` - Default is `all`. [[docs](https://github.com/webpack/webpack-dev-server/blob/main/DOCUMENTATION-v4.md#devserverallowedhosts)]
18
+ - `--host` - Default is `localhost`. [[docs](https://github.com/webpack/webpack-dev-server/blob/main/DOCUMENTATION-v4.md#devserverhost)]
19
+ - `--port` - Default is `3001`. [[docs](https://github.com/webpack/webpack-dev-server/blob/main/DOCUMENTATION-v4.md#devserverport)]
20
+ - `--type` - Server type. Default is `http` for localhost and `https` for all other endpoints. [[docs](https://github.com/webpack/webpack-dev-server/blob/main/DOCUMENTATION-v4.md#devserverserver)]
21
+ - `--key` - Provide a private key in PEM format. [[docs](https://developers.vertigisstudio.com/docs/workflow/sdk-web-overview/#configuring-a-https-certificate)]
22
+ - `--cert` - Provide a certificate chain in PEM format. [[docs](https://developers.vertigisstudio.com/docs/workflow/sdk-web-overview/#configuring-a-https-certificate)]
23
+ - `--ca` - Override the trusted CA certificates. [[docs](https://developers.vertigisstudio.com/docs/workflow/sdk-web-overview/#configuring-a-https-certificate)]
24
+
25
+ NOTE: It is important to add `--` before the list of parameters.
26
+
27
+ Example:
28
+
29
+ ```sh
30
+ npm start -- --host 0.0.0.0 --allowed-hosts auto
31
+ ```
32
+
33
+ ### `npm run build`
34
+
35
+ Builds the library for production to the `build` folder. It optimizes the build for the best performance.
36
+
37
+ Your custom library is now ready to be deployed!
38
+
39
+ See the [section about deployment](https://developers.vertigis.com/docs/web/sdk-deployment/) in the [Developer Center](https://developers.vertigis.com/docs/web/overview/) for more information.
40
+
41
+ ## Upgrading
42
+
43
+ To update a previously created project to the latest version of the Web SDK, navigate to the root directory of that project and run
44
+
45
+ ```sh
46
+ npx @vertigis/web-sdk@latest upgrade
47
+ ```
48
+
49
+ ## Learn More
50
+
51
+ Find [further documentation on the SDK](https://developers.vertigis.com/docs/web/sdk-overview/) on the [VertiGIS Studio Developer Center](https://developers.vertigis.com/docs/web/overview/)