@asd14/vblocks 6.3.0 → 6.4.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/README.md +88 -48
- package/bin/vblocks +4 -0
- package/bin/vblocks.d/build +9 -0
- package/bin/vblocks.d/eject +6 -1
- package/bin/vblocks.d/init +9 -0
- package/bin/vblocks.d/lib/guard.sh +64 -0
- package/bin/vblocks.d/lib/help.sh +26 -0
- package/bin/vblocks.d/lib/log.sh +178 -0
- package/bin/vblocks.d/lib/validation.sh +101 -0
- package/bin/vblocks.d/serve +9 -0
- package/bin/vblocks.d/vblocks.sh +9 -9
- package/bin/vblocks.d/webpack.sh +2 -0
- package/defaults/webpack.config.js +1 -1
- package/package.json +3 -1
- package/template/_common/app/.env.example +5 -0
- package/template/_common/app/src/index.tsx +27 -0
- package/template/_common/post-init-app.sh +9 -0
- package/template/plain/app/src/index.app.tsx +3 -0
- package/template/xyflow/app/src/details.tsx +1 -1
- package/template/xyflow/app/src/diagram.tsx +1 -1
- package/template/xyflow/app/src/{index.tsx → index.app.tsx} +6 -14
- package/template/xyflow/app/src/index.css +1 -0
- package/template/xyflow/post-init-app.sh +2 -2
- package/template/xyflow-tabs/app/src/{index.tsx → index.app.tsx} +5 -15
- package/template/xyflow-tabs/app/src/index.css +1 -0
- package/template/xyflow-tabs/app/src/pages/build/details.tsx +1 -1
- package/template/xyflow-tabs/app/src/pages/build/diagram.tsx +2 -2
- package/template/xyflow-tabs/app/src/pages/serve/details.tsx +1 -1
- package/template/xyflow-tabs/app/src/pages/serve/diagram.tsx +2 -2
- package/template/xyflow-tabs/post-init-app.sh +2 -2
- package/bin/vblocks.d/lib.sh +0 -569
- package/template/plain/app/src/index.tsx +0 -11
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# NAME
|
|
4
|
+
# validation.sh - Tell if a value has a shape, eg. a slug or a geometry
|
|
5
|
+
#
|
|
6
|
+
# SYNOPSIS
|
|
7
|
+
# . "$_SCRIPT_DIR/../lib/validation.sh"
|
|
8
|
+
#
|
|
9
|
+
# DESCRIPTION
|
|
10
|
+
# Needs log.sh. A script sources it before this file.
|
|
11
|
+
|
|
12
|
+
# _is <type> <value>
|
|
13
|
+
#
|
|
14
|
+
# Tell if <value> has the shape of <type>.
|
|
15
|
+
#
|
|
16
|
+
# positive-integer 0-9, no leading zero
|
|
17
|
+
# non-negative-integer 0, or a positive-integer
|
|
18
|
+
# version 0-9 in groups, one dot between two groups, eg.
|
|
19
|
+
# 1.13.4
|
|
20
|
+
# slug A-Za-z0-9_-, starts with a letter or a digit
|
|
21
|
+
# identifier A-Za-z0-9_, cannot start with a digit
|
|
22
|
+
# folgezettel a-z0-9, starts with 1-9, a run of digits never
|
|
23
|
+
# starts with 0, eg. 1b3. 1b03 and 1b3 would name
|
|
24
|
+
# one place
|
|
25
|
+
# geometry "<x>,<y> <width>x<height>", the shape grim, slurp
|
|
26
|
+
# and wf-recorder read, eg. "-10,0 800x600". x and
|
|
27
|
+
# y are integers, width and height positive
|
|
28
|
+
#
|
|
29
|
+
# RETURNS
|
|
30
|
+
# 0 <value> has the shape
|
|
31
|
+
# 1 <value> does not have it, or is empty
|
|
32
|
+
#
|
|
33
|
+
# EXIT
|
|
34
|
+
# 3 <type> is not a type above and <value> is not empty, or the call
|
|
35
|
+
# does not have two positionals
|
|
36
|
+
_is() {
|
|
37
|
+
[ "$#" -eq 2 ] || _fail 3 "_is needs <type> <value>"
|
|
38
|
+
[ -n "$2" ] || return 1
|
|
39
|
+
|
|
40
|
+
# Reject with a negated class, which checks every character.
|
|
41
|
+
# [A-Za-z_][A-Za-z0-9_]* checks two characters and accepts "ab; rm -rf /".
|
|
42
|
+
# Inside a class, put "-" last and "]" first.
|
|
43
|
+
case "$1" in
|
|
44
|
+
positive-integer)
|
|
45
|
+
# 0* rejects zero and every leading zero with it, so no arithmetic runs
|
|
46
|
+
# and a 20-digit value cannot abort the shell with "Illegal number".
|
|
47
|
+
case "$2" in
|
|
48
|
+
*[!0-9]* | 0*) return 1 ;;
|
|
49
|
+
esac
|
|
50
|
+
;;
|
|
51
|
+
non-negative-integer)
|
|
52
|
+
# 0?* rejects a leading zero. Shell arithmetic reads 010 as octal 8
|
|
53
|
+
case "$2" in
|
|
54
|
+
*[!0-9]* | 0?*) return 1 ;;
|
|
55
|
+
esac
|
|
56
|
+
;;
|
|
57
|
+
version)
|
|
58
|
+
case "$2" in
|
|
59
|
+
*[!0-9.]* | .* | *. | *..*) return 1 ;;
|
|
60
|
+
esac
|
|
61
|
+
;;
|
|
62
|
+
slug)
|
|
63
|
+
case "$2" in
|
|
64
|
+
*[!A-Za-z0-9_-]* | [_-]*) return 1 ;;
|
|
65
|
+
esac
|
|
66
|
+
;;
|
|
67
|
+
identifier)
|
|
68
|
+
case "$2" in
|
|
69
|
+
*[!A-Za-z0-9_]* | [0-9]*) return 1 ;;
|
|
70
|
+
esac
|
|
71
|
+
;;
|
|
72
|
+
folgezettel)
|
|
73
|
+
case "$2" in
|
|
74
|
+
*[!0-9a-z]* | [!1-9]* | *[a-z]0*) return 1 ;;
|
|
75
|
+
esac
|
|
76
|
+
;;
|
|
77
|
+
geometry)
|
|
78
|
+
case "$2" in
|
|
79
|
+
*[!0-9,x\ -]* | *,*,* | *" "*" "* | *x*x*) return 1 ;;
|
|
80
|
+
*,*" "*x*) ;;
|
|
81
|
+
*) return 1 ;;
|
|
82
|
+
esac
|
|
83
|
+
|
|
84
|
+
# "-10,0 800x600": x, y, then the size
|
|
85
|
+
lib_is_x=${2%%,*}
|
|
86
|
+
lib_is_y=${2#*,}
|
|
87
|
+
lib_is_y=${lib_is_y%% *}
|
|
88
|
+
lib_is_size=${2##* }
|
|
89
|
+
_is non-negative-integer "${lib_is_x#-}" \
|
|
90
|
+
&& _is non-negative-integer "${lib_is_y#-}" \
|
|
91
|
+
&& _is positive-integer "${lib_is_size%%x*}" \
|
|
92
|
+
&& _is positive-integer "${lib_is_size#*x}" \
|
|
93
|
+
|| return 1
|
|
94
|
+
;;
|
|
95
|
+
*)
|
|
96
|
+
_fail 3 -v type "$1" "Unknown type"
|
|
97
|
+
;;
|
|
98
|
+
esac
|
|
99
|
+
|
|
100
|
+
return 0
|
|
101
|
+
}
|
package/bin/vblocks.d/serve
CHANGED
|
@@ -54,6 +54,15 @@
|
|
|
54
54
|
set -eu
|
|
55
55
|
|
|
56
56
|
_SCRIPT_DIR=$(dirname "$0")
|
|
57
|
+
# tools/update-lib downloads lib/ from posix-utils, never edit it here
|
|
58
|
+
# shellcheck source=lib/log.sh
|
|
59
|
+
. "$_SCRIPT_DIR/lib/log.sh"
|
|
60
|
+
# shellcheck source=lib/validation.sh
|
|
61
|
+
. "$_SCRIPT_DIR/lib/validation.sh"
|
|
62
|
+
# shellcheck source=lib/guard.sh
|
|
63
|
+
. "$_SCRIPT_DIR/lib/guard.sh"
|
|
64
|
+
# shellcheck source=lib/help.sh
|
|
65
|
+
. "$_SCRIPT_DIR/lib/help.sh"
|
|
57
66
|
# shellcheck source=vblocks.sh
|
|
58
67
|
. "$_SCRIPT_DIR/vblocks.sh"
|
|
59
68
|
# shellcheck source=webpack.sh
|
package/bin/vblocks.d/vblocks.sh
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
3
|
# vblocks.sh - What every command of vblocks shares:
|
|
4
|
-
# -
|
|
4
|
+
# - the folders, the styles of the output and the header
|
|
5
|
+
#
|
|
6
|
+
# Needs lib/log.sh. The command needs to source it before this file.
|
|
5
7
|
|
|
6
8
|
# The caller sets _SCRIPT_DIR to the folder of vblocks.sh, then sources it
|
|
7
9
|
: "${_SCRIPT_DIR:?the caller sets _SCRIPT_DIR before it sources vblocks.sh}"
|
|
8
10
|
|
|
9
11
|
_VB_DIR=$(dirname "$(dirname "$_SCRIPT_DIR")")
|
|
10
12
|
|
|
11
|
-
# tools/update-lib downloads lib.sh from @asd14/posix-utils. Never edit lib.sh
|
|
12
|
-
# here
|
|
13
|
-
# shellcheck source=lib.sh
|
|
14
|
-
. "$_SCRIPT_DIR/lib.sh"
|
|
15
|
-
|
|
16
13
|
# _log reads LOG_NAMESPACE, LOG_LEVEL and NO_LOG_TIME.
|
|
17
14
|
#
|
|
18
15
|
# - NO_LOG_TIME drops the time, which adds no fact to a message
|
|
19
16
|
# - Send each stderr message through _ok, _info, _warn or _fail
|
|
20
17
|
# - Only the header, the summaries and `help` print on their own
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
# shellcheck disable=SC2034 # lib/log.sh, which the command sources, reads them
|
|
19
|
+
{
|
|
20
|
+
LOG_NAMESPACE="vblocks"
|
|
21
|
+
LOG_LEVEL="info"
|
|
22
|
+
NO_LOG_TIME="true"
|
|
23
|
+
}
|
|
24
24
|
|
|
25
25
|
# `cd` follows an exported CDPATH and prints the folder it picked, which
|
|
26
26
|
# `$(cd ... && pwd)` would capture
|
package/bin/vblocks.d/webpack.sh
CHANGED
|
@@ -354,7 +354,7 @@ export default (
|
|
|
354
354
|
|
|
355
355
|
module: {
|
|
356
356
|
rules: [
|
|
357
|
-
// If `?raw`, return the file contents
|
|
357
|
+
// If `?raw`, return the file contents and skip every other rule
|
|
358
358
|
{
|
|
359
359
|
resourceQuery: RAW_QUERY,
|
|
360
360
|
type: "asset/source",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@asd14/vblocks",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.4.0",
|
|
5
5
|
"description": "Zero-config React builds, as a static site or a single HTML file",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react",
|
|
@@ -92,8 +92,10 @@
|
|
|
92
92
|
"@tailwindcss/postcss": "^4.3.5",
|
|
93
93
|
"@types/dotenv-webpack": "^7.0.8",
|
|
94
94
|
"@types/react": "^19.3.0",
|
|
95
|
+
"@types/react-dom": "^19",
|
|
95
96
|
"@types/webpack-bundle-analyzer": "^4.7.0",
|
|
96
97
|
"@xyflow/react": "^12.12.1",
|
|
98
|
+
"agentation": "^3.1.2",
|
|
97
99
|
"eslint": "^9.39.5",
|
|
98
100
|
"prettier": "^3.9.10",
|
|
99
101
|
"semantic-release": "^25.0.9",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Agentation } from "agentation"
|
|
2
|
+
import { createRoot } from "react-dom/client"
|
|
3
|
+
|
|
4
|
+
import { App } from "./index.app.tsx"
|
|
5
|
+
|
|
6
|
+
const root = document.querySelector("#root")
|
|
7
|
+
|
|
8
|
+
if (!root) {
|
|
9
|
+
throw new Error("index.html has no #root element")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Webpack writes NODE_ENV into the bundle at build time. A production build
|
|
13
|
+
// drops this branch, and the Agentation toolbar with it
|
|
14
|
+
createRoot(root).render(
|
|
15
|
+
process.env["NODE_ENV"] === "development" ? (
|
|
16
|
+
<>
|
|
17
|
+
{/* Agentation finds React by this attribute. #root has no fiber
|
|
18
|
+
(agentation#225) */}
|
|
19
|
+
<div data-reactroot="" style={{ display: "contents" }}>
|
|
20
|
+
<App />
|
|
21
|
+
</div>
|
|
22
|
+
<Agentation endpoint={process.env["AGENTATION_ENDPOINT"]} />
|
|
23
|
+
</>
|
|
24
|
+
) : (
|
|
25
|
+
<App />
|
|
26
|
+
)
|
|
27
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# Runs in the app folder, after `vblocks init` copies the app files. npm commands
|
|
4
|
+
# write in the nearest package.json, ie. project root
|
|
5
|
+
|
|
6
|
+
set -eu
|
|
7
|
+
|
|
8
|
+
# src/index.tsx renders the Agentation toolbar in development
|
|
9
|
+
npm pkg set "devDependencies.agentation=^3"
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { useState } from "react"
|
|
2
|
-
import { createRoot } from "react-dom/client"
|
|
3
2
|
|
|
4
|
-
import { Details } from "./details"
|
|
5
|
-
import { Diagram } from "./diagram"
|
|
6
|
-
|
|
7
|
-
import "@xyflow/react/dist/style.css"
|
|
8
|
-
import "./index.css"
|
|
3
|
+
import { Details } from "./details.tsx"
|
|
4
|
+
import { Diagram } from "./diagram.tsx"
|
|
9
5
|
|
|
10
6
|
const App = () => {
|
|
11
7
|
const [selectedId, setSelectedId] = useState<string>()
|
|
@@ -14,7 +10,9 @@ const App = () => {
|
|
|
14
10
|
<div className="grid h-screen grid-rows-[auto_1fr] bg-stone-50 text-stone-900">
|
|
15
11
|
<header className="border-b border-stone-200 bg-white px-6 py-3">
|
|
16
12
|
<h1 className="text-lg font-semibold">VBlocks</h1>
|
|
17
|
-
<p className="text-sm text-stone-500">
|
|
13
|
+
<p className="text-sm text-stone-500">
|
|
14
|
+
How build turns src/ into a page
|
|
15
|
+
</p>
|
|
18
16
|
</header>
|
|
19
17
|
|
|
20
18
|
<div className="grid min-h-0 grid-cols-[1fr_20rem]">
|
|
@@ -34,10 +32,4 @@ const App = () => {
|
|
|
34
32
|
)
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!root) {
|
|
40
|
-
throw new Error("index.html has no #root element")
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
createRoot(root).render(<App />)
|
|
35
|
+
export { App }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
|
-
# Runs in the app folder, after `vblocks init` copies the app files. npm
|
|
4
|
-
# the nearest package.json,
|
|
3
|
+
# Runs in the app folder, after `vblocks init` copies the app files. npm commands
|
|
4
|
+
# write in the nearest package.json, ie. project root
|
|
5
5
|
|
|
6
6
|
set -eu
|
|
7
7
|
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { useState } from "react"
|
|
2
|
-
import { createRoot } from "react-dom/client"
|
|
3
2
|
|
|
4
|
-
import { BuildDetails } from "./pages/build/details"
|
|
5
|
-
import { BuildDiagram } from "./pages/build/diagram"
|
|
6
|
-
import { ServeDetails } from "./pages/serve/details"
|
|
7
|
-
import { ServeDiagram } from "./pages/serve/diagram"
|
|
8
|
-
|
|
9
|
-
import "@xyflow/react/dist/style.css"
|
|
10
|
-
import "./index.css"
|
|
3
|
+
import { BuildDetails } from "./pages/build/details.tsx"
|
|
4
|
+
import { BuildDiagram } from "./pages/build/diagram.tsx"
|
|
5
|
+
import { ServeDetails } from "./pages/serve/details.tsx"
|
|
6
|
+
import { ServeDiagram } from "./pages/serve/diagram.tsx"
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
9
|
* The tabs of the diagram. For a new tab, add a folder in `pages/` with a
|
|
@@ -81,10 +77,4 @@ const App = () => {
|
|
|
81
77
|
)
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (!root) {
|
|
87
|
-
throw new Error("index.html has no #root element")
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
createRoot(root).render(<App />)
|
|
80
|
+
export { App }
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
type OnSelectionChangeFunc,
|
|
18
18
|
} from "@xyflow/react"
|
|
19
19
|
|
|
20
|
-
import { CELL_SIZE, toPixels } from "@self/utils/grid"
|
|
20
|
+
import { CELL_SIZE, toPixels } from "@self/utils/grid.ts"
|
|
21
21
|
|
|
22
|
-
import { ZoomLevel } from "@self/ui/zoom-level"
|
|
22
|
+
import { ZoomLevel } from "@self/ui/zoom-level.tsx"
|
|
23
23
|
|
|
24
24
|
type StepNode = Node<{ label: string; detail: string }, "step">
|
|
25
25
|
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
type OnSelectionChangeFunc,
|
|
16
16
|
} from "@xyflow/react"
|
|
17
17
|
|
|
18
|
-
import { CELL_SIZE, toPixels } from "@self/utils/grid"
|
|
18
|
+
import { CELL_SIZE, toPixels } from "@self/utils/grid.ts"
|
|
19
19
|
|
|
20
|
-
import { ZoomLevel } from "@self/ui/zoom-level"
|
|
20
|
+
import { ZoomLevel } from "@self/ui/zoom-level.tsx"
|
|
21
21
|
|
|
22
22
|
type PhaseNode = Node<
|
|
23
23
|
{ label: string; detail: string; delay?: string },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
|
-
# Runs in the app folder, after `vblocks init` copies the app files. npm
|
|
4
|
-
# the nearest package.json,
|
|
3
|
+
# Runs in the app folder, after `vblocks init` copies the app files. npm commands
|
|
4
|
+
# write in the nearest package.json, ie. project root
|
|
5
5
|
|
|
6
6
|
set -eu
|
|
7
7
|
|