ketatlas 0.1.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 (51) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE.md +10 -0
  4. package/README.md +130 -0
  5. package/assets/INTER-LICENSE +93 -0
  6. package/assets/KETJS-LICENSE +21 -0
  7. package/assets/LUCIDE-LICENSE +43 -0
  8. package/assets/design-system.lock.json +56 -0
  9. package/assets/inter-latin-wght-normal.woff2 +0 -0
  10. package/assets/inter-vietnamese-wght-normal.woff2 +0 -0
  11. package/bin/audit.js +116 -0
  12. package/bin/ketatlas.js +148 -0
  13. package/bin/server.js +93 -0
  14. package/bin/viewer.js +20 -0
  15. package/docs/architecture.md +57 -0
  16. package/docs/authoring.md +49 -0
  17. package/docs/cli.md +70 -0
  18. package/docs/configuration.md +65 -0
  19. package/docs/integration.md +108 -0
  20. package/docs/migration.md +35 -0
  21. package/docs/releasing.md +40 -0
  22. package/package.json +59 -0
  23. package/schema.json +187 -0
  24. package/src/config.js +196 -0
  25. package/src/icons.js +23 -0
  26. package/src/index.d.ts +106 -0
  27. package/src/index.js +679 -0
  28. package/src/layout.js +103 -0
  29. package/src/template.js +38 -0
  30. package/styles/design-system.css +2838 -0
  31. package/styles/design-system.document.css +2838 -0
  32. package/styles/fonts.css +17 -0
  33. package/styles/ketatlas.css +992 -0
  34. package/templates/basic/README.md +14 -0
  35. package/templates/basic/atlas.json +45 -0
  36. package/templates/basic/ketatlas.schema.json +187 -0
  37. package/templates/basic/screens/done.html +18 -0
  38. package/templates/basic/screens/screen.css +48 -0
  39. package/templates/basic/screens/welcome.html +21 -0
  40. package/templates/basic/styles/LICENSE +21 -0
  41. package/templates/basic/styles/design-system.css +2838 -0
  42. package/templates/process/README.md +14 -0
  43. package/templates/process/atlas.json +83 -0
  44. package/templates/process/ketatlas.schema.json +187 -0
  45. package/templates/web/README.md +14 -0
  46. package/templates/web/atlas.json +77 -0
  47. package/templates/web/ketatlas.schema.json +187 -0
  48. package/templates/web/screens/demo.css +255 -0
  49. package/templates/web/screens/portal.html +41 -0
  50. package/templates/web/styles/LICENSE +21 -0
  51. package/templates/web/styles/design-system.css +2838 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — Initial scaffold
