wirepulse 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.
@@ -0,0 +1,109 @@
1
+ export type ThemeName = "auto" | "midnight" | "paper" | "blueprint" | "linear" | "terminal";
2
+ export type AccentColor = "cyan" | "violet" | "emerald" | "amber" | "rose" | "blue" | "orange" | "slate";
3
+ export type FlowStyle = "packet" | "dash" | "pulse" | "solid";
4
+ export type FlowSpeed = "slow" | "normal" | "fast";
5
+ export type LayoutDirection = "LR" | "TB";
6
+ export type CurveStyle = "smooth" | "ortho" | "straight";
7
+ export interface DiagramGroup {
8
+ id: string;
9
+ label: string;
10
+ color: AccentColor;
11
+ }
12
+ export interface DiagramNode {
13
+ id: string;
14
+ label: string;
15
+ sublabel?: string;
16
+ icon: string;
17
+ color: AccentColor;
18
+ badge?: string;
19
+ group?: string;
20
+ pulse?: boolean;
21
+ col?: number;
22
+ row?: number;
23
+ x?: number;
24
+ y?: number;
25
+ }
26
+ export interface DiagramEdge {
27
+ id: string;
28
+ from: string;
29
+ to: string;
30
+ label?: string;
31
+ flow: FlowStyle;
32
+ speed?: FlowSpeed;
33
+ color?: AccentColor;
34
+ bidir?: boolean;
35
+ packets?: number;
36
+ curve?: CurveStyle;
37
+ }
38
+ export interface DiagramSpec {
39
+ title?: string;
40
+ subtitle?: string;
41
+ theme: ThemeName;
42
+ direction: LayoutDirection;
43
+ speed: FlowSpeed;
44
+ groups: DiagramGroup[];
45
+ nodes: DiagramNode[];
46
+ edges: DiagramEdge[];
47
+ }
48
+ export interface ParseError {
49
+ line: number;
50
+ message: string;
51
+ }
52
+ export interface ParseResult {
53
+ spec: DiagramSpec;
54
+ errors: ParseError[];
55
+ }
56
+ export interface LayoutNode {
57
+ node: DiagramNode;
58
+ col: number;
59
+ row: number;
60
+ x: number;
61
+ y: number;
62
+ width: number;
63
+ height: number;
64
+ }
65
+ export interface LayoutGroup {
66
+ group: DiagramGroup;
67
+ x: number;
68
+ y: number;
69
+ width: number;
70
+ height: number;
71
+ }
72
+ export interface LayoutEdge {
73
+ edge: DiagramEdge;
74
+ pathD: string;
75
+ reversePathD: string;
76
+ labelX: number;
77
+ labelY: number;
78
+ startX: number;
79
+ startY: number;
80
+ endX: number;
81
+ endY: number;
82
+ color: AccentColor;
83
+ }
84
+ export interface LayoutResult {
85
+ width: number;
86
+ height: number;
87
+ headerHeight: number;
88
+ nodes: LayoutNode[];
89
+ groups: LayoutGroup[];
90
+ edges: LayoutEdge[];
91
+ }
92
+ export interface RenderOptions {
93
+ theme?: ThemeName;
94
+ speedMultiplier?: number;
95
+ paused?: boolean;
96
+ showGrid?: boolean;
97
+ includeWatermark?: boolean;
98
+ }
99
+ export interface ValidationIssue {
100
+ severity: "error" | "warn";
101
+ code: string;
102
+ message: string;
103
+ }
104
+ export interface ValidationResult {
105
+ valid: boolean;
106
+ githubSafe: boolean;
107
+ bytes: number;
108
+ issues: ValidationIssue[];
109
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { ValidationResult } from "./types.js";
2
+ /**
3
+ * Validate that an SVG is well-formed and 100% safe for GitHub READMEs / Camo proxy:
4
+ * - Zero <script> tags
5
+ * - Zero inline on* event handlers (onclick, onload, etc.)
6
+ * - Zero javascript: URIs
7
+ * - Zero external http(s):// asset links or @import rules
8
+ * - Zero <foreignObject> (stripped/broken across many SVG renderers)
9
+ */
10
+ export declare function validateSvg(svg: string): ValidationResult;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Validate that an SVG is well-formed and 100% safe for GitHub READMEs / Camo proxy:
3
+ * - Zero <script> tags
4
+ * - Zero inline on* event handlers (onclick, onload, etc.)
5
+ * - Zero javascript: URIs
6
+ * - Zero external http(s):// asset links or @import rules
7
+ * - Zero <foreignObject> (stripped/broken across many SVG renderers)
8
+ */
9
+ export function validateSvg(svg) {
10
+ const issues = [];
11
+ const bytes = Buffer.byteLength(svg, "utf8");
12
+ const trimmed = svg.trim();
13
+ if (!trimmed.startsWith("<svg") || !trimmed.endsWith("</svg>")) {
14
+ issues.push({
15
+ severity: "error",
16
+ code: "invalid-root",
17
+ message: "SVG must start with <svg and end with </svg>.",
18
+ });
19
+ }
20
+ if (!/xmlns="http:\/\/www\.w3\.org\/2000\/svg"/.test(trimmed)) {
21
+ issues.push({
22
+ severity: "error",
23
+ code: "missing-xmlns",
24
+ message: 'Missing required xmlns="http://www.w3.org/2000/svg" attribute.',
25
+ });
26
+ }
27
+ if (/<script\b/i.test(trimmed)) {
28
+ issues.push({
29
+ severity: "error",
30
+ code: "script-tag",
31
+ message: "Contains <script> tag — blocked by GitHub README CSP & Camo sanitizer.",
32
+ });
33
+ }
34
+ if (/\son[a-z]+\s*=/i.test(trimmed)) {
35
+ issues.push({
36
+ severity: "error",
37
+ code: "inline-event-handler",
38
+ message: "Contains inline on* event handler attribute — blocked by GitHub CSP.",
39
+ });
40
+ }
41
+ if (/javascript\s*:/i.test(trimmed)) {
42
+ issues.push({
43
+ severity: "error",
44
+ code: "javascript-uri",
45
+ message: "Contains javascript: URI — blocked by GitHub CSP.",
46
+ });
47
+ }
48
+ if (/@import\s+/i.test(trimmed)) {
49
+ issues.push({
50
+ severity: "error",
51
+ code: "external-css-import",
52
+ message: "Contains @import CSS rule — external stylesheets fail inside GitHub Camo.",
53
+ });
54
+ }
55
+ // Allow xmlns="http://www.w3.org/2000/svg", flag any other http(s):// href/src/url()
56
+ if (/(?:href|xlink:href|src)\s*=\s*["']https?:\/\//i.test(trimmed)) {
57
+ issues.push({
58
+ severity: "error",
59
+ code: "external-asset-url",
60
+ message: "Contains external http(s):// asset reference — inline all assets for GitHub READMEs.",
61
+ });
62
+ }
63
+ if (/<foreignObject\b/i.test(trimmed)) {
64
+ issues.push({
65
+ severity: "warn",
66
+ code: "foreign-object",
67
+ message: "Contains <foreignObject>, which renders inconsistently across SVG viewers.",
68
+ });
69
+ }
70
+ if (bytes > 250_000) {
71
+ issues.push({
72
+ severity: "warn",
73
+ code: "large-svg",
74
+ message: `SVG is ${(bytes / 1024).toFixed(1)} KB; keep README SVGs under 250 KB for fast page loads.`,
75
+ });
76
+ }
77
+ const hasErrors = issues.some((i) => i.severity === "error");
78
+ return {
79
+ valid: !hasErrors,
80
+ githubSafe: !hasErrors,
81
+ bytes,
82
+ issues,
83
+ };
84
+ }
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "wirepulse",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Zero-dependency Diagram-as-Code compiler and local Visual Studio for pure zero-JS animated architecture SVGs that work natively in GitHub READMEs.",
5
+ "keywords": [
6
+ "svg",
7
+ "diagram",
8
+ "diagram-as-code",
9
+ "architecture",
10
+ "animated-svg",
11
+ "github-readme",
12
+ "flowchart",
13
+ "system-design",
14
+ "dark-mode",
15
+ "visualization",
16
+ "cli",
17
+ "studio"
18
+ ],
19
+ "license": "MIT",
20
+ "author": "Rynia",
21
+ "homepage": "https://github.com/Rynia/wirepulse#readme",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/Rynia/wirepulse.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/Rynia/wirepulse/issues"
28
+ },
29
+ "type": "module",
30
+ "bin": {
31
+ "wirepulse": "dist/cli.js"
32
+ },
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js"
37
+ }
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "README.md",
42
+ "LICENSE",
43
+ "CHANGELOG.md"
44
+ ],
45
+ "engines": {
46
+ "node": ">=20.0.0"
47
+ },
48
+ "scripts": {
49
+ "build": "tsc",
50
+ "lint": "tsc --noEmit",
51
+ "test": "npm run build && npm run test:unit",
52
+ "test:unit": "tsc -p tsconfig.test.json && node --test \"dist-test/test/**/*.test.js\"",
53
+ "clean": "node -e \"import('node:fs').then(fs=>{fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('dist-test',{recursive:true,force:true});})\"",
54
+ "prepublishOnly": "npm run clean && npm run build && npm run test:unit"
55
+ },
56
+ "devDependencies": {
57
+ "@types/node": "^22.0.0",
58
+ "typescript": "^5.7.0"
59
+ }
60
+ }