sketchmark 1.0.1 → 1.0.3

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.
Files changed (34) hide show
  1. package/README.md +23 -8
  2. package/dist/animation/index.d.ts +11 -0
  3. package/dist/animation/index.d.ts.map +1 -1
  4. package/dist/ast/types.d.ts +1 -1
  5. package/dist/ast/types.d.ts.map +1 -1
  6. package/dist/config.d.ts +2 -2
  7. package/dist/index.cjs +2590 -209
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.js +2590 -209
  10. package/dist/index.js.map +1 -1
  11. package/dist/layout/index.d.ts.map +1 -1
  12. package/dist/markdown/parser.d.ts +1 -0
  13. package/dist/markdown/parser.d.ts.map +1 -1
  14. package/dist/parser/tokenizer.d.ts.map +1 -1
  15. package/dist/renderer/canvas/index.d.ts.map +1 -1
  16. package/dist/renderer/shapes/box.d.ts.map +1 -1
  17. package/dist/renderer/shapes/circle.d.ts.map +1 -1
  18. package/dist/renderer/shapes/cylinder.d.ts.map +1 -1
  19. package/dist/renderer/shapes/diamond.d.ts.map +1 -1
  20. package/dist/renderer/shapes/hexagon.d.ts.map +1 -1
  21. package/dist/renderer/shapes/image.d.ts.map +1 -1
  22. package/dist/renderer/shapes/note.d.ts.map +1 -1
  23. package/dist/renderer/shapes/parallelogram.d.ts.map +1 -1
  24. package/dist/renderer/shapes/path.d.ts.map +1 -1
  25. package/dist/renderer/shapes/text-shape.d.ts.map +1 -1
  26. package/dist/renderer/shapes/triangle.d.ts.map +1 -1
  27. package/dist/renderer/shapes/types.d.ts +1 -1
  28. package/dist/renderer/shared.d.ts +2 -1
  29. package/dist/renderer/shared.d.ts.map +1 -1
  30. package/dist/renderer/svg/index.d.ts.map +1 -1
  31. package/dist/sketchmark.iife.js +2590 -209
  32. package/dist/utils/text-measure.d.ts +22 -0
  33. package/dist/utils/text-measure.d.ts.map +1 -0
  34. package/package.json +72 -69
