@cardenelabs/dragon 0.10.0 → 0.12.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/dist/index.cjs +67 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +67 -21
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/compile.ts +23 -15
- package/src/index.ts +1 -1
- package/src/v05/parser.ts +79 -20
package/dist/index.d.cts
CHANGED
|
@@ -810,6 +810,14 @@ declare function parseTextDslV05(src: string): V05ParseResult;
|
|
|
810
810
|
* 画面側も同じ関数を使う (#1028) = 別々に持つと、片方だけが読める本文ができる。
|
|
811
811
|
*/
|
|
812
812
|
declare function stripQuotes(s: string): string;
|
|
813
|
+
/**
|
|
814
|
+
* 段に書ける項目の英語名。 `parsePhase` が受け付ける名前の入口でも使う。
|
|
815
|
+
*
|
|
816
|
+
* 誤りの案内で使うほか、**見本が値の名前にこの語を使っていないか** を見るのにも使う
|
|
817
|
+
* (#1330)。 段の項目と値は階層が違うので衝突しないが、同じ語が 2 つの意味で並ぶと
|
|
818
|
+
* 見本を読む人が階層から意味を判断することになる。
|
|
819
|
+
*/
|
|
820
|
+
declare const PHASE_ITEM_WORDS: readonly ["focus", "badge", "body", "description", "tween", "set", "draw"];
|
|
813
821
|
/**
|
|
814
822
|
* `draw:` に書ける語と、その語が効く図種 (#1312 / #1314)。
|
|
815
823
|
*
|
|
@@ -2024,4 +2032,4 @@ interface CompileOpts {
|
|
|
2024
2032
|
*/
|
|
2025
2033
|
declare function textDslToDiagram(src: string, opts?: CompileOpts): CdlDiagram;
|
|
2026
2034
|
|
|
2027
|
-
export { type AnchorBox, type CompileNotice, type CompileOpts, DIAGRAM_BOUNDARY_PADDING, DRAW_TARGETS, DRAW_WORDS, type DiagramBoundingBox, type DragonJson, type DslActor, type DslAnimate, type DslDocument, type DslError, type DslGroup, type DslLane, type DslPhase, type DslSet, type DslState, type DslStep, type DslTween, type DslValue, type DslViewport, type FocusEntry, type InputSize, JSONを分解する, type JsonActor, type JsonActorNodeOverride, type JsonAxes, type JsonDslError, type JsonPhase, type JsonStep, type LayoutMode, type LayoutPos, type LintIssue, type LintReport, type LintSeverity, MAX_INPUT_BYTES, MAX_INPUT_ELEMENTS, MAX_PART_SCALE, NODE_KIND_ALIAS, NODE_KIND_VALID, PRESET_TYPES, type PresetType, RELATIVE_GAP_DEFAULT, type RelativeDirection, type RelativePos, TONE_ALIAS, TOP_LEVEL_KEYS, autoFix, compileToCdl, computeDiagramBoundingBox, countBytes, countDiagramElements, countDocElements, describeOversize, describeOversizeSource, diagramJsonSchema, isColorValue, jsonToDiagram, lintDiagram, measureActorBoxes, normalizePartScale, orderByDependency, parseFocusEntry, parseRelativePos, parseTextDsl, parseTextDslV05, partBoxInFrame, partDrawsInDiagram, partIsMeasurable, partRenderSize, partScaleFactor, partTargetScale, partTargetSize, partVisualSize, partsGridCenters, pointsOutside, rectsOverlap, resolveRelativePos, stripExternalPaint, stripQuotes, textDslToDiagram, validateDragonJson, writeActorPosition, type トークン, type トークンの種類, 区間に広げる, 記法を分解する };
|
|
2035
|
+
export { type AnchorBox, type CompileNotice, type CompileOpts, DIAGRAM_BOUNDARY_PADDING, DRAW_TARGETS, DRAW_WORDS, type DiagramBoundingBox, type DragonJson, type DslActor, type DslAnimate, type DslDocument, type DslError, type DslGroup, type DslLane, type DslPhase, type DslSet, type DslState, type DslStep, type DslTween, type DslValue, type DslViewport, type FocusEntry, type InputSize, JSONを分解する, type JsonActor, type JsonActorNodeOverride, type JsonAxes, type JsonDslError, type JsonPhase, type JsonStep, type LayoutMode, type LayoutPos, type LintIssue, type LintReport, type LintSeverity, MAX_INPUT_BYTES, MAX_INPUT_ELEMENTS, MAX_PART_SCALE, NODE_KIND_ALIAS, NODE_KIND_VALID, PHASE_ITEM_WORDS, PRESET_TYPES, type PresetType, RELATIVE_GAP_DEFAULT, type RelativeDirection, type RelativePos, TONE_ALIAS, TOP_LEVEL_KEYS, autoFix, compileToCdl, computeDiagramBoundingBox, countBytes, countDiagramElements, countDocElements, describeOversize, describeOversizeSource, diagramJsonSchema, isColorValue, jsonToDiagram, lintDiagram, measureActorBoxes, normalizePartScale, orderByDependency, parseFocusEntry, parseRelativePos, parseTextDsl, parseTextDslV05, partBoxInFrame, partDrawsInDiagram, partIsMeasurable, partRenderSize, partScaleFactor, partTargetScale, partTargetSize, partVisualSize, partsGridCenters, pointsOutside, rectsOverlap, resolveRelativePos, stripExternalPaint, stripQuotes, textDslToDiagram, validateDragonJson, writeActorPosition, type トークン, type トークンの種類, 区間に広げる, 記法を分解する };
|
package/dist/index.d.ts
CHANGED
|
@@ -810,6 +810,14 @@ declare function parseTextDslV05(src: string): V05ParseResult;
|
|
|
810
810
|
* 画面側も同じ関数を使う (#1028) = 別々に持つと、片方だけが読める本文ができる。
|
|
811
811
|
*/
|
|
812
812
|
declare function stripQuotes(s: string): string;
|
|
813
|
+
/**
|
|
814
|
+
* 段に書ける項目の英語名。 `parsePhase` が受け付ける名前の入口でも使う。
|
|
815
|
+
*
|
|
816
|
+
* 誤りの案内で使うほか、**見本が値の名前にこの語を使っていないか** を見るのにも使う
|
|
817
|
+
* (#1330)。 段の項目と値は階層が違うので衝突しないが、同じ語が 2 つの意味で並ぶと
|
|
818
|
+
* 見本を読む人が階層から意味を判断することになる。
|
|
819
|
+
*/
|
|
820
|
+
declare const PHASE_ITEM_WORDS: readonly ["focus", "badge", "body", "description", "tween", "set", "draw"];
|
|
813
821
|
/**
|
|
814
822
|
* `draw:` に書ける語と、その語が効く図種 (#1312 / #1314)。
|
|
815
823
|
*
|
|
@@ -2024,4 +2032,4 @@ interface CompileOpts {
|
|
|
2024
2032
|
*/
|
|
2025
2033
|
declare function textDslToDiagram(src: string, opts?: CompileOpts): CdlDiagram;
|
|
2026
2034
|
|
|
2027
|
-
export { type AnchorBox, type CompileNotice, type CompileOpts, DIAGRAM_BOUNDARY_PADDING, DRAW_TARGETS, DRAW_WORDS, type DiagramBoundingBox, type DragonJson, type DslActor, type DslAnimate, type DslDocument, type DslError, type DslGroup, type DslLane, type DslPhase, type DslSet, type DslState, type DslStep, type DslTween, type DslValue, type DslViewport, type FocusEntry, type InputSize, JSONを分解する, type JsonActor, type JsonActorNodeOverride, type JsonAxes, type JsonDslError, type JsonPhase, type JsonStep, type LayoutMode, type LayoutPos, type LintIssue, type LintReport, type LintSeverity, MAX_INPUT_BYTES, MAX_INPUT_ELEMENTS, MAX_PART_SCALE, NODE_KIND_ALIAS, NODE_KIND_VALID, PRESET_TYPES, type PresetType, RELATIVE_GAP_DEFAULT, type RelativeDirection, type RelativePos, TONE_ALIAS, TOP_LEVEL_KEYS, autoFix, compileToCdl, computeDiagramBoundingBox, countBytes, countDiagramElements, countDocElements, describeOversize, describeOversizeSource, diagramJsonSchema, isColorValue, jsonToDiagram, lintDiagram, measureActorBoxes, normalizePartScale, orderByDependency, parseFocusEntry, parseRelativePos, parseTextDsl, parseTextDslV05, partBoxInFrame, partDrawsInDiagram, partIsMeasurable, partRenderSize, partScaleFactor, partTargetScale, partTargetSize, partVisualSize, partsGridCenters, pointsOutside, rectsOverlap, resolveRelativePos, stripExternalPaint, stripQuotes, textDslToDiagram, validateDragonJson, writeActorPosition, type トークン, type トークンの種類, 区間に広げる, 記法を分解する };
|
|
2035
|
+
export { type AnchorBox, type CompileNotice, type CompileOpts, DIAGRAM_BOUNDARY_PADDING, DRAW_TARGETS, DRAW_WORDS, type DiagramBoundingBox, type DragonJson, type DslActor, type DslAnimate, type DslDocument, type DslError, type DslGroup, type DslLane, type DslPhase, type DslSet, type DslState, type DslStep, type DslTween, type DslValue, type DslViewport, type FocusEntry, type InputSize, JSONを分解する, type JsonActor, type JsonActorNodeOverride, type JsonAxes, type JsonDslError, type JsonPhase, type JsonStep, type LayoutMode, type LayoutPos, type LintIssue, type LintReport, type LintSeverity, MAX_INPUT_BYTES, MAX_INPUT_ELEMENTS, MAX_PART_SCALE, NODE_KIND_ALIAS, NODE_KIND_VALID, PHASE_ITEM_WORDS, PRESET_TYPES, type PresetType, RELATIVE_GAP_DEFAULT, type RelativeDirection, type RelativePos, TONE_ALIAS, TOP_LEVEL_KEYS, autoFix, compileToCdl, computeDiagramBoundingBox, countBytes, countDiagramElements, countDocElements, describeOversize, describeOversizeSource, diagramJsonSchema, isColorValue, jsonToDiagram, lintDiagram, measureActorBoxes, normalizePartScale, orderByDependency, parseFocusEntry, parseRelativePos, parseTextDsl, parseTextDslV05, partBoxInFrame, partDrawsInDiagram, partIsMeasurable, partRenderSize, partScaleFactor, partTargetScale, partTargetSize, partVisualSize, partsGridCenters, pointsOutside, rectsOverlap, resolveRelativePos, stripExternalPaint, stripQuotes, textDslToDiagram, validateDragonJson, writeActorPosition, type トークン, type トークンの種類, 区間に広げる, 記法を分解する };
|
package/dist/index.js
CHANGED
|
@@ -1333,22 +1333,49 @@ function writtenScaleFields(inner) {
|
|
|
1333
1333
|
return out;
|
|
1334
1334
|
}
|
|
1335
1335
|
function splitInlineFields(inner) {
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1336
|
+
const \u5F15\u7528\u7B26\u3092\u898B\u3066\u5272\u308B = (\u898B\u308B) => {
|
|
1337
|
+
let depth = 0;
|
|
1338
|
+
let \u5F15\u7528\u7B26 = null;
|
|
1339
|
+
let \u76F4\u524D = null;
|
|
1340
|
+
let buf = "";
|
|
1341
|
+
const parts = [];
|
|
1342
|
+
for (let i = 0; i < inner.length; i += 1) {
|
|
1343
|
+
const c = inner[i];
|
|
1344
|
+
if (\u898B\u308B) {
|
|
1345
|
+
if (\u5F15\u7528\u7B26 !== null) {
|
|
1346
|
+
if (\u5F15\u7528\u7B26 === '"' && c === "\\" && i + 1 < inner.length) {
|
|
1347
|
+
buf += c;
|
|
1348
|
+
i += 1;
|
|
1349
|
+
buf += inner[i];
|
|
1350
|
+
continue;
|
|
1351
|
+
}
|
|
1352
|
+
if (c === \u5F15\u7528\u7B26) \u5F15\u7528\u7B26 = null;
|
|
1353
|
+
buf += c;
|
|
1354
|
+
continue;
|
|
1355
|
+
}
|
|
1356
|
+
if ((c === '"' || c === "'") && (\u76F4\u524D === null || ":,{[".includes(\u76F4\u524D))) {
|
|
1357
|
+
\u5F15\u7528\u7B26 = c;
|
|
1358
|
+
\u76F4\u524D = c;
|
|
1359
|
+
buf += c;
|
|
1360
|
+
continue;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
if (c === "[" || c === "{") depth += 1;
|
|
1364
|
+
else if (c === "]" || c === "}") depth -= 1;
|
|
1365
|
+
if (c === "," && depth === 0) {
|
|
1366
|
+
parts.push(buf);
|
|
1367
|
+
buf = "";
|
|
1368
|
+
\u76F4\u524D = c;
|
|
1369
|
+
continue;
|
|
1370
|
+
}
|
|
1371
|
+
buf += c;
|
|
1372
|
+
if (c !== " " && c !== " ") \u76F4\u524D = c;
|
|
1347
1373
|
}
|
|
1348
|
-
buf
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1374
|
+
if (buf.trim()) parts.push(buf);
|
|
1375
|
+
return { parts, \u9589\u3058\u305F: \u5F15\u7528\u7B26 === null };
|
|
1376
|
+
};
|
|
1377
|
+
const \u898B\u305F = \u5F15\u7528\u7B26\u3092\u898B\u3066\u5272\u308B(true);
|
|
1378
|
+
return \u898B\u305F.\u9589\u3058\u305F ? \u898B\u305F.parts : \u5F15\u7528\u7B26\u3092\u898B\u3066\u5272\u308B(false).parts;
|
|
1352
1379
|
}
|
|
1353
1380
|
function collectIndentedList(lines, start, parentIndent) {
|
|
1354
1381
|
const items = [];
|
|
@@ -2086,6 +2113,9 @@ function ensureAnimate(a, lineNo) {
|
|
|
2086
2113
|
if (a) return a;
|
|
2087
2114
|
return { states: [], phases: [], pos: { line: lineNo } };
|
|
2088
2115
|
}
|
|
2116
|
+
var PHASE_ITEM_WORDS = ["focus", "badge", "body", "description", "tween", "set", "draw"];
|
|
2117
|
+
var \u6BB5\u306E\u9805\u76EE\u306E\u82F1\u8A9E = PHASE_ITEM_WORDS;
|
|
2118
|
+
var \u6BB5\u306E\u9805\u76EE\u306E\u96C6\u5408 = new Set(PHASE_ITEM_WORDS);
|
|
2089
2119
|
function parsePhase(block, errors) {
|
|
2090
2120
|
const head = block[0];
|
|
2091
2121
|
const m = head.trimmed.match(/^step\s*:\s*(.+)$/);
|
|
@@ -2126,6 +2156,15 @@ function parsePhase(block, errors) {
|
|
|
2126
2156
|
}
|
|
2127
2157
|
const key = (propMatch[1] ?? "").toLowerCase();
|
|
2128
2158
|
const value = (propMatch[2] ?? "").trim();
|
|
2159
|
+
if (!\u6BB5\u306E\u9805\u76EE\u306E\u96C6\u5408.has(key)) {
|
|
2160
|
+
errors.push({
|
|
2161
|
+
line: ln.no,
|
|
2162
|
+
message: `\u6BB5\u306E\u9805\u76EE\u540D\u304C\u8AAD\u3081\u307E\u305B\u3093: "${propMatch[1] ?? ""}"`,
|
|
2163
|
+
hint: \u6BB5\u306E\u9805\u76EE\u306E\u30D2\u30F3\u30C8(propMatch[1] ?? "")
|
|
2164
|
+
});
|
|
2165
|
+
i += 1;
|
|
2166
|
+
continue;
|
|
2167
|
+
}
|
|
2129
2168
|
if (key === "focus") {
|
|
2130
2169
|
phase.highlight = parseFocusList(value);
|
|
2131
2170
|
i += 1;
|
|
@@ -2219,7 +2258,6 @@ function \u6BB5\u306E\u9805\u76EE\u306E\u30D2\u30F3\u30C8(\u66F8\u3044\u305F\u54
|
|
|
2219
2258
|
const \u82F1\u8A9E = \u6BB5\u306E\u9805\u76EE\u306E\u65E5\u672C\u8A9E[\u66F8\u3044\u305F\u540D\u524D];
|
|
2220
2259
|
return \u82F1\u8A9E !== void 0 ? `v0.5 \u3067\u306F\u82F1\u8A9E\u3067\u66F8\u304F (\`${\u82F1\u8A9E}\`)` : `\u4F7F\u3048\u308B\u9805\u76EE = ${\u6BB5\u306E\u9805\u76EE\u306E\u82F1\u8A9E.join(", ")}`;
|
|
2221
2260
|
}
|
|
2222
|
-
var \u6BB5\u306E\u9805\u76EE\u306E\u82F1\u8A9E = ["focus", "badge", "body", "description", "tween", "set", "draw"];
|
|
2223
2261
|
var DRAW_TARGETS = /* @__PURE__ */ new Map([
|
|
2224
2262
|
["line", "line"],
|
|
2225
2263
|
["bar", "bar"],
|
|
@@ -4983,7 +5021,7 @@ function compileTree(doc, onNotice) {
|
|
|
4983
5021
|
const data = doc.actors.map((a) => {
|
|
4984
5022
|
const id = slugify(a.name);
|
|
4985
5023
|
const p3 = \u89AA.get(id);
|
|
4986
|
-
return { id,
|
|
5024
|
+
return { id, ...\u653E\u5C04\u306B\u51FA\u3059\u6587\u5B57(a), ...p3 !== void 0 ? { parent: p3 } : {} };
|
|
4987
5025
|
});
|
|
4988
5026
|
b.node(`${slugify(doc.title)}-chart`, {
|
|
4989
5027
|
lane: "chart",
|
|
@@ -5248,7 +5286,7 @@ function \u653E\u5C04\u3067\u63CF\u3051\u306A\u3044\u6B04\u3092\u66F8\u3044\u305
|
|
|
5248
5286
|
}
|
|
5249
5287
|
function \u653E\u5C04\u306B\u51FA\u3059\u6587\u5B57(a) {
|
|
5250
5288
|
const \u7D9A\u304D = [a.subtitle, a.value].map((x) => x?.trim()).filter((x) => !!x);
|
|
5251
|
-
return
|
|
5289
|
+
return { title: a.name, ...\u7D9A\u304D.length > 0 ? { subtitle: \u7D9A\u304D.join(" ") } : {} };
|
|
5252
5290
|
}
|
|
5253
5291
|
function compileMind(doc, onNotice) {
|
|
5254
5292
|
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
@@ -5340,7 +5378,7 @@ function compileMind(doc, onNotice) {
|
|
|
5340
5378
|
\u8A18\u9332\u3059\u308B(a);
|
|
5341
5379
|
branches.push({
|
|
5342
5380
|
id,
|
|
5343
|
-
|
|
5381
|
+
...\u653E\u5C04\u306B\u51FA\u3059\u6587\u5B57(a),
|
|
5344
5382
|
parent: \u89AA.get(id) ?? rootId,
|
|
5345
5383
|
...a.tone ? { tone: a.tone } : {}
|
|
5346
5384
|
});
|
|
@@ -5361,7 +5399,15 @@ function compileMind(doc, onNotice) {
|
|
|
5361
5399
|
...\u56F3\u306E\u5C0F\u898B\u51FA\u3057(doc),
|
|
5362
5400
|
w: W,
|
|
5363
5401
|
h: H,
|
|
5364
|
-
mindData:
|
|
5402
|
+
mindData: (() => {
|
|
5403
|
+
const \u4E2D\u5FC3 = \u653E\u5C04\u306B\u51FA\u3059\u6587\u5B57(root);
|
|
5404
|
+
return {
|
|
5405
|
+
rootId,
|
|
5406
|
+
rootTitle: \u4E2D\u5FC3.title,
|
|
5407
|
+
...\u4E2D\u5FC3.subtitle === void 0 ? {} : { rootSubtitle: \u4E2D\u5FC3.subtitle },
|
|
5408
|
+
branches
|
|
5409
|
+
};
|
|
5410
|
+
})()
|
|
5365
5411
|
});
|
|
5366
5412
|
return b.build();
|
|
5367
5413
|
}
|
|
@@ -8116,6 +8162,6 @@ function isV05Source(src) {
|
|
|
8116
8162
|
return true;
|
|
8117
8163
|
}
|
|
8118
8164
|
|
|
8119
|
-
export { DIAGRAM_BOUNDARY_PADDING, DRAW_TARGETS, DRAW_WORDS, JSONを分解する, MAX_INPUT_BYTES, MAX_INPUT_ELEMENTS, MAX_PART_SCALE, NODE_KIND_ALIAS, NODE_KIND_VALID, PRESET_TYPES, RELATIVE_GAP_DEFAULT, TONE_ALIAS, TOP_LEVEL_KEYS, autoFix, compileToCdl, computeDiagramBoundingBox, countBytes, countDiagramElements, countDocElements, describeOversize, describeOversizeSource, diagramJsonSchema, isColorValue, jsonToDiagram, lintDiagram, measureActorBoxes, normalizePartScale, orderByDependency, parseFocusEntry, parseRelativePos, parseTextDsl, parseTextDslV05, partBoxInFrame, partDrawsInDiagram, partIsMeasurable, partRenderSize, partScaleFactor, partTargetScale, partTargetSize, partVisualSize, partsGridCenters, pointsOutside, rectsOverlap, resolveRelativePos, stripExternalPaint, stripQuotes, textDslToDiagram, validateDragonJson, writeActorPosition, 区間に広げる, 記法を分解する };
|
|
8165
|
+
export { DIAGRAM_BOUNDARY_PADDING, DRAW_TARGETS, DRAW_WORDS, JSONを分解する, MAX_INPUT_BYTES, MAX_INPUT_ELEMENTS, MAX_PART_SCALE, NODE_KIND_ALIAS, NODE_KIND_VALID, PHASE_ITEM_WORDS, PRESET_TYPES, RELATIVE_GAP_DEFAULT, TONE_ALIAS, TOP_LEVEL_KEYS, autoFix, compileToCdl, computeDiagramBoundingBox, countBytes, countDiagramElements, countDocElements, describeOversize, describeOversizeSource, diagramJsonSchema, isColorValue, jsonToDiagram, lintDiagram, measureActorBoxes, normalizePartScale, orderByDependency, parseFocusEntry, parseRelativePos, parseTextDsl, parseTextDslV05, partBoxInFrame, partDrawsInDiagram, partIsMeasurable, partRenderSize, partScaleFactor, partTargetScale, partTargetSize, partVisualSize, partsGridCenters, pointsOutside, rectsOverlap, resolveRelativePos, stripExternalPaint, stripQuotes, textDslToDiagram, validateDragonJson, writeActorPosition, 区間に広げる, 記法を分解する };
|
|
8120
8166
|
//# sourceMappingURL=index.js.map
|
|
8121
8167
|
//# sourceMappingURL=index.js.map
|