@kensnzk/koyu 0.26.0 → 0.28.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/assets/plan/README.md +18 -0
- package/assets/plan/catalog.muro +87 -0
- package/assets/plan/library.muro +26 -0
- package/assets/plan/svg/bathtub.svg +9 -0
- package/assets/plan/svg/bed-double.svg +9 -0
- package/assets/plan/svg/bed-single.svg +8 -0
- package/assets/plan/svg/cabinet.svg +9 -0
- package/assets/plan/svg/chair.svg +8 -0
- package/assets/plan/svg/desk.svg +9 -0
- package/assets/plan/svg/hedge-2m.svg +7 -0
- package/assets/plan/svg/kitchen-sink.svg +10 -0
- package/assets/plan/svg/locker.svg +9 -0
- package/assets/plan/svg/office-chair.svg +25 -0
- package/assets/plan/svg/potted-plant.svg +14 -0
- package/assets/plan/svg/refrigerator.svg +10 -0
- package/assets/plan/svg/shelf.svg +9 -0
- package/assets/plan/svg/shrub-1m.svg +7 -0
- package/assets/plan/svg/sofa-2.svg +9 -0
- package/assets/plan/svg/sofa-3.svg +9 -0
- package/assets/plan/svg/table-rect.svg +7 -0
- package/assets/plan/svg/table-round.svg +7 -0
- package/assets/plan/svg/tree-3m.svg +8 -0
- package/assets/plan/svg/urinal.svg +9 -0
- package/assets/plan/svg/washing-machine-pan.svg +13 -0
- package/assets/plan/svg/washing-machine.svg +10 -0
- package/assets/plan/svg/washstand-500.svg +12 -0
- package/assets/plan/svg/washstand.svg +12 -0
- package/assets/plan/svg/wc-cabinet.svg +14 -0
- package/assets/plan/svg/wc.svg +9 -0
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/core/components.d.ts +31 -0
- package/dist/core/components.d.ts.map +1 -0
- package/dist/core/components.js +167 -0
- package/dist/core/components.js.map +1 -0
- package/dist/core/derive.d.ts +9 -1
- package/dist/core/derive.d.ts.map +1 -1
- package/dist/core/derive.js +33 -3
- package/dist/core/derive.js.map +1 -1
- package/dist/core/diagnose.d.ts +6 -0
- package/dist/core/diagnose.d.ts.map +1 -1
- package/dist/core/diagnose.js +137 -4
- package/dist/core/diagnose.js.map +1 -1
- package/dist/core/model.d.ts +5 -5
- package/dist/core/model.d.ts.map +1 -1
- package/dist/core/model.js +6 -1
- package/dist/core/model.js.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/parse.js +5 -4
- package/dist/core/parse.js.map +1 -1
- package/dist/core/section.d.ts +27 -2
- package/dist/core/section.d.ts.map +1 -1
- package/dist/core/section.js +63 -11
- package/dist/core/section.js.map +1 -1
- package/dist/core/vocabulary.d.ts +20 -4
- package/dist/core/vocabulary.d.ts.map +1 -1
- package/dist/core/vocabulary.js +107 -9
- package/dist/core/vocabulary.js.map +1 -1
- package/dist/draw/component-files.d.ts +8 -0
- package/dist/draw/component-files.d.ts.map +1 -0
- package/dist/draw/component-files.js +35 -0
- package/dist/draw/component-files.js.map +1 -0
- package/dist/draw/component-svg.d.ts +14 -0
- package/dist/draw/component-svg.d.ts.map +1 -0
- package/dist/draw/component-svg.js +67 -0
- package/dist/draw/component-svg.js.map +1 -0
- package/dist/draw/conventions/architectural.d.ts +32 -0
- package/dist/draw/conventions/architectural.d.ts.map +1 -0
- package/dist/draw/conventions/architectural.js +29 -0
- package/dist/draw/conventions/architectural.js.map +1 -0
- package/dist/draw/index.d.ts +2 -2
- package/dist/draw/index.d.ts.map +1 -1
- package/dist/draw/index.js +2 -2
- package/dist/draw/index.js.map +1 -1
- package/dist/draw/marks.d.ts +37 -12
- package/dist/draw/marks.d.ts.map +1 -1
- package/dist/draw/marks.js +508 -38
- package/dist/draw/marks.js.map +1 -1
- package/dist/draw/plan.d.ts +3 -1
- package/dist/draw/plan.d.ts.map +1 -1
- package/dist/draw/plan.js +247 -85
- package/dist/draw/plan.js.map +1 -1
- package/dist/draw/section.d.ts +20 -2
- package/dist/draw/section.d.ts.map +1 -1
- package/dist/draw/section.js +43 -10
- package/dist/draw/section.js.map +1 -1
- package/dist/form.d.ts +2 -2
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.js +21 -3
- package/dist/mcp.js.map +1 -1
- package/dist/parse-file.d.ts +1 -0
- package/dist/parse-file.d.ts.map +1 -1
- package/dist/parse-file.js +1 -0
- package/dist/parse-file.js.map +1 -1
- package/dist/validate/builtin/index.d.ts +4 -2
- package/dist/validate/builtin/index.d.ts.map +1 -1
- package/dist/validate/builtin/index.js +9 -2
- package/dist/validate/builtin/index.js.map +1 -1
- package/dist/validate/builtin/opening-operations.d.ts +63 -0
- package/dist/validate/builtin/opening-operations.d.ts.map +1 -0
- package/dist/validate/builtin/opening-operations.js +406 -0
- package/dist/validate/builtin/opening-operations.js.map +1 -0
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +3 -3
- package/examples/basement/main.muro +3 -3
- package/examples/complex/L1.muro +1 -1
- package/examples/complex/assets.muro +2 -2
- package/examples/complex/main.muro +1 -1
- package/examples/house/L1.muro +3 -3
- package/examples/house/L2.muro +2 -2
- package/examples/house/assets.muro +8 -8
- package/examples/house/main.muro +1 -1
- package/examples/house/site.muro +2 -2
- package/examples/house.muro +6 -6
- package/examples/mansion.muro +1 -1
- package/examples/office.muro +1 -1
- package/examples/steps/06-finished.muro +1 -1
- package/examples/tower/assets.muro +1 -1
- package/examples/tower/main.muro +1 -1
- package/examples/twin/assets.muro +2 -2
- package/examples/twin/main.muro +1 -1
- package/examples/two-rooms.canonical.json +1 -1
- package/examples/two-rooms.muro +1 -1
- package/package.json +7 -4
- package/src/cli.ts +2 -2
- package/src/core/components.ts +224 -0
- package/src/core/derive.ts +47 -4
- package/src/core/diagnose.ts +182 -4
- package/src/core/model.ts +10 -5
- package/src/core/parse.ts +5 -4
- package/src/core/section.ts +107 -8
- package/src/core/vocabulary.ts +115 -9
- package/src/draw/component-files.ts +36 -0
- package/src/draw/component-svg.ts +79 -0
- package/src/draw/conventions/architectural.ts +60 -0
- package/src/draw/index.ts +9 -2
- package/src/draw/marks.ts +564 -44
- package/src/draw/plan.ts +253 -88
- package/src/draw/section.ts +78 -14
- package/src/form.ts +4 -0
- package/src/index.ts +1 -1
- package/src/mcp.ts +21 -3
- package/src/parse-file.ts +1 -0
- package/src/validate/builtin/index.ts +14 -2
- package/src/validate/builtin/opening-operations.ts +519 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Asset } from "../core/model.js";
|
|
2
|
+
|
|
3
|
+
export interface ComponentSvg {
|
|
4
|
+
dataUri: string;
|
|
5
|
+
viewBox: { width: number; height: number };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validate an SVG before it is embedded as an isolated image. Isolation preserves Figma-style
|
|
10
|
+
* defs, masks and clip paths without letting IDs collide with the plan sheet.
|
|
11
|
+
*/
|
|
12
|
+
export function componentSvg(asset: Asset, source: string): ComponentSvg {
|
|
13
|
+
const text = source.trim();
|
|
14
|
+
const root = /<svg\b([^>]*)>/i.exec(text);
|
|
15
|
+
if (!root) throw new Error(`Component asset ${asset.name} plan-svg does not contain an svg root`);
|
|
16
|
+
const number = "[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?";
|
|
17
|
+
const viewBox = new RegExp(
|
|
18
|
+
`\\bviewBox\\s*=\\s*["']\\s*(${number})\\s+(${number})\\s+(${number})\\s+(${number})\\s*["']`,
|
|
19
|
+
"i",
|
|
20
|
+
).exec(root[1]!);
|
|
21
|
+
if (!viewBox) throw new Error(`Component asset ${asset.name} plan-svg requires a positive viewBox`);
|
|
22
|
+
const width = Number(viewBox[3]);
|
|
23
|
+
const height = Number(viewBox[4]);
|
|
24
|
+
if (!(width > 0 && height > 0)) throw new Error(`Component asset ${asset.name} plan-svg requires a positive viewBox`);
|
|
25
|
+
|
|
26
|
+
const forbidden = [
|
|
27
|
+
/<!DOCTYPE/i,
|
|
28
|
+
/<!ENTITY/i,
|
|
29
|
+
/<script\b/i,
|
|
30
|
+
/<foreignObject\b/i,
|
|
31
|
+
/<(?:animate|animateMotion|animateTransform|set)\b/i,
|
|
32
|
+
/\s(?:[A-Za-z_][\w.-]*:)?on[a-z]+\s*=/i,
|
|
33
|
+
/javascript\s*:/i,
|
|
34
|
+
/@import\b/i,
|
|
35
|
+
];
|
|
36
|
+
if (forbidden.some((pattern) => pattern.test(text))) {
|
|
37
|
+
throw new Error(`Component asset ${asset.name} plan-svg contains active or external content`);
|
|
38
|
+
}
|
|
39
|
+
for (const match of text.matchAll(/\b(?:href|src)\s*=\s*["']([^"']+)["']/gi)) {
|
|
40
|
+
const value = match[1]!;
|
|
41
|
+
if (!safeReference(value)) {
|
|
42
|
+
throw new Error(`Component asset ${asset.name} plan-svg contains an external reference: ${value}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const match of text.matchAll(/url\(\s*([^)]+?)\s*\)/gi)) {
|
|
46
|
+
const value = match[1]!.replace(/^["']|["']$/g, "").trim();
|
|
47
|
+
if (!safeReference(value)) {
|
|
48
|
+
throw new Error(`Component asset ${asset.name} plan-svg contains an external reference: ${value}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const w = asset.attrs["w"];
|
|
53
|
+
const d = asset.attrs["d"];
|
|
54
|
+
if (typeof w !== "number" || !(w > 0) || typeof d !== "number" || !(d > 0)) {
|
|
55
|
+
throw new Error(`Component asset ${asset.name} requires positive w: and d:`);
|
|
56
|
+
}
|
|
57
|
+
const sourceRatio = width / height;
|
|
58
|
+
const physicalRatio = w / d;
|
|
59
|
+
const ratioError = Math.abs(sourceRatio - physicalRatio) / physicalRatio;
|
|
60
|
+
if (ratioError > 0.001) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`Component asset ${asset.name} plan-svg viewBox ratio ${round(sourceRatio)} does not match w:d ratio ${round(physicalRatio)}`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
dataUri: `data:image/svg+xml,${encodeURIComponent(text).replace(/'/g, "%27").replace(/"/g, "%22")}`,
|
|
68
|
+
viewBox: { width, height },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function safeReference(value: string): boolean {
|
|
73
|
+
if (value.startsWith("#")) return true;
|
|
74
|
+
return /^data:image\/(?:png|jpeg|webp|gif);base64,/i.test(value);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function round(value: number): number {
|
|
78
|
+
return Math.round(value * 10000) / 10000;
|
|
79
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Shared architectural plan conventions.
|
|
2
|
+
//
|
|
3
|
+
// These values describe paper symbols, never building geometry. They live outside core and Form
|
|
4
|
+
// so another drawing convention can replace them without changing a `.muro` file, canonical JSON,
|
|
5
|
+
// circulation, area or validation. The current set is broadly shared architectural practice; a
|
|
6
|
+
// jurisdiction module should override only a convention that is actually different.
|
|
7
|
+
|
|
8
|
+
export interface ArchitecturalPlanConvention {
|
|
9
|
+
readonly openings: {
|
|
10
|
+
/** Clear paper distance from the wall face to a sliding panel, in model millimetres. */
|
|
11
|
+
readonly slidingGapMm: number;
|
|
12
|
+
/** Extra overlap used to make two bypass leaves legible as separate panels. */
|
|
13
|
+
readonly bypassOverlapRatio: number;
|
|
14
|
+
/** Length of an automatic-door direction chevron relative to the aperture width. */
|
|
15
|
+
readonly automaticDirectionRatio: number;
|
|
16
|
+
/** Meeting point of the larger leaf in an unequal pair, measured from the first jamb. */
|
|
17
|
+
readonly unequalLeafMeetingRatio: number;
|
|
18
|
+
};
|
|
19
|
+
readonly stairs: {
|
|
20
|
+
/** How far an arrow enters a landing, relative to the narrower adjoining flight. */
|
|
21
|
+
readonly landingOffsetFlightWidthRatio: number;
|
|
22
|
+
readonly breakGlyph: {
|
|
23
|
+
/** Rotation from the line that crosses the flight. */
|
|
24
|
+
readonly angleDegrees: number;
|
|
25
|
+
/** Source-glyph proportions. The glyph is scaled to the flight width. */
|
|
26
|
+
readonly width: number;
|
|
27
|
+
readonly height: number;
|
|
28
|
+
readonly notch: number;
|
|
29
|
+
};
|
|
30
|
+
readonly arrowHead: {
|
|
31
|
+
/** SVG-space sizes: legibility belongs to paper, not to the building model. */
|
|
32
|
+
readonly length: number;
|
|
33
|
+
readonly halfWidth: number;
|
|
34
|
+
readonly startRadius: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const ARCHITECTURAL_PLAN_CONVENTION: ArchitecturalPlanConvention = {
|
|
40
|
+
openings: {
|
|
41
|
+
slidingGapMm: 60,
|
|
42
|
+
bypassOverlapRatio: 0.12,
|
|
43
|
+
automaticDirectionRatio: 0.08,
|
|
44
|
+
unequalLeafMeetingRatio: 2 / 3,
|
|
45
|
+
},
|
|
46
|
+
stairs: {
|
|
47
|
+
landingOffsetFlightWidthRatio: 0.5,
|
|
48
|
+
breakGlyph: {
|
|
49
|
+
angleDegrees: 30,
|
|
50
|
+
width: 10,
|
|
51
|
+
height: 40,
|
|
52
|
+
notch: 3.5,
|
|
53
|
+
},
|
|
54
|
+
arrowHead: {
|
|
55
|
+
length: 8,
|
|
56
|
+
halfWidth: 3.5,
|
|
57
|
+
startRadius: 2.8,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
package/src/draw/index.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
export { svgPlan, type PlanOptions } from "./plan.js";
|
|
11
11
|
export {
|
|
12
12
|
planMarks,
|
|
13
|
-
|
|
13
|
+
SLIDE_GAP,
|
|
14
14
|
type Mark,
|
|
15
15
|
type MarkArc,
|
|
16
16
|
type MarkNote,
|
|
@@ -31,5 +31,12 @@ export {
|
|
|
31
31
|
type SceneRole,
|
|
32
32
|
type SceneSubject,
|
|
33
33
|
} from "./scene.js";
|
|
34
|
-
export {
|
|
34
|
+
export {
|
|
35
|
+
svgSection,
|
|
36
|
+
svgElevation,
|
|
37
|
+
type ElevationOptions,
|
|
38
|
+
type LineSectionOptions,
|
|
39
|
+
type SectionGuide,
|
|
40
|
+
type SectionOptions,
|
|
41
|
+
} from "./section.js";
|
|
35
42
|
export { writtenOf, type Written } from "./written.js";
|