@@ -0,0 +1,22 @@
1
+ import { prepareWithSegments, layoutWithLines } from '@chenglou/pretext';
2
+ export { prepareWithSegments, layoutWithLines };
3
+ /** Build a CSS font shorthand from fontSize, fontWeight and fontFamily */
4
+ export declare function buildFontStr(fontSize: number, fontWeight: number | string, fontFamily: string): string;
5
+ /** Measure the natural (unwrapped) width of text using pretext */
6
+ export declare function measureTextWidth(text: string, font: string): number;
7
+ /** Word-wrap text using pretext, with fallback to character approximation */
8
+ export declare function wrapText(text: string, maxWidth: number, fontSize: number, font?: string): string[];
9
+ export interface ShapeLine {
10
+ text: string;
11
+ width: number;
12
+ }
13
+ /**
14
+ * Wrap text to conform to the interior of a shape.
15
+ * Returns lines with their text + measured width, plus a startY
16
+ * offset (from shape top) where the first line's center sits.
17
+ */
18
+ export declare function wrapTextInShape(text: string, font: string, fontSize: number, lineHeight: number, shape: string, shapeW: number, shapeH: number, padding: number): {
19
+ lines: ShapeLine[];
20
+ startY: number;
21
+ };
22
+ //# sourceMappingURL=text-measure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-measure.d.ts","sourceRoot":"","sources":["../../src/utils/text-measure.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAkC,MAAM,mBAAmB,CAAC;AAEzG,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;AAEhD,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEtG;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKnE;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CA6BlG;AAMD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAyCD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd;IAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA6DxC"}
package/package.json CHANGED
@@ -1,69 +1,72 @@
1
- {
2
- "name": "sketchmark",
3
- "version": "1.0.1",
4
- "description": "A plain-text DSL for hand-drawn diagrams. Write boxes, edges, and groups as code — renders sketchy SVG/Canvas via rough.js with a built-in step-by-step animation system.",
5
- "keywords": [
6
- "diagram",
7
- "dsl",
8
- "rough.js",
9
- "hand-drawn",
10
- "ai",
11
- "llm",
12
- "visualization",
13
- "animation",
14
- "svg"
15
- ],
16
- "author": "sketchmark contributors",
17
- "license": "MIT",
18
- "type": "module",
19
- "main": "./dist/index.cjs",
20
- "module": "./dist/index.js",
21
- "types": "./dist/index.d.ts",
22
- "exports": {
23
- ".": {
24
- "import": "./dist/index.js",
25
- "require": "./dist/index.cjs",
26
- "types": "./dist/index.d.ts"
27
- }
28
- },
29
- "files": [
30
- "dist",
31
- "README.md",
32
- "LICENSE"
33
- ],
34
- "scripts": {
35
- "build": "rollup -c rollup.config.js",
36
- "build:watch": "rollup -c rollup.config.js --watch",
37
- "typecheck": "tsc --noEmit",
38
- "lint": "eslint src --ext .ts",
39
- "prepublishOnly": "npm run typecheck && npm run build",
40
- "deploy": "wrangler deploy",
41
- "preview": "wrangler dev"
42
- },
43
- "peerDependencies": {
44
- "roughjs": "^4.6.0"
45
- },
46
- "devDependencies": {
47
- "@rollup/plugin-node-resolve": "^15.2.3",
48
- "@rollup/plugin-typescript": "^11.1.6",
49
- "@types/node": "^20.0.0",
50
- "@typescript-eslint/eslint-plugin": "^7.0.0",
51
- "@typescript-eslint/parser": "^7.0.0",
52
- "eslint": "^8.56.0",
53
- "happy-dom": "^13.6.0",
54
- "rollup": "^4.9.0",
55
- "tslib": "^2.6.2",
56
- "typescript": "^5.3.3",
57
- "vitest": "^1.2.0",
58
- "wrangler": "^4.76.0"
59
- },
60
- "sideEffects": false,
61
- "repository": {
62
- "type": "git",
63
- "url": "https://github.com/anmism/sketchmark"
64
- },
65
- "bugs": {
66
- "url": "https://github.com/anmism/sketchmark/issues"
67
- },
68
- "homepage": "https://github.com/anmism/sketchmark#readme"
69
- }
1
+ {
2
+ "name": "sketchmark",
3
+ "version": "1.0.3",
4
+ "description": "A plain-text DSL for hand-drawn diagrams. Write boxes, edges, and groups as code — renders sketchy SVG/Canvas via rough.js with a built-in step-by-step animation system.",
5
+ "keywords": [
6
+ "diagram",
7
+ "dsl",
8
+ "rough.js",
9
+ "hand-drawn",
10
+ "ai",
11
+ "llm",
12
+ "visualization",
13
+ "animation",
14
+ "svg"
15
+ ],
16
+ "author": "sketchmark contributors",
17
+ "license": "MIT",
18
+ "type": "module",
19
+ "main": "./dist/index.cjs",
20
+ "module": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/index.js",
25
+ "require": "./dist/index.cjs",
26
+ "types": "./dist/index.d.ts"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "scripts": {
35
+ "build": "rollup -c rollup.config.js",
36
+ "build:watch": "rollup -c rollup.config.js --watch",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "eslint src --ext .ts",
39
+ "prepublishOnly": "npm run typecheck && npm run build",
40
+ "deploy": "wrangler deploy",
41
+ "preview": "wrangler dev"
42
+ },
43
+ "dependencies": {
44
+ "@chenglou/pretext": "^0.0.4"
45
+ },
46
+ "peerDependencies": {
47
+ "roughjs": "^4.6.0"
48
+ },
49
+ "devDependencies": {
50
+ "@rollup/plugin-node-resolve": "^15.2.3",
51
+ "@rollup/plugin-typescript": "^11.1.6",
52
+ "@types/node": "^20.0.0",
53
+ "@typescript-eslint/eslint-plugin": "^7.0.0",
54
+ "@typescript-eslint/parser": "^7.0.0",
55
+ "eslint": "^8.56.0",
56
+ "happy-dom": "^13.6.0",
57
+ "rollup": "^4.9.0",
58
+ "tslib": "^2.6.2",
59
+ "typescript": "^5.3.3",
60
+ "vitest": "^1.2.0",
61
+ "wrangler": "^4.76.0"
62
+ },
63
+ "sideEffects": false,
64
+ "repository": {
65
+ "type": "git",
66
+ "url": "https://github.com/anmism/sketchmark"
67
+ },
68
+ "bugs": {
69
+ "url": "https://github.com/anmism/sketchmark/issues"
70
+ },
71
+ "homepage": "https://github.com/anmism/sketchmark#readme"
72
+ }