@pixelinfinito/gravity-ui-compliance-truecanvas 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +43 -2
- package/dist/audit/index.d.ts +52 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +1058 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +435 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/overlay/constants.d.ts +3 -0
- package/dist/overlay/constants.d.ts.map +1 -0
- package/dist/overlay/constants.js +3 -0
- package/dist/overlay/constants.js.map +1 -0
- package/dist/overlay/index.d.ts +43 -0
- package/dist/overlay/index.d.ts.map +1 -0
- package/dist/overlay/index.js +144 -0
- package/dist/overlay/index.js.map +1 -0
- package/dist/provider/index.d.ts +42 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/index.js +91 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/starter/index.d.ts +50 -0
- package/dist/starter/index.d.ts.map +1 -0
- package/dist/starter/index.js +375 -0
- package/dist/starter/index.js.map +1 -0
- package/dist/templates/truecanvas/gitignore.snippet +3 -0
- package/dist/templates/truecanvas/starter.canvas.tsx +32 -0
- package/dist/templates/truecanvas/truecanvas.config.json +14 -0
- package/dist/version/index.d.ts +26 -0
- package/dist/version/index.d.ts.map +1 -0
- package/dist/version/index.js +143 -0
- package/dist/version/index.js.map +1 -0
- package/dist/watch/index.d.ts +67 -0
- package/dist/watch/index.d.ts.map +1 -0
- package/dist/watch/index.js +970 -0
- package/dist/watch/index.js.map +1 -0
- package/package.json +81 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 pixelinfinito
|
|
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/README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Gravity UI compliance for Truecanvas
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Add live compliance checks and production-build isolation auditing to a Truecanvas project. Use Node.js 22 or newer and React 19 or newer.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install --save-dev @pixelinfinito/gravity-ui-compliance @pixelinfinito/gravity-ui-compliance-truecanvas
|
|
9
|
+
npm install --save-dev --save-exact truecanvas@0.7.2
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Add `gravity-ui-compliance.policy.json` at the project root. Adapt the example design-system wrapper, Gravity UI pin, and directories to your project.
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"schemaVersion": 1,
|
|
17
|
+
"designSystem": { "package": "@example/ui", "path": "packages/ui" },
|
|
18
|
+
"gravityAllowlist": { "@gravity-ui/uikit": "7.51.1" },
|
|
19
|
+
"sources": {
|
|
20
|
+
"include": ["src/**/*.{ts,tsx,css}", "packages/ui/src/**/*.{ts,tsx}", "canvas/**/*.canvas.tsx"]
|
|
21
|
+
},
|
|
22
|
+
"forbiddenIntrinsicElements": [{ "selector": "button", "replacement": "Button" }],
|
|
23
|
+
"forbiddenIntrinsicProps": ["on*"],
|
|
24
|
+
"forbiddenClassPrefixes": [".g-"],
|
|
25
|
+
"forbiddenColorLiterals": ["hex", "rgb", "hsl"],
|
|
26
|
+
"truecanvas": {
|
|
27
|
+
"enabled": true,
|
|
28
|
+
"canvasGlobs": ["canvas/**/*.canvas.tsx"],
|
|
29
|
+
"routeDir": ".truecanvas"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Run the gate
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npx gravity-ui-lint check --changed # Modified and untracked files
|
|
38
|
+
npx gravity-ui-lint check --staged # Staged Git snapshot
|
|
39
|
+
npx gravity-ui-lint check # Full policy scope
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Run `npx gravity-ui-lint watch --with-truecanvas` while prototyping and `npx gravity-ui-lint audit-build` after a production build. The package ships starter templates in `dist/templates/truecanvas/`. You can also generate the starter files from your policy with `createStarterBundleFromPolicy` from `@pixelinfinito/gravity-ui-compliance-truecanvas/starter`.
|
|
43
|
+
|
|
44
|
+
[Truecanvas prototyping guide](https://github.com/pixelinfinito/gravity-ui-compliance/blob/main/docs/truecanvas-prototyping.md) · [Registry installation and GitHub Action options](https://github.com/pixelinfinito/gravity-ui-compliance/blob/main/docs/releasing.md)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const PRODUCTION_BUILD_AUDIT_RULE_ID: "gravity-compliance/truecanvas-in-production-build";
|
|
2
|
+
export type AuditFramework = 'next' | 'vite';
|
|
3
|
+
export type AuditFindingCategory = 'missing-build' | 'missing-manifest' | 'invalid-manifest' | 'missing-bundles' | 'missing-routedir' | 'route-manifest' | 'emitted-path' | 'emitted-bundle';
|
|
4
|
+
export interface ProductionBuildAuditFinding {
|
|
5
|
+
category: AuditFindingCategory;
|
|
6
|
+
file: string;
|
|
7
|
+
pattern: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ProductionBuildAuditOptions {
|
|
11
|
+
cwd: string;
|
|
12
|
+
framework?: 'auto' | AuditFramework;
|
|
13
|
+
buildDir?: string;
|
|
14
|
+
routeDir?: string;
|
|
15
|
+
/** Optional Vite deployment base URL prefix (e.g. "/docs/"). Defaults to "/" (root); supply your Vite base for subpath builds. */
|
|
16
|
+
base?: string;
|
|
17
|
+
/**
|
|
18
|
+
* When true, fails closed if `routeDir` is not present on disk (proving the production build
|
|
19
|
+
* stays isolated even when a local Truecanvas session has generated `routeDir` on disk).
|
|
20
|
+
*/
|
|
21
|
+
requireRouteDirOnDisk?: boolean;
|
|
22
|
+
extraForbiddenPatterns?: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface ProductionBuildAuditResult {
|
|
25
|
+
schemaVersion: '1.0.0';
|
|
26
|
+
ok: boolean;
|
|
27
|
+
framework: AuditFramework;
|
|
28
|
+
buildDir: string;
|
|
29
|
+
routeDir: string;
|
|
30
|
+
routeDirPresentOnDisk: boolean;
|
|
31
|
+
inspectedManifests: string[];
|
|
32
|
+
inspectedBundlesCount: number;
|
|
33
|
+
totalInspectedFiles: number;
|
|
34
|
+
findings: ProductionBuildAuditFinding[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Audits production build route manifests and emitted bundles to confirm zero Truecanvas runtime
|
|
38
|
+
* modules, generated `routeDir` routes/files, `.canvas.tsx` files, or dev-only overlay code leak
|
|
39
|
+
* into production builds.
|
|
40
|
+
*/
|
|
41
|
+
export declare function auditProductionBuild(options: ProductionBuildAuditOptions): ProductionBuildAuditResult;
|
|
42
|
+
/**
|
|
43
|
+
* Next.js config wrapper that keeps a locally generated Truecanvas `routeDir` (e.g. `app/truecanvas`)
|
|
44
|
+
* completely excluded from `next build` (`phase-production-build`) by moving it to a recoverable
|
|
45
|
+
* project-local stash on the same filesystem for the duration of the production build and restoring
|
|
46
|
+
* it on process exit.
|
|
47
|
+
*/
|
|
48
|
+
export declare function withTruecanvasIsolation<T extends Record<string, unknown>>(nextConfig: T, options?: {
|
|
49
|
+
cwd?: string;
|
|
50
|
+
routeDir?: string;
|
|
51
|
+
}): (phase: string) => T;
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/audit/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,8BAA8B,EACzC,mDAA4D,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,MAAM,MAAM,oBAAoB,GAC5B,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,CAAC;AAErB,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,2BAA2B;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAA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