@snaptrude/plugin-core 1.0.2-plainpoint-20261026.2 → 1.0.2-plainpoint-20261102.2
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/AGENTS.md +1 -0
- package/CHANGELOG.md +12 -0
- package/api-manifest.json +116 -39
- package/dist/api/core/camera/index.d.ts +4 -2
- package/dist/api/core/camera/index.d.ts.map +1 -1
- package/dist/api/core/storeys/index.d.ts +5 -0
- package/dist/api/core/storeys/index.d.ts.map +1 -1
- package/dist/api/design/create/bulk-items.d.ts +64 -12
- package/dist/api/design/create/bulk-items.d.ts.map +1 -1
- package/dist/api/design/create/index.d.ts +67 -32
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/create/opening-fields.d.ts +18 -6
- package/dist/api/design/create/opening-fields.d.ts.map +1 -1
- package/dist/api/design/erase/index.d.ts +2 -10
- package/dist/api/design/erase/index.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +5 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/text.d.ts +400 -0
- package/dist/api/design/text.d.ts.map +1 -0
- package/dist/api/entity/story.d.ts +4 -0
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/presentation/drawings.d.ts +45 -0
- package/dist/api/presentation/drawings.d.ts.map +1 -1
- package/dist/api/presentation/graphics.d.ts +4 -0
- package/dist/api/presentation/graphics.d.ts.map +1 -1
- package/dist/api/presentation/placedViews.d.ts +29 -1
- package/dist/api/presentation/placedViews.d.ts.map +1 -1
- package/dist/api/presentation/standards.d.ts +14 -0
- package/dist/api/presentation/standards.d.ts.map +1 -1
- package/dist/api/presentation/views.d.ts +5 -1
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/index.cjs +2209 -2102
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2197 -2102
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/core/camera/index.ts +4 -2
- package/src/api/core/storeys/index.ts +5 -0
- package/src/api/design/create/bulk-items.ts +4 -0
- package/src/api/design/create/index.ts +7 -20
- package/src/api/design/create/opening-fields.ts +7 -7
- package/src/api/design/erase/index.ts +2 -2
- package/src/api/design/index.ts +5 -0
- package/src/api/design/text.ts +394 -0
- package/src/api/entity/story.ts +4 -0
- package/src/api/presentation/graphics.ts +4 -1
- package/src/api/presentation/placedViews.ts +12 -0
- package/src/api/presentation/standards.ts +6 -0
- package/src/api/presentation/views.ts +7 -2
- package/test/designText.test.mjs +72 -0
- package/test/paperPensContract.test.mjs +39 -0
|
@@ -82,6 +82,7 @@ const StoredText = z
|
|
|
82
82
|
})
|
|
83
83
|
.strict()
|
|
84
84
|
.optional(),
|
|
85
|
+
Text: z.object({ textMm: TextSize.optional() }).strict().optional(),
|
|
85
86
|
})
|
|
86
87
|
.strict()
|
|
87
88
|
const StoredDimension = z
|
|
@@ -226,6 +227,10 @@ export const PluginGraphicStandardPatch = z
|
|
|
226
227
|
})
|
|
227
228
|
.strict()
|
|
228
229
|
.optional(),
|
|
230
|
+
Text: z
|
|
231
|
+
.object({ textMm: TextSize.nullable().optional() })
|
|
232
|
+
.strict()
|
|
233
|
+
.optional(),
|
|
229
234
|
})
|
|
230
235
|
.strict()
|
|
231
236
|
.optional(),
|
|
@@ -329,6 +334,7 @@ export const PluginResolvedGraphicStandard = z.object({
|
|
|
329
334
|
gridBubbleRadiusMm: HeadRadius,
|
|
330
335
|
sectionTextMm: TextSize,
|
|
331
336
|
sectionHeadRadiusMm: HeadRadius,
|
|
337
|
+
annotationMm: TextSize,
|
|
332
338
|
}),
|
|
333
339
|
dimension: z.object({
|
|
334
340
|
tickMm: TickLength,
|
|
@@ -522,8 +522,13 @@ export type PluginPresentationViewsCreateArgs = z.infer<
|
|
|
522
522
|
typeof PluginPresentationViewsCreateArgs
|
|
523
523
|
>
|
|
524
524
|
|
|
525
|
-
/**
|
|
526
|
-
|
|
525
|
+
/**
|
|
526
|
+
* Result of {@linkcode PluginPresentationViewsApi.create} — the saved view, plus `framed`:
|
|
527
|
+
* whether the view was framed on the given elements or bounds (always `false` without `frame`).
|
|
528
|
+
*/
|
|
529
|
+
export const PluginPresentationViewsCreateResult = PluginPresentationView.extend({
|
|
530
|
+
framed: z.boolean().optional(),
|
|
531
|
+
})
|
|
527
532
|
export type PluginPresentationViewsCreateResult = z.infer<
|
|
528
533
|
typeof PluginPresentationViewsCreateResult
|
|
529
534
|
>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// The design.text argument contract, checked before transport.
|
|
2
|
+
// Run: node --test test/
|
|
3
|
+
// Imports the BUILT package (dist) — run `pnpm build` first.
|
|
4
|
+
import test from "node:test"
|
|
5
|
+
import assert from "node:assert/strict"
|
|
6
|
+
import {
|
|
7
|
+
PluginDesignTextCreateArgs,
|
|
8
|
+
PluginDesignTextUpdateArgs,
|
|
9
|
+
PluginTextPatch,
|
|
10
|
+
} from "../dist/index.js"
|
|
11
|
+
|
|
12
|
+
const position = "vec3_position"
|
|
13
|
+
|
|
14
|
+
test("create takes one non-blank line of words", () => {
|
|
15
|
+
assert.equal(
|
|
16
|
+
PluginDesignTextCreateArgs.safeParse({ position, content: "LIVING" })
|
|
17
|
+
.success,
|
|
18
|
+
true,
|
|
19
|
+
)
|
|
20
|
+
for (const content of ["", " ", "two\nlines", "two\r\nlines"])
|
|
21
|
+
assert.equal(
|
|
22
|
+
PluginDesignTextCreateArgs.safeParse({ position, content }).success,
|
|
23
|
+
false,
|
|
24
|
+
JSON.stringify(content),
|
|
25
|
+
)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test("create takes a #rrggbb colour and a vec3 handle for the arrowhead", () => {
|
|
29
|
+
const ok = {
|
|
30
|
+
position,
|
|
31
|
+
content: "Shear wall",
|
|
32
|
+
color: "#c62828",
|
|
33
|
+
arrowhead: "vec3_head",
|
|
34
|
+
}
|
|
35
|
+
assert.equal(PluginDesignTextCreateArgs.safeParse(ok).success, true)
|
|
36
|
+
for (const color of ["red", "#12345", "c62828"])
|
|
37
|
+
assert.equal(
|
|
38
|
+
PluginDesignTextCreateArgs.safeParse({ ...ok, color }).success,
|
|
39
|
+
false,
|
|
40
|
+
color,
|
|
41
|
+
)
|
|
42
|
+
for (const arrowhead of [{ x: 1, y: 0, z: 2 }, "component_1", "quat_1"])
|
|
43
|
+
assert.equal(
|
|
44
|
+
PluginDesignTextCreateArgs.safeParse({ ...ok, arrowhead }).success,
|
|
45
|
+
false,
|
|
46
|
+
JSON.stringify(arrowhead),
|
|
47
|
+
)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test("an update patch sets at least one known field", () => {
|
|
51
|
+
assert.deepEqual(PluginTextPatch.parse({ fontStyle: "Bold" }), {
|
|
52
|
+
fontStyle: "Bold",
|
|
53
|
+
})
|
|
54
|
+
for (const patch of [
|
|
55
|
+
{},
|
|
56
|
+
{ size: 3 },
|
|
57
|
+
{ content: "Fire exit", rotation: 90 },
|
|
58
|
+
{ content: " " },
|
|
59
|
+
])
|
|
60
|
+
assert.equal(
|
|
61
|
+
PluginTextPatch.safeParse(patch).success,
|
|
62
|
+
false,
|
|
63
|
+
JSON.stringify(patch),
|
|
64
|
+
)
|
|
65
|
+
assert.equal(
|
|
66
|
+
PluginDesignTextUpdateArgs.safeParse({
|
|
67
|
+
texts: [],
|
|
68
|
+
patch: { color: "#1565c0" },
|
|
69
|
+
}).success,
|
|
70
|
+
false,
|
|
71
|
+
)
|
|
72
|
+
})
|
|
@@ -2,7 +2,10 @@ import { test } from "node:test"
|
|
|
2
2
|
import assert from "node:assert/strict"
|
|
3
3
|
import {
|
|
4
4
|
PluginGraphicStandardPatch,
|
|
5
|
+
PluginGraphicsAnnotationCategory,
|
|
6
|
+
PluginGraphicsOverrideCategory,
|
|
5
7
|
PluginGraphicsOverrides,
|
|
8
|
+
PluginResolvedGraphicStandard,
|
|
6
9
|
PluginGraphicsSetScaleArgs,
|
|
7
10
|
PluginDesignCreateReferenceLinesArgs,
|
|
8
11
|
PluginReferenceLineOptions,
|
|
@@ -36,6 +39,42 @@ test("Paper Pens rejects ambiguous, ineffective and stock-writing edits before t
|
|
|
36
39
|
assert.deepEqual(PluginGraphicStandardPatch.parse(patch), patch)
|
|
37
40
|
})
|
|
38
41
|
|
|
42
|
+
test("Text is an annotation category with a projection pen and a size, but no view override", () => {
|
|
43
|
+
assert.equal(PluginGraphicsAnnotationCategory.safeParse("Text").success, true)
|
|
44
|
+
assert.equal(PluginGraphicsOverrideCategory.safeParse("Text").success, false)
|
|
45
|
+
assert.equal(
|
|
46
|
+
PluginGraphicsOverrides.safeParse({ Text: { hidden: true } }).success,
|
|
47
|
+
false,
|
|
48
|
+
)
|
|
49
|
+
for (const patch of [
|
|
50
|
+
{ annotationText: { Text: { textMm: 3.5 } } },
|
|
51
|
+
{ annotationText: { Text: { textMm: null } } },
|
|
52
|
+
{ objectStyles: { Text: { projection: 2 } } },
|
|
53
|
+
])
|
|
54
|
+
assert.deepEqual(PluginGraphicStandardPatch.parse(patch), patch)
|
|
55
|
+
for (const patch of [
|
|
56
|
+
{ annotationText: { Text: { textMm: 0 } } },
|
|
57
|
+
{ annotationText: { Text: { sizeMm: 3 } } },
|
|
58
|
+
{ objectStyles: { Text: { cut: 2 } } },
|
|
59
|
+
])
|
|
60
|
+
assert.equal(PluginGraphicStandardPatch.safeParse(patch).success, false)
|
|
61
|
+
const text = {
|
|
62
|
+
nameMm: 3,
|
|
63
|
+
areaMm: 2.5,
|
|
64
|
+
dimensionMm: 2.5,
|
|
65
|
+
gridTextMm: 3.5,
|
|
66
|
+
gridBubbleRadiusMm: 5,
|
|
67
|
+
sectionTextMm: 3,
|
|
68
|
+
sectionHeadRadiusMm: 6,
|
|
69
|
+
}
|
|
70
|
+
const resolvedText = PluginResolvedGraphicStandard.shape.text
|
|
71
|
+
assert.equal(resolvedText.safeParse(text).success, false)
|
|
72
|
+
assert.equal(
|
|
73
|
+
resolvedText.safeParse({ ...text, annotationMm: 2.5 }).success,
|
|
74
|
+
true,
|
|
75
|
+
)
|
|
76
|
+
})
|
|
77
|
+
|
|
39
78
|
test("explicit reference styles cannot conflict with legacy fields or mixed call forms", () => {
|
|
40
79
|
assert.equal(
|
|
41
80
|
PluginReferenceLineOptions.safeParse({ styleId: "wide", thickness: 3 })
|