Files
shaneandshinyobjectz 2563c183e7 The component library: 609 open-source effects sorted by use, searched and copied by raea make component (#281)
* The component library: 609 open-source effects sorted by use, searched by `raea make component list WORDS` and copied by `add NAME`

sdk/raea/library/components holds 475 pieces from remocn, 79 from the React Video Editor templates and 55 from snapcn,
ported to raea's composition API and sorted by what they're for (text, numbers, transitions, screens, HUDs and more),
not by who made them. catalog.json lists each piece's category, type, what it does, its files, the shared helpers it
needs, its fonts and npm packages and its source; CREDITS.md holds the licences and every file's first line names its
source.

- `raea make component list` ends with the library's categories; `list WORDS` searches by category, category/type or
  words (catalog.ts). `add NAME` copies the piece into components/CATEGORY/NAME/ with its helpers under
  components/_lib/, and installs its npm packages through the engine.
- The native host reads the library beside the binary (share/raea, which tools/release.sh already packs from
  sdk/raea/library), in RAEA_HOME, or in the tree a built raea runs from.
- tools/effects-catalog.sh writes the cut-down catalogue raea cloud's dashboard imports (Libraries › Effects).
- tools/size.sh leaves the library out: it's other people's code, kept as they wrote it but for imports.
- conformance/catalog.test.ts: every listed file exists, imports stay inside what a piece copies, none imports another
  video framework, and search finds by use.

* raea help's line for make component says list WORDS searches the library

* no-void leaves the component library out: its gradient shader's own name is void

---------

Co-authored-by: shinyobjectz <[email protected]>
2026-11-30 18:27:08 -08:00

70 lines
4.1 KiB
Bash
Executable File

#!/bin/bash
# "void" is retired: raea's application layer is raea feed (decided 10-25). This ratchet keeps the old name from
# coming back. It counts the lines of each tracked file (raea's and apps/app's) that use "void" as a product name: the
# names raea-void, void-bevy, void_bevy, void-app, void-conform and RAEA_VOID_*, and the bare word wherever it isn't
# TypeScript's `void` type or operator. It fails when a file has more such lines than tools/no-void.allow gives it, or
# a file it doesn't list has any. The allowance only shrinks: rename, then take the new counts.
# tools/no-void.sh check; each file over its allowance, with its lines
# tools/no-void.sh --update tools/no-void.allow rewritten to today's counts (refused if any count rose)
set -u
ROOT=$(cd "$(dirname "$0")/.." && pwd)
cd "$ROOT" || exit 2
ALLOW=tools/no-void.allow
NAMES='raea-void|void[-_](bevy|app|conform|shell)|RAEA_VOID_'
# TypeScript's void (and C's, in a few FFI comments): a type after `:`, `=>`, `<` or `|`, or the operator before an
# expression (`void css;` too, in TS a script writes); ts-native's checklist names the operator's own tests; those
# lines aren't the product
KEYWORD='(:|=>|<|\||\(|,) *void\b|\bvoid *(0|\(|>|\||;|,|\)|\]|\{|=)|\bvoid [a-z_$][a-zA-Z0-9_$.]*\(|\bvoid [A-Za-z_$][A-Za-z0-9_$]*;|operators\.void|expressions/void|c_void|void\*|\bvoid main\b|no-void'
# the fallback readers: they read RAEA_VOID_* and move ~/.raea-void for one release, so they must
# name both; dropped from here when the fallback is
SHIMS=(':!systems/ml/src/feed.rs')
# text that isn't ours or is a record, kept as written:
# the fonts' OFL licence texts (the licence's own word, "void")
# a recorded SEO rankings file (the keywords searched that day)
# P26 baseline rows already taken (their notes name the composition as it was then)
# the component library (sdk/raea/library/components): other people's code, whose gradient shader is called "void"
RECORDS=(':!*-OFL.txt' ':!apps/site/seo/rankings/*' ':!bench/p26-baseline/manifest.jsonl' ':!sdk/raea/library/components/*')
# raea-skills (skills/) is its own repo: an export has its files, the live tree's git grep never reads them
SKIP=("${SHIMS[@]}" "${RECORDS[@]}" ':!skills/*' ':!*.lock' ':!*pnpm-lock.yaml' ':!*package-lock.json' ':!*/vendor/*' ':!vendor/*' ':!**/node_modules/**' ':!tools/no-void.allow' ':!tools/no-void.sh' ':!docs/handoff/*' ':!docs/overhaul/audit/*' ':!*LICENSE*' ':!*LICENCE*' ':!*.png' ':!*.jpg' ':!*.mp4' ':!*.woff2' ':!*.glb' ':!*.wasm')
# file:line of each use, in one repo (prefixed with its path in raea)
uses() {
local dir=$1 pre=$2
{
git -C "$dir" grep -n -I -E "$NAMES" -- . "${SKIP[@]}"
git -C "$dir" grep -n -I -i -w void -- . "${SKIP[@]}" ':!*.ts' ':!*.tsx' ':!*.js' ':!*.mjs' ':!*.cjs' ':!*.d.ts' \
| grep -v -i -E "^[^:]+:[0-9]+:.*($KEYWORD)"
} | awk -F: -v p="$pre" '{print p $1 ":" $2}' | sort -u
}
all=$(uses . ""; [ -e apps/app/.git ] && uses apps/app "apps/app/")
counts=$(printf '%s\n' "$all" | grep -v '^$' | awk -F: '{n[$1]++} END {for (f in n) print n[f], f}' | sort -k2)
if [ "${1:-}" = "--update" ]; then
rose=0
while read -r n f; do
[ -n "$n" ] || continue
a=$(awk -v f="$f" '$2 == f {print $1}' "$ALLOW" 2>/dev/null)
if [ -f "$ALLOW" ] && [ "${a:-0}" -lt "$n" ]; then echo "no-void: $f rose to $n (allowed ${a:-0}); rename it instead"; rose=1; fi
done <<< "$counts"
[ $rose = 0 ] || exit 1
printf '%s\n' "$counts" | grep -v '^$' > "$ALLOW"
echo "no-void: $ALLOW now $(wc -l < "$ALLOW" | tr -d ' ') files, $(awk '{s+=$1} END {print s+0}' "$ALLOW") lines"
exit 0
fi
bad=0
while read -r n f; do
[ -n "$f" ] || continue
a=$(awk -v f="$f" '$2 == f {print $1}' "$ALLOW")
if [ "${a:-0}" -lt "$n" ]; then
echo "no-void: $f has $n product uses of \"void\" (allowed ${a:-0}); the app is raea feed:"
printf '%s\n' "$all" | awk -F: -v f="$f" '$1 == f {print $2}' | while read -r l; do
echo " $l: $(sed -n "${l}p" "$f" | cut -c1-140)"
done
bad=1
fi
done <<< "$counts"
total=$(printf '%s\n' "$counts" | awk '{s+=$1} END {print s+0}')
[ $bad = 0 ] && echo "no-void: ok ($total uses left in $(printf '%s\n' "$counts" | grep -c .) files, none new)"
exit $bad