4
+
5
+ - Standalone `ketatlas scaffold`, `serve <atlas.json>`, `audit`, and `validate` commands.
6
+ - Basic, web and screenless process templates with a local configuration schema.
7
+ - English HTML viewer with pan, zoom, touch pinch, search, minimap, labelled arrows and interactive previews.
8
+ - Mobile and desktop viewport sizes, repeated screen states and process/external nodes.
9
+ - Isolated JavaScript embedding API, lifecycle methods, events and TypeScript declarations.
10
+ - Canonical KetJS design system with pinned provenance and offline assets.
11
+ - Static audits, CLI/server tests, browser evidence and packed-install verification.
12
+
13
+ This entry describes the source version; it does not confirm publication to npm.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KETVIET JSC, Vietnam
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/NOTICE.md ADDED
@@ -0,0 +1,10 @@
1
+ # Third-party notices
2
+
3
+ KetAtlas is maintained by KETVIET JSC under the MIT license.
4
+
5
+ - The viewer originated from KétSuite's HTML flow-map prototype, then was extracted into this independent package. No mobile app code or business data is bundled.
6
+ - Default tokens and UI primitives: `@ketvietlab/design-system` from [KetJS](https://github.com/ketvietlab/ketjs), MIT. Exact source revision and file hashes are recorded in `assets/design-system.lock.json`. Generated output only adapts root selectors to a Shadow DOM host; token values are unchanged. See `assets/KETJS-LICENSE`.
7
+ - Inter Variable: `@fontsource-variable/inter` 5.3.0, SIL Open Font License. See `assets/INTER-LICENSE`.
8
+ - Icons: Lucide 1.40.0, ISC. See `assets/LUCIDE-LICENSE`.
9
+
10
+ The default theme and these notices are included in generated projects and npm archives.
package/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # KetAtlas
2
+
3
+ **Scaffold, serve, and audit interactive HTML workflow maps.**
4
+
5
+ Turn a JSON file and your existing HTML screens into a canvas you can drag, zoom, and explore. Connect screens with labelled arrows, model decisions and recovery paths, and open the real HTML to try a step. The same tool supports mobile screens, web pages, and processes with no screens at all.
6
+
7
+ KetAtlas has an English UI, zero runtime npm dependencies, and no build step. Node.js **22+** is needed for the CLI. Viewers use native ES modules and run on an HTTP server.
8
+
9
+ ## Start from this repository
10
+
11
+ ```sh
12
+ git clone git@github.com:ketvietlab/ketatlas.git
13
+ cd ketatlas
14
+ npm ci
15
+ npm run dev
16
+ ```
17
+
18
+ Open **http://127.0.0.1:4178**. The playground includes mobile sign-in, a desktop approval flow, and a fulfilment process.
19
+
20
+ Create your own project:
21
+
22
+ ```sh
23
+ node bin/ketatlas.js scaffold ../my-atlas
24
+ node bin/ketatlas.js serve ../my-atlas/atlas.json
25
+ node bin/ketatlas.js audit ../my-atlas/atlas.json --strict
26
+ ```
27
+
28
+ No wrapper HTML is needed. Edit `atlas.json` and the files under `screens/`, then refresh the browser.
29
+
30
+ ## Run through npx
31
+
32
+ Run immediately from a local checkout, including before the first push or npm release:
33
+
34
+ ```sh
35
+ npx --yes --package ~/dev/ketatlas ketatlas scaffold my-atlas
36
+ npx --yes --package ~/dev/ketatlas ketatlas serve my-atlas/atlas.json
37
+ npx --yes --package ~/dev/ketatlas ketatlas audit my-atlas/atlas.json --strict
38
+ ```
39
+
40
+ Replace `~/dev/ketatlas` with your checkout path. This uses the local package, not an npm registry release.
41
+
42
+ Once the source has been pushed to GitHub, run without cloning it yourself:
43
+
44
+ ```sh
45
+ npx --yes --package=github:ketvietlab/ketatlas ketatlas scaffold my-atlas
46
+ npx --yes --package=github:ketvietlab/ketatlas ketatlas serve my-atlas/atlas.json
47
+ npx --yes --package=github:ketvietlab/ketatlas ketatlas audit my-atlas/atlas.json
48
+ ```
49
+
50
+ After `ketatlas` has been published to npm, the short form is:
51
+
52
+ ```sh
53
+ npx ketatlas scaffold my-atlas --template web
54
+ npx ketatlas serve my-atlas/atlas.json
55
+ npx ketatlas audit my-atlas/atlas.json --strict
56
+ ```
57
+
58
+ The repository does not imply an npm release. Package installation is tested from the actual `.tgz` archive; release instructions are in [Releasing](docs/releasing.md).
59
+
60
+ ## One file describes the journey
61
+
62
+ ```json
63
+ {
64
+ "version": 1,
65
+ "title": "Customer onboarding",
66
+ "screens": [
67
+ { "id": "welcome", "title": "Welcome", "url": "./screens/welcome.html" },
68
+ { "id": "home", "title": "Workspace", "url": "./screens/home.html" }
69
+ ],
70
+ "flows": [
71
+ {
72
+ "id": "onboarding",
73
+ "title": "Join a workspace",
74
+ "nodes": [
75
+ { "id": "start", "screen": "welcome" },
76
+ { "id": "finish", "screen": "home" }
77
+ ],
78
+ "edges": [{ "from": "start", "to": "finish", "label": "Continue" }]
79
+ }
80
+ ]
81
+ }
82
+ ```
83
+
84
+ URLs resolve relative to the JSON file. Nodes default to a left-to-right row. Set `column` and `row` for branches; set each screen's `viewport` for mobile or desktop dimensions. Reuse a screen in many flows without duplicating its HTML.
85
+
86
+ ## Commands
87
+
88
+ | Command | Purpose |
89
+ | ----------------------- | ------------------------------------------------------------------------------------------ |
90
+ | `scaffold <directory>` | Create a project from `basic`, `web`, or `process`. Refuses to overwrite existing content. |
91
+ | `serve <atlas.json>` | Start the viewer and serve local screens. Defaults to port 4178 on localhost. |
92
+ | `audit <atlas.json>` | Check configuration, reachability, local files, and literal HTML/CSS references. |
93
+ | `validate <atlas.json>` | Validate configuration only, without reading screen files. |
94
+
95
+ Use `--help` for options, `--root` when assets live above the JSON directory, and `audit --json` for CI reports. [Full CLI reference →](docs/cli.md)
96
+
97
+ ## Embed it in an existing page
98
+
99
+ ```js
100
+ import { loadAtlas } from "/vendor/ketatlas/src/index.js";
101
+
102
+ const atlas = await loadAtlas(document.querySelector("#map"), "./atlas.json");
103
+ atlas.goToFlow("onboarding");
104
+ // When the host page unmounts:
105
+ // atlas.destroy();
106
+ ```
107
+
108
+ Give the container a height. Ship `src/`, `styles/`, and `assets/` together. Shadow DOM isolates viewer styles and events; multiple viewers can coexist. For React or bundled applications, see [Integration](docs/integration.md).
109
+
110
+ ## Explore and contribute
111
+
112
+ - [Authoring guide](docs/authoring.md): screens, processes, branching, reuse, and viewport sizes.
113
+ - [Configuration reference](docs/configuration.md): schema and defaults.
114
+ - [CLI and audit](docs/cli.md): commands, exit codes, and audit boundaries.
115
+ - [Integration and API](docs/integration.md): lifecycle, events, embedding, and styling.
116
+ - [Architecture](docs/architecture.md): package boundaries and design provenance.
117
+ - [Migration from the mobile map](docs/migration.md): explicit field mapping.
118
+ - [Contributing](CONTRIBUTING.md) and [releasing](docs/releasing.md).
119
+
120
+ ```sh
121
+ npm run validate
122
+ npm test
123
+ npx playwright install chromium
124
+ npm run test:e2e
125
+ npm run test:package
126
+ ```
127
+
128
+ Audit is static analysis. It does not execute product code or prove that native apps, external services, or embedded pages behave correctly. Arrows describe the authored workflow; the embedded HTML retains its own interactions.
129
+
130
+ MIT · [Third-party notices](NOTICE.md).
@@ -0,0 +1,93 @@
1
+ Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KETVIET JSC, Vietnam
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.
@@ -0,0 +1,43 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Lucide Icons and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ ---
18
+
19
+ The following Lucide icons are derived from the Feather project:
20
+
21
+ airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
22
+
23
+ The MIT License (MIT) (for the icons listed above)
24
+
25
+ Copyright (c) 2013-present Cole Bemis
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ of this software and associated documentation files (the "Software"), to deal
29
+ in the Software without restriction, including without limitation the rights
30
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ copies of the Software, and to permit persons to whom the Software is
32
+ furnished to do so, subject to the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be included in all
35
+ copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43
+ SOFTWARE.
@@ -0,0 +1,56 @@
1
+ {
2
+ "source": "@ketvietlab/design-system",
3
+ "repository": "https://github.com/ketvietlab/ketjs",
4
+ "revision": "fab9de5d5814e96f2e04ced806b6bef487cf9662",
5
+ "transform": "Flatten imports. Adapt :root to :host in the Shadow DOM bundle. Preserve all token values.",
6
+ "fontSource": "@fontsource-variable/inter@5.3.0",
7
+ "iconSource": "lucide-static@1.40.0",
8
+ "sources": [
9
+ {
10
+ "path": "packages/design-system/src/styles.css",
11
+ "sha256": "d93ffcad19de960a8652067b6be872bcbc963fba5e605770cb35d9577c48d803"
12
+ },
13
+ {
14
+ "path": "packages/design-system/src/foundations/tokens.css",
15
+ "sha256": "b940bdde82f0df2e54aec6c168915561281531aa903dfdf55d7585112921055e"
16
+ },
17
+ {
18
+ "path": "packages/design-system/src/foundations/reset.css",
19
+ "sha256": "bf993c7526bdb7654bbf25f661eac65c579ac11a17bd189bc4e07e9ff8ba9349"
20
+ },
21
+ {
22
+ "path": "packages/design-system/src/primitives/primitives.css",
23
+ "sha256": "1a102a816369f10fd126ea03fbbb1172c9923afc4af89951d32ba9403a1698db"
24
+ },
25
+ {
26
+ "path": "packages/design-system/src/primitives/navigation.css",
27
+ "sha256": "1375592dced6468752607ec513d0f85df5fdacc69f681bf4f01677bddd2167c7"
28
+ },
29
+ {
30
+ "path": "packages/design-system/src/primitives/progress.css",
31
+ "sha256": "3b8436da7884d30a180588a474e77dfd8237f2346e2fad7718d1e5295b8cc8dc"
32
+ },
33
+ {
34
+ "path": "packages/design-system/src/layouts/layouts.css",
35
+ "sha256": "905db294d479c9db83059cb43f1ee7ea79573c04824fde378e923610052399f2"
36
+ },
37
+ {
38
+ "path": "packages/design-system/src/layouts/shell.css",
39
+ "sha256": "4dc89488b74022e999c9a1591650ef37826640302c8929074170c0eeddb318ec"
40
+ },
41
+ {
42
+ "path": "packages/design-system/src/patterns/patterns.css",
43
+ "sha256": "7444dcc6336ab8bb60ca2ca6809d0fd919f09108db36020c5f3500d752e29f57"
44
+ }
45
+ ],
46
+ "outputs": {
47
+ "styles/design-system.css": "ecc93e327cf006190bef28485d15aedf2f84087c80f5eb6e3594be00ac253a5c",
48
+ "styles/design-system.document.css": "d095a063da527933a96dd415ebf960b4e5f9e882ad5b806493aac9141490840e",
49
+ "src/icons.js": "44791ce0a1400d0bd6f628816935372ab02ace3e981b099ed1c157f6f13422bb",
50
+ "assets/KETJS-LICENSE": "21a04c5b7aa12b45dfefe506cae70ffb2f22961e3bd89d9edcbcaad57e86956c",
51
+ "assets/INTER-LICENSE": "3b0a5fca3d17942cde889069889dedbbbd075e9b599968c82a95f4d944e9b345",
52
+ "assets/LUCIDE-LICENSE": "b495047bd93a9b06913511076f504daba17d5bbeb3e0650f3bb53a4220329c57",
53
+ "assets/inter-latin-wght-normal.woff2": "3100e775e8616cd2611beecfa23a4263d7037586789b43f035236a2e6fbd4c62",
54
+ "assets/inter-vietnamese-wght-normal.woff2": "5c66f9e07e90c6d4ac4922cc68d60de26c17b1858e677fb5e603fce3952b3ff2"
55
+ }
56
+ }
package/bin/audit.js ADDED
@@ -0,0 +1,116 @@
1
+ import { readFile, realpath, stat } from "node:fs/promises";
2
+ import { resolve, dirname, relative, sep, extname } from "node:path";
3
+ import { fileURLToPath, pathToFileURL } from "node:url";
4
+ import { validateAtlas } from "../src/config.js";
5
+ const within = (root, path) => {
6
+ const r = relative(root, path);
7
+ return r === "" || (!r.startsWith(".." + sep) && r !== ".." && !r.startsWith(sep));
8
+ };
9
+ export async function auditAtlas(file, { root: rootOption } = {}) {
10
+ const absolute = await realpath(resolve(file));
11
+ const root = await realpath(resolve(rootOption || dirname(absolute)));
12
+ let config;
13
+ try {
14
+ config = JSON.parse(await readFile(absolute, "utf8"));
15
+ } catch (error) {
16
+ return {
17
+ valid: false,
18
+ file: absolute,
19
+ root,
20
+ summary: { flows: 0, screens: 0, nodes: 0, edges: 0, localFiles: 0, remoteUrls: 0 },
21
+ errors: [{ path: "$", message: error.message }],
22
+ warnings: [],
23
+ scope: "Invalid JSON; no resources inspected.",
24
+ };
25
+ }
26
+ const result = validateAtlas(config);
27
+ const errors = [...result.errors],
28
+ warnings = [...result.warnings],
29
+ checked = new Set(),
30
+ remote = new Set();
31
+ if (!within(root, absolute))
32
+ errors.push({ path: "file", message: "The atlas JSON must be inside the serve root." });
33
+ async function inspect(value, from, label) {
34
+ if (
35
+ !value ||
36
+ value.startsWith("#") ||
37
+ value.startsWith("data:") ||
38
+ value.startsWith("mailto:") ||
39
+ value.startsWith("tel:")
40
+ )
41
+ return;
42
+ if (/^(https?:)?\/\//i.test(value)) {
43
+ remote.add(value);
44
+ return;
45
+ }
46
+ let target;
47
+ try {
48
+ const url = value.startsWith("/")
49
+ ? new URL("." + value, pathToFileURL(root + sep))
50
+ : new URL(value, pathToFileURL(from));
51
+ if (url.protocol !== "file:") return;
52
+ target = await realpath(fileURLToPath(url));
53
+ if (!within(root, target))
54
+ throw new Error("Asset is outside the serve root; move it or use --root.");
55
+ const rel = relative(root, target);
56
+ if (rel.split(sep).some((part) => part.startsWith(".")))
57
+ throw new Error("Dotfiles are not served.");
58
+ if (!(await stat(target)).isFile()) throw new Error("Expected a file.");
59
+ } catch (e) {
60
+ errors.push({
61
+ path: label,
62
+ message: `Cannot serve ${value}: ${e.code === "ENOENT" ? "file not found" : e.message}`,
63
+ });
64
+ return;
65
+ }
66
+ if (checked.has(target)) return;
67
+ checked.add(target);
68
+ const extension = extname(target).toLowerCase();
69
+ if (![".html", ".css"].includes(extension)) return;
70
+ const content = await readFile(target, "utf8");
71
+ if (extension === ".html") {
72
+ if (!/<meta\b[^>]*name\s*=\s*["']viewport["']/i.test(content))
73
+ warnings.push({
74
+ path: relative(root, target),
75
+ message: "No viewport meta tag; narrow previews may use a desktop layout.",
76
+ });
77
+ // Literal HTML resource URLs only. JS-generated URLs need browser verification.
78
+ for (const match of content.matchAll(
79
+ /<(?:script|link|img|iframe|source)\b[^>]*?\b(?:src|href)\s*=\s*["']([^"']+)["']/gi,
80
+ ))
81
+ await inspect(match[1], target, relative(root, target));
82
+ for (const match of content.matchAll(/<a\b[^>]*?\bhref\s*=\s*["']([^"']+)["']/gi))
83
+ await inspect(match[1], target, relative(root, target));
84
+ } else {
85
+ for (const match of content.matchAll(
86
+ /(?:url\(\s*["']?([^\s"')]+)["']?\s*\)|@import\s+["']([^"']+)["'])/gi,
87
+ ))
88
+ await inspect(match[1] || match[2], target, relative(root, target));
89
+ }
90
+ }
91
+ if (result.valid) {
92
+ for (const s of config.screens || []) await inspect(s.url, absolute, `screen:${s.id}`);
93
+ for (const f of config.flows)
94
+ for (const n of f.nodes) if (n.url) await inspect(n.url, absolute, `node:${f.id}/${n.id}`);
95
+ }
96
+ for (const url of remote)
97
+ warnings.push({ path: "remote", message: `Remote URL not fetched: ${url}` });
98
+ const flows = Array.isArray(config?.flows) ? config.flows : [];
99
+ return {
100
+ valid: errors.length === 0,
101
+ file: absolute,
102
+ root,
103
+ summary: {
104
+ flows: flows.length,
105
+ screens: Array.isArray(config?.screens) ? config.screens.length : 0,
106
+ nodes: flows.reduce((n, f) => n + (Array.isArray(f?.nodes) ? f.nodes.length : 0), 0),
107
+ edges: flows.reduce((n, f) => n + (Array.isArray(f?.edges) ? f.edges.length : 0), 0),
108
+ localFiles: checked.size,
109
+ remoteUrls: remote.size,
110
+ },
111
+ errors,
112
+ warnings,
113
+ scope:
114
+ "Static configuration and literal local HTML/CSS references. JavaScript behavior and remote embedding policies are not executed.",
115
+ };
116
+ }
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ import { readFile, readdir, mkdir, cp, writeFile, stat } from "node:fs/promises";
3
+ import { resolve, dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { validateAtlas } from "../src/config.js";
6
+ import { serve } from "./server.js";
7
+ import { serveAtlas } from "./viewer.js";
8
+ import { auditAtlas } from "./audit.js";
9
+ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
10
+ const help = `KetAtlas — scaffold, serve, and audit HTML workflow maps
11
+
12
+ ketatlas scaffold <directory> [--template basic|web|process]
13
+ ketatlas serve <atlas.json> [--port 4178] [--root directory]
14
+ ketatlas audit <atlas.json> [--root directory] [--json] [--strict]
15
+ ketatlas validate <atlas.json>
16
+ ketatlas --version
17
+
18
+ Examples:
19
+ npx ketatlas scaffold my-atlas
20
+ npx ketatlas serve my-atlas/atlas.json
21
+ npx ketatlas audit my-atlas/atlas.json --strict
22
+
23
+ Serve binds to 127.0.0.1. No HTML wrapper, build, account, or backend required.
24
+ `;
25
+ function parse(args, allowed) {
26
+ const options = {},
27
+ positionals = [];
28
+ for (let i = 0; i < args.length; i++) {
29
+ const arg = args[i];
30
+ if (arg.startsWith("--")) {
31
+ const key = arg.slice(2);
32
+ if (!(key in allowed)) throw new Error(`Unknown option: ${arg}`);
33
+ if (allowed[key] === "boolean") options[key] = true;
34
+ else {
35
+ const value = args[++i];
36
+ if (!value || value.startsWith("--")) throw new Error(`Missing value for ${arg}`);
37
+ options[key] = value;
38
+ }
39
+ } else positionals.push(arg);
40
+ }
41
+ if (positionals.length !== 1)
42
+ throw new Error("Expected one file or directory. Run ketatlas --help.");
43
+ return { target: positionals[0], options };
44
+ }
45
+ async function main(args) {
46
+ const [command, ...rest] = args;
47
+ if (!command || ["--help", "-h", "help"].includes(command) || rest.includes("--help")) {
48
+ console.log(help);
49
+ return;
50
+ }
51
+ if (command === "--version") {
52
+ console.log(JSON.parse(await readFile(join(packageRoot, "package.json"), "utf8")).version);
53
+ return;
54
+ }
55
+ if (command === "scaffold" || command === "init") {
56
+ const { target, options } = parse(rest, { template: "string" }),
57
+ template = options.template || "basic";
58
+ if (!["basic", "web", "process"].includes(template))
59
+ throw new Error("Templates: basic, web, process.");
60
+ const destination = resolve(target);
61
+ let existing;
62
+ try {
63
+ existing = await readdir(destination);
64
+ } catch (e) {
65
+ if (e.code !== "ENOENT") throw e;
66
+ }
67
+ if (existing?.length)
68
+ throw new Error("Destination is not empty. Choose an empty or new directory.");
69
+ await mkdir(destination, { recursive: true });
70
+ const source = join(packageRoot, "templates", template);
71
+ for (const name of await readdir(source))
72
+ await cp(join(source, name), join(destination, name), {
73
+ recursive: true,
74
+ force: false,
75
+ errorOnExist: true,
76
+ });
77
+ console.log(
78
+ `Created ${destination}\n\nNext: npx ketatlas serve "${join(destination, "atlas.json")}"\nEdit atlas.json to make it yours.`,
79
+ );
80
+ return;
81
+ }
82
+ if (command === "audit") {
83
+ const { target, options } = parse(rest, {
84
+ root: "string",
85
+ json: "boolean",
86
+ strict: "boolean",
87
+ output: "string",
88
+ });
89
+ const report = await auditAtlas(target, options),
90
+ pass = report.valid && (!options.strict || report.warnings.length === 0);
91
+ if (options.output)
92
+ await writeFile(resolve(options.output), JSON.stringify(report, null, 2) + "\n", {
93
+ flag: "wx",
94
+ });
95
+ if (options.json) console.log(JSON.stringify(report, null, 2));
96
+ else {
97
+ for (const issue of report.errors) console.error(`ERROR ${issue.path}: ${issue.message}`);
98
+ for (const issue of report.warnings) console.warn(`WARN ${issue.path}: ${issue.message}`);
99
+ console.log(
100
+ `${pass ? "PASS" : "FAIL"} · ${report.summary.flows} flows · ${report.summary.screens} screens · ${report.summary.localFiles} local files\n${report.scope}`,
101
+ );
102
+ }
103
+ if (!pass) process.exitCode = 1;
104
+ return;
105
+ }
106
+ if (command === "validate") {
107
+ const { target } = parse(rest, {}),
108
+ config = JSON.parse(await readFile(resolve(target), "utf8")),
109
+ result = validateAtlas(config);
110
+ for (const issue of result.errors) console.error(`ERROR ${issue.path}: ${issue.message}`);
111
+ for (const issue of result.warnings) console.warn(`WARN ${issue.path}: ${issue.message}`);
112
+ if (!result.valid) {
113
+ process.exitCode = 1;
114
+ return;
115
+ }
116
+ console.log(
117
+ `Valid atlas: ${config.flows.length} flows, ${config.screens?.length || 0} screens.`,
118
+ );
119
+ return;
120
+ }
121
+ if (command === "serve") {
122
+ const { target, options } = parse(rest, { port: "string", root: "string" }),
123
+ port = Number(options.port || 4178);
124
+ if (!Number.isInteger(port) || port < 1 || port > 65535)
125
+ throw new Error("Port must be 1–65535.");
126
+ const directory = (await stat(resolve(target))).isDirectory();
127
+ if (directory && options.root)
128
+ throw new Error("--root is only needed when serving an atlas JSON file.");
129
+ const server = directory
130
+ ? await serve(target, { port })
131
+ : await serveAtlas(target, { port, root: options.root });
132
+ console.log(
133
+ `KetAtlas: http://127.0.0.1:${server.address().port}\nServing ${resolve(target)}\nPress Ctrl+C to stop.`,
134
+ );
135
+ const close = () => {
136
+ server.close();
137
+ server.closeAllConnections();
138
+ };
139
+ process.once("SIGINT", close);
140
+ process.once("SIGTERM", close);
141
+ return;
142
+ }
143
+ throw new Error(`Unknown command: ${command}. Run ketatlas --help.`);
144
+ }
145
+ main(process.argv.slice(2)).catch((error) => {
146
+ console.error(`KetAtlas: ${error.message}`);
147
+ process.exitCode = 1;
148
+ });