@markdy/core 0.7.26 → 0.7.27
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.d.ts +1 -1
- package/dist/index.js +79 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -197,7 +197,7 @@ declare const PRESET_NAMES: readonly string[];
|
|
|
197
197
|
*/
|
|
198
198
|
declare const BUILTIN_ACTOR_TYPES: readonly BuiltinActorType[];
|
|
199
199
|
/** Actions valid on every actor type. */
|
|
200
|
-
declare const UNIVERSAL_ACTION_NAMES: readonly ["enter", "exit", "move", "fade_in", "fade_out", "scale", "rotate", "shake", "say", "throw", "play"];
|
|
200
|
+
declare const UNIVERSAL_ACTION_NAMES: readonly ["enter", "exit", "move", "spring", "follow_path", "fade_in", "fade_out", "scale", "rotate", "shake", "pulse", "glow", "ripple", "blur", "line_reveal", "mask", "parallax", "say", "throw", "play"];
|
|
201
201
|
/**
|
|
202
202
|
* Actions that require a `figure` actor. Applying one to any other actor
|
|
203
203
|
* type is a hard `ParseError`, not a soft warning — it's always a mistake.
|
package/dist/index.js
CHANGED
|
@@ -236,11 +236,20 @@ var UNIVERSAL_ACTION_NAMES = [
|
|
|
236
236
|
"enter",
|
|
237
237
|
"exit",
|
|
238
238
|
"move",
|
|
239
|
+
"spring",
|
|
240
|
+
"follow_path",
|
|
239
241
|
"fade_in",
|
|
240
242
|
"fade_out",
|
|
241
243
|
"scale",
|
|
242
244
|
"rotate",
|
|
243
245
|
"shake",
|
|
246
|
+
"pulse",
|
|
247
|
+
"glow",
|
|
248
|
+
"ripple",
|
|
249
|
+
"blur",
|
|
250
|
+
"line_reveal",
|
|
251
|
+
"mask",
|
|
252
|
+
"parallax",
|
|
244
253
|
"say",
|
|
245
254
|
"throw",
|
|
246
255
|
"play"
|
|
@@ -517,6 +526,22 @@ var SEQ_EVENT_RE = /^@\+([\d.]+):\s+\$\.(!?\w+)\((.*)\)$/;
|
|
|
517
526
|
var CHAPTER_HEADER_RE = /^scene\s+"([^"]+)"\s*\{$/;
|
|
518
527
|
var IMPORT_RE = /^import\s+"([^"]+)"\s+as\s+(\w+)\s*$/;
|
|
519
528
|
var PRESET_RE = /^preset\s+(\w+)(?:\s*\((.*)\))?\s*$/;
|
|
529
|
+
var ARCHITECTURE_NODE_RE = /^(service|database|db|queue|cache|api|user|client|cloud|region|container|microservice|cluster)\s+(\w+)(?:\s+("[^"]+"|'[^']+'))?(?:\s+at\s+\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\))?(.*)$/;
|
|
530
|
+
var ARCHITECTURE_ALIAS_TO_TYPE = {
|
|
531
|
+
api: "service",
|
|
532
|
+
database: "database",
|
|
533
|
+
db: "db",
|
|
534
|
+
user: "client",
|
|
535
|
+
client: "client",
|
|
536
|
+
service: "service",
|
|
537
|
+
queue: "queue",
|
|
538
|
+
cache: "cache",
|
|
539
|
+
cloud: "cloud",
|
|
540
|
+
region: "region",
|
|
541
|
+
container: "container",
|
|
542
|
+
microservice: "microservice",
|
|
543
|
+
cluster: "cluster"
|
|
544
|
+
};
|
|
520
545
|
function interpolate(s, vars) {
|
|
521
546
|
return s.replace(
|
|
522
547
|
/\\?\$\{([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\}/g,
|
|
@@ -779,7 +804,7 @@ function parse(source, opts = {}) {
|
|
|
779
804
|
}
|
|
780
805
|
continue;
|
|
781
806
|
}
|
|
782
|
-
if (raw.startsWith("actor ")) {
|
|
807
|
+
if (raw.startsWith("actor ") || isArchitectureNodeLine(raw)) {
|
|
783
808
|
const actorInfo = parseActorLine(raw, lineNum, ast);
|
|
784
809
|
if (!actorCountWarned && actorCountWarningThreshold > 0) {
|
|
785
810
|
const actorCount = Object.keys(ast.actors).length;
|
|
@@ -845,6 +870,8 @@ function parseActorCallArgs(argsRaw) {
|
|
|
845
870
|
});
|
|
846
871
|
}
|
|
847
872
|
function parseActorLine(raw, lineNum, ast) {
|
|
873
|
+
const architectureNode = parseArchitectureNodeLine(raw, lineNum, ast);
|
|
874
|
+
if (architectureNode) return architectureNode;
|
|
848
875
|
const amAnchor = ACTOR_ANCHOR_POS_RE.exec(raw);
|
|
849
876
|
const amNum = amAnchor ? null : ACTOR_NUM_POS_RE.exec(raw);
|
|
850
877
|
if (!amAnchor && !amNum) throw new ParseError(`Invalid actor declaration: ${raw}`, lineNum);
|
|
@@ -935,6 +962,57 @@ function parseActorLine(raw, lineNum, ast) {
|
|
|
935
962
|
};
|
|
936
963
|
return { name, args: resolvedArgs };
|
|
937
964
|
}
|
|
965
|
+
function isArchitectureNodeLine(raw) {
|
|
966
|
+
return ARCHITECTURE_NODE_RE.test(raw);
|
|
967
|
+
}
|
|
968
|
+
function parseArchitectureNodeLine(raw, lineNum, ast) {
|
|
969
|
+
const m = ARCHITECTURE_NODE_RE.exec(raw);
|
|
970
|
+
if (!m) return null;
|
|
971
|
+
const [, alias, name, labelRaw, xRaw, yRaw, trailer] = m;
|
|
972
|
+
if (name === "camera") {
|
|
973
|
+
throw new ParseError(
|
|
974
|
+
`"camera" is a reserved actor name; choose a different architecture node name`,
|
|
975
|
+
lineNum
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
const typeName = ARCHITECTURE_ALIAS_TO_TYPE[alias] ?? alias;
|
|
979
|
+
if (!isKnownActorType(typeName)) {
|
|
980
|
+
throw new ParseError(
|
|
981
|
+
`Architecture node "${alias}" requires an actor pack that registers type "${typeName}"`,
|
|
982
|
+
lineNum
|
|
983
|
+
);
|
|
984
|
+
}
|
|
985
|
+
const actorIndex = Object.keys(ast.actors).length;
|
|
986
|
+
const x = xRaw === void 0 ? autoNodeX(actorIndex, ast.meta.width) : Number(xRaw);
|
|
987
|
+
const y = yRaw === void 0 ? autoNodeY(actorIndex, ast.meta.height, ast.meta.width) : Number(yRaw);
|
|
988
|
+
if (x < 0 || x > ast.meta.width || y < 0 || y > ast.meta.height) {
|
|
989
|
+
throw new ParseError(
|
|
990
|
+
`Actor "${name}" position (${x}, ${y}) is outside scene bounds (0\u2013${ast.meta.width}, 0\u2013${ast.meta.height})`,
|
|
991
|
+
lineNum
|
|
992
|
+
);
|
|
993
|
+
}
|
|
994
|
+
const quoted = labelRaw ? parseQuotedLiteral(labelRaw.trim()) : null;
|
|
995
|
+
const label = quoted ?? labelRaw?.trim() ?? name;
|
|
996
|
+
const modifiers = parseActorTrailer(trailer, lineNum, ast.warnings);
|
|
997
|
+
ast.actors[name] = {
|
|
998
|
+
type: typeName,
|
|
999
|
+
args: [label],
|
|
1000
|
+
x,
|
|
1001
|
+
y,
|
|
1002
|
+
...modifiers
|
|
1003
|
+
};
|
|
1004
|
+
return { name, args: [label] };
|
|
1005
|
+
}
|
|
1006
|
+
function autoNodeX(index, width) {
|
|
1007
|
+
const columns = Math.max(1, Math.floor(width / 220));
|
|
1008
|
+
const gutter = width / (columns + 1);
|
|
1009
|
+
return Math.round(gutter * (index % columns + 1));
|
|
1010
|
+
}
|
|
1011
|
+
function autoNodeY(index, height, width = DEFAULTS.width) {
|
|
1012
|
+
const columns = Math.max(1, Math.floor(width / 220));
|
|
1013
|
+
const row = Math.floor(index / columns);
|
|
1014
|
+
return Math.min(height - 60, 90 + row * 120);
|
|
1015
|
+
}
|
|
938
1016
|
var GROUP_RE = /^group\s+([A-Za-z_][\w.]*)\s*=\s*(.+)$/;
|
|
939
1017
|
function parseGroupLine(raw, lineNum, ast) {
|
|
940
1018
|
const m = GROUP_RE.exec(raw);
|