@flipova/foundation 1.13.0 → 2.0.4
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/CHANGELOG.md +181 -0
- package/README.md +53 -178
- package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +162 -0
- package/components/ui/accordion/AccordionAnimatedHeight.tsx +56 -0
- package/components/ui/accordion/AccordionAnimatedIcon.tsx +41 -0
- package/components/ui/accordion/AnimatedHeight.tsx +56 -0
- package/components/ui/accordion/AnimatedIcon.tsx +41 -0
- package/components/ui/accordion/MIGRATION_SUMMARY.md +250 -0
- package/components/ui/accordion/USAGE_EXAMPLE.tsx +179 -0
- package/components/ui/accordion/animation-config.ts +32 -0
- package/components/ui/accordion/index.tsx +253 -0
- package/components/ui/actionsheet/index.tsx +511 -0
- package/components/ui/alert/index.tsx +158 -0
- package/components/ui/alert-dialog/index.tsx +254 -0
- package/components/ui/avatar/index.tsx +139 -0
- package/components/ui/badge/index.tsx +163 -0
- package/components/ui/bottomsheet/index.tsx +477 -0
- package/components/ui/box/index.tsx +19 -0
- package/components/ui/box/index.web.tsx +19 -0
- package/components/ui/box/styles.tsx +10 -0
- package/components/ui/button/index.tsx +264 -0
- package/components/ui/calendar/creator.tsx +366 -0
- package/components/ui/calendar/index.tsx +462 -0
- package/components/ui/calendar/styles.tsx +140 -0
- package/components/ui/card/index.tsx +23 -0
- package/components/ui/card/index.web.tsx +26 -0
- package/components/ui/card/styles.tsx +16 -0
- package/components/ui/center/index.tsx +22 -0
- package/components/ui/center/index.web.tsx +20 -0
- package/components/ui/center/styles.tsx +8 -0
- package/components/ui/checkbox/index.tsx +184 -0
- package/components/ui/date-time-picker/creator.tsx +109 -0
- package/components/ui/date-time-picker/index.tsx +585 -0
- package/components/ui/date-time-picker/index.web.tsx +217 -0
- package/components/ui/date-time-picker/styles.tsx +56 -0
- package/components/ui/divider/index.tsx +40 -0
- package/components/ui/drawer/index.tsx +362 -0
- package/components/ui/fab/index.tsx +215 -0
- package/components/ui/flat-list/index.tsx +21 -0
- package/components/ui/form-control/index.tsx +352 -0
- package/components/ui/gluestack-ui-provider/config.ts +72 -0
- package/components/ui/gluestack-ui-provider/index.tsx +47 -0
- package/components/ui/gluestack-ui-provider/index.web.tsx +96 -0
- package/components/ui/gluestack-ui-provider/script.ts +19 -0
- package/components/ui/gluestack-ui-provider/tokens.d.ts +17 -0
- package/components/ui/gluestack-ui-provider/tokens.js +188 -0
- package/components/ui/gluestack-ui-provider/useGluestackColors.ts +82 -0
- package/components/ui/grid/index.tsx +283 -0
- package/components/ui/grid/index.web.tsx +66 -0
- package/components/ui/grid/styles.tsx +15 -0
- package/components/ui/heading/index.tsx +220 -0
- package/components/ui/heading/index.web.tsx +202 -0
- package/components/ui/heading/styles.tsx +43 -0
- package/components/ui/hstack/index.tsx +27 -0
- package/components/ui/hstack/index.web.tsx +26 -0
- package/components/ui/hstack/styles.tsx +25 -0
- package/components/ui/icon/index.tsx +1588 -0
- package/components/ui/icon/index.web.tsx +1573 -0
- package/components/ui/image/index.tsx +48 -0
- package/components/ui/image-background/index.tsx +25 -0
- package/components/ui/image-viewer/index.tsx +743 -0
- package/components/ui/image-viewer/index.web.tsx +302 -0
- package/components/ui/index.ts +58 -0
- package/components/ui/input/index.tsx +125 -0
- package/components/ui/input-accessory-view/index.tsx +2 -0
- package/components/ui/keyboard-avoiding-view/index.tsx +2 -0
- package/components/ui/link/index.tsx +102 -0
- package/components/ui/liquid-glass/index.tsx +74 -0
- package/components/ui/menu/index.tsx +186 -0
- package/components/ui/modal/index.tsx +237 -0
- package/components/ui/popover/index.tsx +272 -0
- package/components/ui/portal/index.tsx +17 -0
- package/components/ui/pressable/index.tsx +39 -0
- package/components/ui/progress/index.tsx +83 -0
- package/components/ui/radio/index.tsx +217 -0
- package/components/ui/refresh-control/index.tsx +2 -0
- package/components/ui/safe-area-view/index.tsx +2 -0
- package/components/ui/scroll-view/index.tsx +2 -0
- package/components/ui/section-list/index.tsx +2 -0
- package/components/ui/select/index.tsx +277 -0
- package/components/ui/select/select-actionsheet.tsx +562 -0
- package/components/ui/skeleton/index.tsx +105 -0
- package/components/ui/skeleton/index.web.tsx +103 -0
- package/components/ui/skeleton/styles.tsx +35 -0
- package/components/ui/slider/index.tsx +181 -0
- package/components/ui/spinner/index.tsx +40 -0
- package/components/ui/status-bar/index.tsx +2 -0
- package/components/ui/switch/index.tsx +41 -0
- package/components/ui/table/index.tsx +210 -0
- package/components/ui/table/index.web.tsx +157 -0
- package/components/ui/table/styles.tsx +44 -0
- package/components/ui/tabs/TabsAnimatedIndicator.tsx +160 -0
- package/components/ui/tabs/animation-config.ts +3 -0
- package/components/ui/tabs/creator.tsx +206 -0
- package/components/ui/tabs/index.tsx +484 -0
- package/components/ui/text/index.tsx +48 -0
- package/components/ui/text/index.web.tsx +45 -0
- package/components/ui/text/styles.tsx +47 -0
- package/components/ui/textarea/index.tsx +94 -0
- package/components/ui/toast/index.tsx +252 -0
- package/components/ui/tooltip/index.tsx +131 -0
- package/components/ui/view/index.tsx +2 -0
- package/components/ui/virtualized-list/index.tsx +2 -0
- package/components/ui/vstack/index.tsx +28 -0
- package/components/ui/vstack/index.web.tsx +27 -0
- package/components/ui/vstack/styles.tsx +25 -0
- package/design/canonical.index.txt +53 -0
- package/design/documentation.xml +519 -0
- package/design/manifest.xml +90 -0
- package/design/schema.xsd +639 -0
- package/design/themes.xml +204 -0
- package/design/tokens.xml +510 -0
- package/design/tools/design.js +165 -0
- package/design/tools/npm.js +65 -0
- package/design/tools/requirements.txt +35 -0
- package/design/tools/sources/.checker/__init__.py +81 -0
- package/design/tools/sources/.checker/checks.py +198 -0
- package/design/tools/sources/.checker/cli.py +154 -0
- package/design/tools/sources/.checker/io.py +242 -0
- package/design/tools/sources/.checker/model.py +144 -0
- package/design/tools/sources/.checker/registry.py +115 -0
- package/design/tools/sources/.checker/report.py +21 -0
- package/design/tools/sources/.docgen/__init__.py +45 -0
- package/design/tools/sources/.docgen/cli.py +101 -0
- package/design/tools/sources/.docgen/model.py +147 -0
- package/design/tools/sources/.docgen/reference.py +97 -0
- package/design/tools/sources/.docgen/site.py +145 -0
- package/design/tools/sources/.docgen/xsddoc.py +329 -0
- package/design/tools/sources/.generate/__init__.py +35 -0
- package/design/tools/sources/.generate/cli.py +76 -0
- package/design/tools/sources/.generate/common.py +33 -0
- package/design/tools/sources/.generate/config.py +119 -0
- package/design/tools/sources/.generate/model.py +51 -0
- package/design/tools/sources/.generate/tokens.py +141 -0
- package/design/tools/sources/.linter/__init__.py +9 -0
- package/design/tools/sources/.linter/cli.py +44 -0
- package/design/tools/sources/.linter/discovery.py +30 -0
- package/design/tools/sources/.linter/errors.py +45 -0
- package/design/tools/sources/.linter/linter.py +68 -0
- package/design/tools/sources/.xmleditor/__init__.py +74 -0
- package/design/tools/sources/.xmleditor/blocks.py +185 -0
- package/design/tools/sources/.xmleditor/cli.py +141 -0
- package/design/tools/sources/.xmleditor/editor.py +906 -0
- package/design/tools/sources/.xmleditor/model.py +708 -0
- package/design/tools/sources/.xmleditor/widgets.py +1832 -0
- package/design/tools/sources/.xmleditor/xsdmodel.py +753 -0
- package/design/tools/sources/checker.py +55 -0
- package/design/tools/sources/docgen.py +66 -0
- package/design/tools/sources/generate.py +48 -0
- package/design/tools/sources/linter.py +54 -0
- package/design/tools/sources/ruff.toml +12 -0
- package/design/tools/sources/xmleditor.py +62 -0
- package/design/tools/unix/_venv_python.sh +16 -0
- package/design/tools/unix/check.sh +13 -0
- package/design/tools/unix/doc.sh +14 -0
- package/design/tools/unix/gen.sh +14 -0
- package/design/tools/unix/lint.sh +10 -0
- package/design/tools/unix/run.sh +20 -0
- package/design/tools/unix/verify.sh +12 -0
- package/design/tools/unix/xmledit.sh +12 -0
- package/design/tools/windows/check.cmd +12 -0
- package/design/tools/windows/doc.cmd +12 -0
- package/design/tools/windows/gen.cmd +11 -0
- package/design/tools/windows/lint.cmd +9 -0
- package/design/tools/windows/run.cmd +26 -0
- package/design/tools/windows/verify.cmd +10 -0
- package/design/tools/windows/xmledit.cmd +10 -0
- package/dist/chunk-LV4UIEQN.js +9730 -0
- package/dist/chunk-LV4UIEQN.js.map +1 -0
- package/dist/chunk-WNVU3BM2.mjs +9401 -0
- package/dist/chunk-WNVU3BM2.mjs.map +1 -0
- package/dist/index.d.mts +40 -9
- package/dist/index.d.ts +40 -9
- package/dist/index.js +726 -414
- package/dist/index.mjs +1 -5
- package/dist/ui/index.d.mts +6931 -3070
- package/dist/ui/index.d.ts +6931 -3070
- package/dist/ui/index.js +779 -352
- package/dist/ui/index.mjs +1 -2
- package/package.json +66 -142
- package/dist/chunk-2XORADW6.js +0 -24552
- package/dist/chunk-2XORADW6.js.map +0 -1
- package/dist/chunk-52BHHF5M.js +0 -46
- package/dist/chunk-52BHHF5M.js.map +0 -1
- package/dist/chunk-5647JY7Z.mjs +0 -100
- package/dist/chunk-5647JY7Z.mjs.map +0 -1
- package/dist/chunk-5N5HC4ZA.mjs +0 -3
- package/dist/chunk-5N5HC4ZA.mjs.map +0 -1
- package/dist/chunk-7QFZMGL6.js +0 -8583
- package/dist/chunk-7QFZMGL6.js.map +0 -1
- package/dist/chunk-ASZEP37D.js +0 -423
- package/dist/chunk-ASZEP37D.js.map +0 -1
- package/dist/chunk-BH5SU2JQ.mjs +0 -8282
- package/dist/chunk-BH5SU2JQ.mjs.map +0 -1
- package/dist/chunk-BO65GO53.mjs +0 -422
- package/dist/chunk-BO65GO53.mjs.map +0 -1
- package/dist/chunk-BSVXX52E.mjs +0 -413
- package/dist/chunk-BSVXX52E.mjs.map +0 -1
- package/dist/chunk-DNV5UBNF.mjs +0 -3
- package/dist/chunk-DNV5UBNF.mjs.map +0 -1
- package/dist/chunk-EDTAMUO2.js +0 -8310
- package/dist/chunk-EDTAMUO2.js.map +0 -1
- package/dist/chunk-IJTI6EX4.js +0 -4
- package/dist/chunk-IJTI6EX4.js.map +0 -1
- package/dist/chunk-M3YLASM2.js +0 -428
- package/dist/chunk-M3YLASM2.js.map +0 -1
- package/dist/chunk-OXKOGLXE.js +0 -4
- package/dist/chunk-OXKOGLXE.js.map +0 -1
- package/dist/chunk-RQXQK3ZO.mjs +0 -8486
- package/dist/chunk-RQXQK3ZO.mjs.map +0 -1
- package/dist/chunk-SR25V4EA.mjs +0 -40
- package/dist/chunk-SR25V4EA.mjs.map +0 -1
- package/dist/chunk-UB34WFEQ.js +0 -106
- package/dist/chunk-UB34WFEQ.js.map +0 -1
- package/dist/chunk-ZBRWXKDF.mjs +0 -24431
- package/dist/chunk-ZBRWXKDF.mjs.map +0 -1
- package/dist/cli/ds.d.mts +0 -1
- package/dist/cli/ds.d.ts +0 -1
- package/dist/cli/ds.js +0 -602
- package/dist/cli/ds.js.map +0 -1
- package/dist/cli/ds.mjs +0 -579
- package/dist/cli/ds.mjs.map +0 -1
- package/dist/cli/flipova.d.mts +0 -1
- package/dist/cli/flipova.d.ts +0 -1
- package/dist/cli/flipova.js +0 -161
- package/dist/cli/flipova.js.map +0 -1
- package/dist/cli/flipova.mjs +0 -154
- package/dist/cli/flipova.mjs.map +0 -1
- package/dist/config/index.d.mts +0 -123
- package/dist/config/index.d.ts +0 -123
- package/dist/config/index.js +0 -28
- package/dist/config/index.js.map +0 -1
- package/dist/config/index.mjs +0 -3
- package/dist/config/index.mjs.map +0 -1
- package/dist/index-CuaJA3gM.d.mts +0 -78
- package/dist/index-CuaJA3gM.d.ts +0 -78
- package/dist/registry/index.d.mts +0 -10160
- package/dist/registry/index.d.ts +0 -10160
- package/dist/registry/index.js +0 -392
- package/dist/registry/index.js.map +0 -1
- package/dist/registry/index.mjs +0 -3
- package/dist/registry/index.mjs.map +0 -1
- package/dist/theme/index.d.mts +0 -109
- package/dist/theme/index.d.ts +0 -109
- package/dist/theme/index.js +0 -28
- package/dist/theme/index.js.map +0 -1
- package/dist/theme/index.mjs +0 -3
- package/dist/theme/index.mjs.map +0 -1
- package/dist/tokens/index.d.mts +0 -423
- package/dist/tokens/index.d.ts +0 -423
- package/dist/tokens/index.js +0 -44
- package/dist/tokens/index.js.map +0 -1
- package/dist/tokens/index.mjs +0 -3
- package/dist/tokens/index.mjs.map +0 -1
- package/dist/types/index.d.mts +0 -202
- package/dist/types/index.d.ts +0 -202
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -3
- package/dist/types/index.mjs.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* Project-local entry point for the design tool shipped with the package. */
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const { spawnSync } = require('child_process');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
const packageDesign = path.resolve(__dirname, '..');
|
|
10
|
+
const packageRoot = path.resolve(packageDesign, '..');
|
|
11
|
+
const projectRoot = process.cwd();
|
|
12
|
+
const projectDesign = path.join(projectRoot, 'design');
|
|
13
|
+
const packageGluestack = path.join(packageRoot, 'foundation', 'gluestack');
|
|
14
|
+
const projectGluestack = path.join(projectRoot, 'foundation', 'gluestack');
|
|
15
|
+
const tool = path.join(packageDesign, 'tools', 'design.js');
|
|
16
|
+
|
|
17
|
+
function copyDesign() {
|
|
18
|
+
if (fs.existsSync(projectDesign)) {
|
|
19
|
+
process.stderr.write(`A design directory already exists at ${projectDesign}.\n`);
|
|
20
|
+
process.stderr.write('Use the existing project design files, or remove it before init.\n');
|
|
21
|
+
process.exit(2);
|
|
22
|
+
}
|
|
23
|
+
if (fs.existsSync(projectGluestack)) {
|
|
24
|
+
process.stderr.write(`A gluestack source directory already exists at ${projectGluestack}.\n`);
|
|
25
|
+
process.stderr.write('Use the existing project sources, or remove it before init.\n');
|
|
26
|
+
process.exit(2);
|
|
27
|
+
}
|
|
28
|
+
fs.cpSync(packageDesign, projectDesign, {
|
|
29
|
+
recursive: true,
|
|
30
|
+
filter: (source) => !source.endsWith(`${path.sep}.venv`)
|
|
31
|
+
&& !source.includes(`${path.sep}.venv${path.sep}`)
|
|
32
|
+
&& !source.endsWith(`${path.sep}__pycache__`)
|
|
33
|
+
&& !source.includes(`${path.sep}__pycache__${path.sep}`),
|
|
34
|
+
});
|
|
35
|
+
if (fs.existsSync(packageGluestack)) {
|
|
36
|
+
fs.cpSync(packageGluestack, projectGluestack, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
process.stdout.write(`Initialized ${projectDesign}\n`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const [command, ...args] = process.argv.slice(2);
|
|
42
|
+
if (command === 'init') {
|
|
43
|
+
copyDesign();
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!fs.existsSync(path.join(projectDesign, 'schema.xsd'))) {
|
|
48
|
+
process.stderr.write('No local design directory found. Run "npx flipova-design init" first.\n');
|
|
49
|
+
process.exit(2);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const result = spawnSync(process.execPath, [tool, command || 'edit', ...args], {
|
|
53
|
+
cwd: projectRoot,
|
|
54
|
+
env: {
|
|
55
|
+
...process.env,
|
|
56
|
+
FOUNDATION_DESIGN_DIR: projectDesign,
|
|
57
|
+
FOUNDATION_PROJECT_ROOT: projectRoot,
|
|
58
|
+
},
|
|
59
|
+
stdio: 'inherit',
|
|
60
|
+
});
|
|
61
|
+
if (result.error) {
|
|
62
|
+
process.stderr.write(`${result.error}\n`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
process.exit(result.status == null ? 1 : result.status);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Python runtime requirements for the design-system toolchain
|
|
2
|
+
# design/tools/sources/linter.py (agnostic XML <-> XSD validator)
|
|
3
|
+
# design/tools/sources/checker.py (manifest determinism rules + XSD pass
|
|
4
|
+
# + ruff lint of design/tools/sources)
|
|
5
|
+
# design/tools/sources/generate.py (tokens/themes -> gluestack config)
|
|
6
|
+
# design/tools/sources/docgen.py (documentation site generator)
|
|
7
|
+
# design/tools/sources/xmleditor.py (visual XSD-driven XML block editor:
|
|
8
|
+
# tkinter GUI + headless CLI)
|
|
9
|
+
#
|
|
10
|
+
# All tools require Python 3.8+.
|
|
11
|
+
#
|
|
12
|
+
# In CI the tooling is installed on a pinned interpreter (3.12) with
|
|
13
|
+
# `pip install --only-binary=:all:`. Wheels are mandatory here: `lxml < 6` has
|
|
14
|
+
# no wheel for the newest CPython, and building it from source needs the
|
|
15
|
+
# libxml2/libxslt development headers that the runners do not provide. Pinning
|
|
16
|
+
# the interpreter in the workflows keeps this a fast, deterministic install.
|
|
17
|
+
# Third-party dependencies:
|
|
18
|
+
# lxml ElementTree / XMLSchema backend — used by every tool
|
|
19
|
+
# ruff Python linter — run automatically by checker.py --check
|
|
20
|
+
# (i.e. by npm run design:check / design:pipeline)
|
|
21
|
+
#
|
|
22
|
+
# tkinter (the XML editor's GUI) ships with the standard library; headless
|
|
23
|
+
# CLI modes of xmleditor.py do not need it. On minimal Linux images install
|
|
24
|
+
# it with your package manager (e.g. apt install python3-tk).
|
|
25
|
+
#
|
|
26
|
+
# Install with:
|
|
27
|
+
# python3 -m pip install -r design/tools/requirements.txt
|
|
28
|
+
# or
|
|
29
|
+
# pip install -r design/tools/requirements.txt
|
|
30
|
+
|
|
31
|
+
lxml>=4.7,<6
|
|
32
|
+
# Floor at 0.16.9: EXE001 (shebang without the executable bit) only exists on
|
|
33
|
+
# POSIX, so a Windows developer must run the same linter version as CI to see
|
|
34
|
+
# what CI sees. Bump this floor whenever a newer ruff adds a rule.
|
|
35
|
+
ruff>=0.16.9,<1
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Flipova Foundation determinism checker (implementation package).
|
|
2
|
+
|
|
3
|
+
Split out of the historical ``checker.py`` monolith for modularity:
|
|
4
|
+
|
|
5
|
+
- ``model.py`` : Rule/Diagnostic/RegistryModel, reference resolution
|
|
6
|
+
- ``registry.py`` : handler registry, target expansion, ordering checks
|
|
7
|
+
- ``checks.py`` : one handler per rule kind (ids, ordering, references,
|
|
8
|
+
timestamps, locale, style, sync)
|
|
9
|
+
- ``io.py`` : build_model, canonical index, sync-version, XSD pass
|
|
10
|
+
- ``cli.py`` : argument parsing & dispatch (``main``)
|
|
11
|
+
- ``report.py`` : Report (diagnostics collector)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from .checks import (
|
|
17
|
+
handler_ids,
|
|
18
|
+
handler_locale,
|
|
19
|
+
handler_ordering,
|
|
20
|
+
handler_references,
|
|
21
|
+
handler_sync,
|
|
22
|
+
handler_timestamps,
|
|
23
|
+
)
|
|
24
|
+
from .cli import main
|
|
25
|
+
from .io import (
|
|
26
|
+
build_model,
|
|
27
|
+
canonical_document,
|
|
28
|
+
canonical_payload,
|
|
29
|
+
resolve_reference_value,
|
|
30
|
+
sync_versions,
|
|
31
|
+
validate_xsd,
|
|
32
|
+
)
|
|
33
|
+
from .model import (
|
|
34
|
+
Diagnostic,
|
|
35
|
+
RegistryModel,
|
|
36
|
+
Rule,
|
|
37
|
+
cap,
|
|
38
|
+
localname,
|
|
39
|
+
natural_key,
|
|
40
|
+
q,
|
|
41
|
+
resolve_reference,
|
|
42
|
+
slug,
|
|
43
|
+
)
|
|
44
|
+
from .registry import HANDLERS, expand_targets, iter_files, register
|
|
45
|
+
from .report import Report
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
# registry
|
|
49
|
+
"HANDLERS",
|
|
50
|
+
# model
|
|
51
|
+
"Diagnostic",
|
|
52
|
+
"RegistryModel",
|
|
53
|
+
# report
|
|
54
|
+
"Report",
|
|
55
|
+
"Rule",
|
|
56
|
+
# io
|
|
57
|
+
"build_model",
|
|
58
|
+
"canonical_document",
|
|
59
|
+
"canonical_payload",
|
|
60
|
+
"cap",
|
|
61
|
+
"expand_targets",
|
|
62
|
+
# checks
|
|
63
|
+
"handler_ids",
|
|
64
|
+
"handler_locale",
|
|
65
|
+
"handler_ordering",
|
|
66
|
+
"handler_references",
|
|
67
|
+
"handler_sync",
|
|
68
|
+
"handler_timestamps",
|
|
69
|
+
"iter_files",
|
|
70
|
+
"localname",
|
|
71
|
+
# cli
|
|
72
|
+
"main",
|
|
73
|
+
"natural_key",
|
|
74
|
+
"q",
|
|
75
|
+
"register",
|
|
76
|
+
"resolve_reference",
|
|
77
|
+
"resolve_reference_value",
|
|
78
|
+
"slug",
|
|
79
|
+
"sync_versions",
|
|
80
|
+
"validate_xsd",
|
|
81
|
+
]
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from lxml import etree
|
|
7
|
+
|
|
8
|
+
from .model import RegistryModel, Rule, localname
|
|
9
|
+
from .registry import register
|
|
10
|
+
from .report import Report
|
|
11
|
+
|
|
12
|
+
# ---------------------------------------------------------------------------
|
|
13
|
+
# kind: ids
|
|
14
|
+
# ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
NON_ASCII_RE = re.compile(r"[^\x00-\x7F]")
|
|
17
|
+
TIMESTAMP_RE = re.compile(
|
|
18
|
+
r"\b\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2})?(?:Zz|[+-]\d{2}:?\d{2})?"
|
|
19
|
+
r"|\b\d{4}-\d{2}-\d{2}\b"
|
|
20
|
+
r"|\b1[5-9]\d{8}\b"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@register("ids")
|
|
25
|
+
def handler_ids(ctx: RegistryModel, rule: Rule, targets: list[Path], report: Report) -> None:
|
|
26
|
+
pattern = rule.get("pattern") or r"^[A-Za-z][A-Za-z0-9]*$"
|
|
27
|
+
selectors = set(rule.get_list("selectors", ["token", "theme", "role", "item", "register"]))
|
|
28
|
+
regex = re.compile(pattern)
|
|
29
|
+
for path in targets:
|
|
30
|
+
doc = etree.parse(str(path))
|
|
31
|
+
for elem in doc.iter():
|
|
32
|
+
name = localname(elem.tag)
|
|
33
|
+
if name not in selectors:
|
|
34
|
+
continue
|
|
35
|
+
ident = elem.get("id")
|
|
36
|
+
if ident is None:
|
|
37
|
+
ident = elem.get("register") or elem.get("name")
|
|
38
|
+
if ident is None and name in ("item", "field", "key", "register"):
|
|
39
|
+
ident = (elem.text or "").strip()
|
|
40
|
+
if not ident:
|
|
41
|
+
continue
|
|
42
|
+
if not regex.fullmatch(ident):
|
|
43
|
+
report.add(rule, str(path), elem.sourceline,
|
|
44
|
+
f"id {ident!r} violates stable-slug pattern {pattern!r} (explicit uid, otherwise stable slug)")
|
|
45
|
+
if ident in ctx.reserves:
|
|
46
|
+
report.add(rule, str(path), elem.sourceline,
|
|
47
|
+
"id {!r} is a reserved word ({})".format(ident, ", ".join(ctx.reserves)))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# ---------------------------------------------------------------------------
|
|
51
|
+
# kind: ordering
|
|
52
|
+
# ---------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@register("ordering")
|
|
56
|
+
def handler_ordering(ctx: RegistryModel, rule: Rule, targets: list[Path], report: Report) -> None:
|
|
57
|
+
mode = rule.get("mode") or "registers"
|
|
58
|
+
if mode == "registers":
|
|
59
|
+
_check_register_order(ctx, rule, report)
|
|
60
|
+
elif mode == "siblings":
|
|
61
|
+
selectors = rule.get_list("selectors", [])
|
|
62
|
+
for path in targets:
|
|
63
|
+
_check_sibling_order(path, rule, selectors, report)
|
|
64
|
+
else:
|
|
65
|
+
report.add(rule, ctx.manifest_path.name, None,
|
|
66
|
+
f"unknown ordering mode {mode!r} (expected 'registers' or 'siblings')")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _check_register_order(ctx: RegistryModel, rule: Rule, report: Report) -> None:
|
|
70
|
+
from .registry import _check_register_order as impl
|
|
71
|
+
|
|
72
|
+
impl(ctx, rule, report)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _check_sibling_order(path: Path, rule: Rule, selectors: list[str], report: Report) -> None:
|
|
76
|
+
from .registry import _check_sibling_order as impl
|
|
77
|
+
|
|
78
|
+
impl(path, rule, selectors, report)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# ---------------------------------------------------------------------------
|
|
82
|
+
# kind: references
|
|
83
|
+
# ---------------------------------------------------------------------------
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@register("references")
|
|
87
|
+
def handler_references(ctx: RegistryModel, rule: Rule, targets: list[Path], report: Report) -> None:
|
|
88
|
+
from .model import resolve_reference
|
|
89
|
+
|
|
90
|
+
pattern = rule.get("pattern")
|
|
91
|
+
regex = re.compile(pattern) if pattern else None
|
|
92
|
+
for path in targets:
|
|
93
|
+
doc = etree.parse(str(path))
|
|
94
|
+
for elem in doc.iter():
|
|
95
|
+
if localname(elem.tag) != "ref":
|
|
96
|
+
continue
|
|
97
|
+
ref = (elem.text or "").strip()
|
|
98
|
+
if not ref:
|
|
99
|
+
continue
|
|
100
|
+
if regex and not regex.fullmatch(ref):
|
|
101
|
+
report.add(rule, str(path), elem.sourceline,
|
|
102
|
+
f"reference {ref!r} violates format pattern {pattern!r} (expected $ref.<register>.<id>.<path> or <id>.<path>)")
|
|
103
|
+
if not resolve_reference(ctx, ref):
|
|
104
|
+
report.add(rule, str(path), elem.sourceline,
|
|
105
|
+
f"dangling reference {ref!r}: no token value matches (never implicit links)")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# ---------------------------------------------------------------------------
|
|
109
|
+
# kind: timestamps
|
|
110
|
+
# ---------------------------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@register("timestamps")
|
|
114
|
+
def handler_timestamps(ctx: RegistryModel, rule: Rule, targets: list[Path], report: Report) -> None:
|
|
115
|
+
for path in targets:
|
|
116
|
+
doc = etree.parse(str(path))
|
|
117
|
+
for elem in doc.iter():
|
|
118
|
+
values = []
|
|
119
|
+
if elem.text and elem.text.strip():
|
|
120
|
+
values.append(elem.text)
|
|
121
|
+
values.extend(attr for attr in elem.attrib.values() if attr and attr.strip())
|
|
122
|
+
for value in values:
|
|
123
|
+
match = TIMESTAMP_RE.search(value)
|
|
124
|
+
if match:
|
|
125
|
+
report.add(rule, str(path), elem.sourceline,
|
|
126
|
+
f"timestamp forbidden: found {match.group(0)!r} (bit-identical rebuilds require no date/time literal)")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
# ---------------------------------------------------------------------------
|
|
130
|
+
# kind: locale
|
|
131
|
+
# ---------------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@register("locale")
|
|
135
|
+
def handler_locale(ctx: RegistryModel, rule: Rule, targets: list[Path], report: Report) -> None:
|
|
136
|
+
# Free-text elements are documentation/labels, not identifiers or design
|
|
137
|
+
# values: they may be localized/prose and are exempt (manifest-declared).
|
|
138
|
+
exempt_tags = set(rule.get_list("exemptTags", ["label", "description", "content"]))
|
|
139
|
+
# Optional manifest-declared exempt subtrees (none by default).
|
|
140
|
+
exempt_subtrees = set(rule.get_list("exemptSubtrees", []))
|
|
141
|
+
# Prose attribute names (example/showcase titles & descriptions).
|
|
142
|
+
exempt_attrs = set(rule.get_list("exemptAttrs", ["title", "description"]))
|
|
143
|
+
for path in targets:
|
|
144
|
+
doc = etree.parse(str(path))
|
|
145
|
+
for elem in doc.iter():
|
|
146
|
+
if localname(elem.tag) in exempt_tags:
|
|
147
|
+
continue
|
|
148
|
+
parent = elem.getparent()
|
|
149
|
+
in_subtree = False
|
|
150
|
+
while parent is not None:
|
|
151
|
+
if localname(parent.tag) in exempt_subtrees:
|
|
152
|
+
in_subtree = True
|
|
153
|
+
break
|
|
154
|
+
parent = parent.getparent()
|
|
155
|
+
if in_subtree:
|
|
156
|
+
continue
|
|
157
|
+
values = []
|
|
158
|
+
if elem.text and elem.text.strip():
|
|
159
|
+
values.append(elem.text)
|
|
160
|
+
for attr_name, attr in elem.attrib.items():
|
|
161
|
+
if not attr or not attr.strip():
|
|
162
|
+
continue
|
|
163
|
+
if localname(attr_name) in exempt_attrs:
|
|
164
|
+
continue
|
|
165
|
+
# static:<payload> binds are display literals, not identifiers.
|
|
166
|
+
if attr.startswith("static:"):
|
|
167
|
+
attr = "static:"
|
|
168
|
+
values.append(attr)
|
|
169
|
+
for value in values:
|
|
170
|
+
match = NON_ASCII_RE.search(value)
|
|
171
|
+
if match:
|
|
172
|
+
report.add(rule, str(path), elem.sourceline,
|
|
173
|
+
f"locale forbidden in values: non-ASCII {match.group(0)!r} in {value.strip()!r} (allowed only in labels/comments)")
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
# --- kind: sync (manifest version / schema propagation) ---------------------
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
@register("sync")
|
|
180
|
+
def handler_sync(ctx: RegistryModel, rule: Rule, targets: list[Path], report: Report) -> None:
|
|
181
|
+
"""The manifest owns the registry namespace (@schema): every root that
|
|
182
|
+
declares it must carry the manifest value (run `checker.py --sync-version`
|
|
183
|
+
to fix drifted files in place).
|
|
184
|
+
|
|
185
|
+
The project version is NOT part of this: it lives in the root package.json
|
|
186
|
+
and is never duplicated in the XML, so it cannot drift.
|
|
187
|
+
"""
|
|
188
|
+
for path in targets:
|
|
189
|
+
try:
|
|
190
|
+
doc = etree.parse(str(path))
|
|
191
|
+
except etree.XMLSyntaxError as exc:
|
|
192
|
+
report.add(rule, str(path), exc.lineno, f"malformed XML: {exc.msg}")
|
|
193
|
+
continue
|
|
194
|
+
root = doc.getroot()
|
|
195
|
+
schema = root.get("schema")
|
|
196
|
+
if ctx.schema_id and schema is not None and schema != ctx.schema_id:
|
|
197
|
+
report.add(rule, str(path), 1,
|
|
198
|
+
f"root @schema {schema!r} != manifest @schema {ctx.schema_id!r} -- run `checker.py --sync-version`")
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import re
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from .io import build_model, canonical_document, sync_versions, validate_xsd
|
|
10
|
+
from .model import Diagnostic
|
|
11
|
+
from .registry import HANDLERS, expand_targets
|
|
12
|
+
from .report import Report
|
|
13
|
+
|
|
14
|
+
# design/tools/sources/.checker/cli.py -> design/tools/sources
|
|
15
|
+
SOURCES_DIR = Path(__file__).resolve().parents[1]
|
|
16
|
+
RUFF_CONFIG = SOURCES_DIR / "ruff.toml"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def run_ruff(report: Report, verbose: bool) -> None:
|
|
20
|
+
"""Lint the toolchain's Python sources with ruff (part of ``--check``).
|
|
21
|
+
|
|
22
|
+
Runs the project's interpreter (``python -m ruff``) over every script and
|
|
23
|
+
dot-package under ``design/tools/sources`` with the same ``ruff.toml`` the
|
|
24
|
+
editors use, so ``npm run design:check`` gates Python style next to the
|
|
25
|
+
manifest determinism rules.
|
|
26
|
+
"""
|
|
27
|
+
cmd = [sys.executable, "-m", "ruff", "check",
|
|
28
|
+
"--config", str(RUFF_CONFIG),
|
|
29
|
+
"--output-format", "concise", "--quiet", "."]
|
|
30
|
+
if verbose:
|
|
31
|
+
print(f"ruff: {' '.join(cmd)} (cwd={SOURCES_DIR})")
|
|
32
|
+
try:
|
|
33
|
+
proc = subprocess.run(cmd, capture_output=True, text=True, cwd=str(SOURCES_DIR),
|
|
34
|
+
check=False)
|
|
35
|
+
except OSError as exc:
|
|
36
|
+
report.diagnostics.append(Diagnostic(
|
|
37
|
+
"ruff", "error", str(RUFF_CONFIG), None, f"cannot run ruff: {exc}"))
|
|
38
|
+
return
|
|
39
|
+
stderr = (proc.stderr or "").strip()
|
|
40
|
+
if proc.returncode not in (0, 1):
|
|
41
|
+
# Not lint results: ruff is missing or the invocation failed.
|
|
42
|
+
first = stderr.splitlines()[0] if stderr else f"exit code {proc.returncode}"
|
|
43
|
+
report.diagnostics.append(Diagnostic(
|
|
44
|
+
"ruff", "error", str(RUFF_CONFIG), None,
|
|
45
|
+
f"ruff failed to run ({first}); install it with: "
|
|
46
|
+
"pip install -r design/tools/requirements.txt"))
|
|
47
|
+
return
|
|
48
|
+
seen = 0
|
|
49
|
+
for line in (proc.stdout or "").splitlines():
|
|
50
|
+
line = line.strip()
|
|
51
|
+
if not line:
|
|
52
|
+
continue
|
|
53
|
+
seen += 1
|
|
54
|
+
match = re.match(r"^(?P<file>.+?):(?P<line>\d+):\d+: (?P<code>\S+) (?P<msg>.+)$", line)
|
|
55
|
+
if match is None:
|
|
56
|
+
report.diagnostics.append(Diagnostic(
|
|
57
|
+
"ruff", "error", str(SOURCES_DIR), None, line))
|
|
58
|
+
continue
|
|
59
|
+
report.diagnostics.append(Diagnostic(
|
|
60
|
+
"ruff", "error", match.group("file"), int(match.group("line")),
|
|
61
|
+
f"{match.group('code')}: {match.group('msg')}"))
|
|
62
|
+
if seen:
|
|
63
|
+
print(f"ruff: {seen} violation(s) ({SOURCES_DIR})")
|
|
64
|
+
elif verbose:
|
|
65
|
+
print(f"ruff: clean ({SOURCES_DIR})")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def main() -> int:
|
|
69
|
+
parser = argparse.ArgumentParser(
|
|
70
|
+
description="Manifest-driven determinism checker (rules declared in the manifest, not in code)."
|
|
71
|
+
)
|
|
72
|
+
parser.add_argument("--manifest", "-m", required=True, help="Path to manifest.xml")
|
|
73
|
+
parser.add_argument("--root", "-r", default=".", help="Repository root for applyTo globs (default: cwd)")
|
|
74
|
+
parser.add_argument("--schema", "-s", help="Optional XSD schema: validates every XML via linter.py first")
|
|
75
|
+
parser.add_argument("--check", action="store_true",
|
|
76
|
+
help="Run the declared determinism rules + the ruff lint of design/tools/sources (default)")
|
|
77
|
+
parser.add_argument("--list-rules", action="store_true", help="Print the rules declared in the manifest")
|
|
78
|
+
parser.add_argument("--emit-canonical", action="store_true", help="Write the deterministic canonical index")
|
|
79
|
+
parser.add_argument("--out", default=None, help="Output path for --emit-canonical (default: design/canonical.index.txt)")
|
|
80
|
+
parser.add_argument("--verify-canonical", action="store_true", help="Compare committed canonical index with the registry")
|
|
81
|
+
parser.add_argument("--sync-version", action="store_true",
|
|
82
|
+
help="Rewrite @version/@schema on every XML root tag to the manifest values")
|
|
83
|
+
parser.add_argument("--no-ruff", action="store_true",
|
|
84
|
+
help="Skip the ruff lint of design/tools/sources during --check")
|
|
85
|
+
parser.add_argument("--verbose", "-v", action="store_true")
|
|
86
|
+
args = parser.parse_args()
|
|
87
|
+
|
|
88
|
+
root = Path(args.root).resolve()
|
|
89
|
+
manifest_path = Path(args.manifest).resolve()
|
|
90
|
+
ctx = build_model(root, manifest_path)
|
|
91
|
+
|
|
92
|
+
if args.list_rules:
|
|
93
|
+
print("Determinism rules declared in {} (handlers: {}):".format(manifest_path.relative_to(root), ", ".join(sorted(HANDLERS))))
|
|
94
|
+
for rule in ctx.rules:
|
|
95
|
+
status = "registered" if rule.kind in HANDLERS else "NO HANDLER (warning)"
|
|
96
|
+
print(f" - {rule.id} kind={rule.kind} severity={rule.severity} applyTo={rule.apply_to} [{status}]")
|
|
97
|
+
print(f" {rule.description}")
|
|
98
|
+
return 0
|
|
99
|
+
|
|
100
|
+
report = Report()
|
|
101
|
+
|
|
102
|
+
if args.schema:
|
|
103
|
+
xsd_report = validate_xsd(ctx, Path(args.schema), args.verbose)
|
|
104
|
+
report.diagnostics.extend(xsd_report.diagnostics)
|
|
105
|
+
|
|
106
|
+
if args.check:
|
|
107
|
+
for rule in ctx.rules:
|
|
108
|
+
if rule.kind not in HANDLERS:
|
|
109
|
+
report.add(rule, manifest_path.name, None,
|
|
110
|
+
f"no handler registered for kind={rule.kind!r}; rule declared but not enforced yet")
|
|
111
|
+
continue
|
|
112
|
+
targets = expand_targets(root, rule.apply_to)
|
|
113
|
+
HANDLERS[rule.kind](ctx, rule, targets, report)
|
|
114
|
+
if args.verbose:
|
|
115
|
+
print(f"rule {rule.id} [{rule.kind}]: {len(targets)} file(s), "
|
|
116
|
+
f"{sum(1 for d in report.diagnostics if d.rule_id == rule.id)} diagnostic(s)")
|
|
117
|
+
if not args.no_ruff:
|
|
118
|
+
run_ruff(report, args.verbose)
|
|
119
|
+
|
|
120
|
+
if args.emit_canonical:
|
|
121
|
+
out = Path(args.out) if args.out else root / "design" / "canonical.index.txt"
|
|
122
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
123
|
+
out.write_text(canonical_document(ctx), encoding="utf-8")
|
|
124
|
+
print(f"canonical index written to {out}")
|
|
125
|
+
|
|
126
|
+
if args.verify_canonical:
|
|
127
|
+
canonical_path = Path(args.out) if args.out else root / "design" / "canonical.index.txt"
|
|
128
|
+
if not canonical_path.exists():
|
|
129
|
+
report.diagnostics.append(Diagnostic(
|
|
130
|
+
"canonical", "error", str(canonical_path), None,
|
|
131
|
+
"canonical index file missing; run --emit-canonical"
|
|
132
|
+
))
|
|
133
|
+
else:
|
|
134
|
+
committed = canonical_path.read_text(encoding="utf-8").strip()
|
|
135
|
+
expected = canonical_document(ctx).strip()
|
|
136
|
+
if committed != expected:
|
|
137
|
+
report.diagnostics.append(Diagnostic(
|
|
138
|
+
"canonical", "error", str(canonical_path), None,
|
|
139
|
+
"canonical index drifted from the registry; run --emit-canonical and commit the new file"
|
|
140
|
+
))
|
|
141
|
+
|
|
142
|
+
if args.sync_version:
|
|
143
|
+
synced = sync_versions(ctx)
|
|
144
|
+
print(f"sync-version: {synced} file(s) updated (version={ctx.version!r} schema={ctx.schema_id!r})")
|
|
145
|
+
|
|
146
|
+
for diag in report.diagnostics:
|
|
147
|
+
print(f" {diag}")
|
|
148
|
+
errors = report.errors
|
|
149
|
+
print(f"checker: {len(errors)} error(s), {len(report.warnings)} warning(s)")
|
|
150
|
+
return 1 if errors else 0
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
if __name__ == "__main__":
|
|
154
|
+
sys.exit(main())
|