@typecaast/schema 0.1.0 → 0.2.1
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 +44 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -111
- package/dist/index.d.ts +82 -111
- package/dist/index.js +43 -22
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
- package/typecaast.schema.json +33 -91
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ var sizeSchema = zod.z.object({
|
|
|
8
8
|
height: zod.z.number().int().positive()
|
|
9
9
|
});
|
|
10
10
|
var fitModeSchema = zod.z.enum(["reflow", "scale", "fixed"]);
|
|
11
|
+
var composerModeSchema = zod.z.enum(["auto", "always", "never"]);
|
|
11
12
|
var themeModeSchema = zod.z.enum(["light", "dark", "auto"]);
|
|
12
13
|
var assetModeSchema = zod.z.enum(["inline", "url"]);
|
|
13
14
|
var skinRefSchema = zod.z.object({
|
|
@@ -25,7 +26,15 @@ var metaSchema = zod.z.object({
|
|
|
25
26
|
seed: zod.z.number().int().default(42),
|
|
26
27
|
/** Canvas background: `"transparent"` or any CSS color. */
|
|
27
28
|
background: zod.z.string().default("transparent"),
|
|
28
|
-
assets: assetModeSchema.default("inline")
|
|
29
|
+
assets: assetModeSchema.default("inline"),
|
|
30
|
+
/** Reply-box visibility (see `composerModeSchema`). */
|
|
31
|
+
composer: composerModeSchema.default("auto"),
|
|
32
|
+
/**
|
|
33
|
+
* Auto-replay when the timeline reaches the end. Honored by the builder
|
|
34
|
+
* preview and by `<Typecaast>` when the consumer doesn't pass an explicit
|
|
35
|
+
* `loop` prop.
|
|
36
|
+
*/
|
|
37
|
+
loop: zod.z.boolean().default(false)
|
|
29
38
|
});
|
|
30
39
|
var participantKindSchema = zod.z.enum(["person", "app"]);
|
|
31
40
|
var participantSchema = zod.z.object({
|
|
@@ -46,10 +55,6 @@ var pacingSchema = zod.z.object({
|
|
|
46
55
|
readingWpm: zod.z.number().positive().default(240),
|
|
47
56
|
/** Chars/sec for composer typing + sender typing duration. */
|
|
48
57
|
typingCps: zod.z.number().positive().default(14),
|
|
49
|
-
/** Lag between a message and a reaction landing. */
|
|
50
|
-
reactionDelayMs: zod.z.number().nonnegative().default(700),
|
|
51
|
-
/** Baseline beat between messages. */
|
|
52
|
-
interMessageGapMs: zod.z.number().nonnegative().default(900),
|
|
53
58
|
/** ±fraction of seeded jitter so pacing doesn't feel robotic (0–1). */
|
|
54
59
|
humanize: zod.z.number().min(0).max(1).default(0.15),
|
|
55
60
|
/** Delay before the first event. */
|
|
@@ -176,12 +181,8 @@ function toContentNodes(body) {
|
|
|
176
181
|
var stepBaseShape = {
|
|
177
182
|
/** Optional id so reactions/edits/deletes can target this step's message. */
|
|
178
183
|
id: zod.z.string().optional(),
|
|
179
|
-
/** Override the computed gap before this step (ms, relative to the prior). */
|
|
180
|
-
delay: zod.z.number().optional(),
|
|
181
184
|
/** Reveal with no animation and no computed delay. */
|
|
182
|
-
instant: zod.z.boolean().optional()
|
|
183
|
-
/** Extra pause held after this step completes (ms). */
|
|
184
|
-
holdAfter: zod.z.number().nonnegative().optional()
|
|
185
|
+
instant: zod.z.boolean().optional()
|
|
185
186
|
};
|
|
186
187
|
var imageSugarSchema = zod.z.object({
|
|
187
188
|
src: zod.z.string(),
|
|
@@ -207,9 +208,14 @@ var messageStepSchema = zod.z.object({
|
|
|
207
208
|
});
|
|
208
209
|
var reactionStepSchema = zod.z.object({
|
|
209
210
|
type: zod.z.literal("reaction"),
|
|
210
|
-
|
|
211
|
+
/** Message id to react to. Defaults to `$prev` (the most-recent message). */
|
|
212
|
+
target: zod.z.string().optional(),
|
|
211
213
|
emoji: zod.z.string(),
|
|
214
|
+
/** Emoji shortcode without colons, e.g. `"eyes"` — shown in skin tooltips. */
|
|
215
|
+
shortcode: zod.z.string().optional(),
|
|
212
216
|
from: zod.z.string().optional(),
|
|
217
|
+
/** Gap from when the target appears, before the reaction lands (ms). */
|
|
218
|
+
delay: zod.z.number().nonnegative().optional(),
|
|
213
219
|
...stepBaseShape
|
|
214
220
|
});
|
|
215
221
|
var typingStepSchema = zod.z.object({
|
|
@@ -233,13 +239,15 @@ var sendStepSchema = zod.z.object({
|
|
|
233
239
|
});
|
|
234
240
|
var editStepSchema = zod.z.object({
|
|
235
241
|
type: zod.z.literal("edit"),
|
|
236
|
-
|
|
242
|
+
/** Message id to edit. Defaults to `$prev` (the most-recent message). */
|
|
243
|
+
target: zod.z.string().optional(),
|
|
237
244
|
...bodyShape,
|
|
238
245
|
...stepBaseShape
|
|
239
246
|
});
|
|
240
247
|
var deleteStepSchema = zod.z.object({
|
|
241
248
|
type: zod.z.literal("delete"),
|
|
242
|
-
|
|
249
|
+
/** Message id to delete. Defaults to `$prev` (the most-recent message). */
|
|
250
|
+
target: zod.z.string().optional(),
|
|
243
251
|
...stepBaseShape
|
|
244
252
|
});
|
|
245
253
|
var readReceiptStepSchema = zod.z.object({
|
|
@@ -253,12 +261,25 @@ var systemStepSchema = zod.z.object({
|
|
|
253
261
|
from: zod.z.string().optional(),
|
|
254
262
|
/** Named card variant the skin renders, e.g. `"pr-opened"`. */
|
|
255
263
|
card: zod.z.string().optional(),
|
|
256
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Buttons rendered alongside the system message. When `href` is set the
|
|
266
|
+
* skin should render the button as a link that opens in a new tab; when
|
|
267
|
+
* absent it should be visibly inert (e.g. `cursor: not-allowed`). `variant`
|
|
268
|
+
* controls visual emphasis; if omitted the first action defaults to
|
|
269
|
+
* `"primary"` and the rest to `"secondary"`.
|
|
270
|
+
*/
|
|
271
|
+
actions: zod.z.array(
|
|
272
|
+
zod.z.object({
|
|
273
|
+
label: zod.z.string(),
|
|
274
|
+
href: zod.z.string().optional(),
|
|
275
|
+
variant: zod.z.enum(["primary", "secondary"]).optional()
|
|
276
|
+
})
|
|
277
|
+
).optional(),
|
|
257
278
|
...bodyShape,
|
|
258
279
|
...stepBaseShape
|
|
259
280
|
});
|
|
260
|
-
var
|
|
261
|
-
type: zod.z.literal("
|
|
281
|
+
var delayStepSchema = zod.z.object({
|
|
282
|
+
type: zod.z.literal("delay"),
|
|
262
283
|
duration: zod.z.number().nonnegative(),
|
|
263
284
|
...stepBaseShape
|
|
264
285
|
});
|
|
@@ -272,7 +293,7 @@ var timelineStepSchema = zod.z.discriminatedUnion("type", [
|
|
|
272
293
|
deleteStepSchema,
|
|
273
294
|
readReceiptStepSchema,
|
|
274
295
|
systemStepSchema,
|
|
275
|
-
|
|
296
|
+
delayStepSchema
|
|
276
297
|
]);
|
|
277
298
|
var timelineSchema = zod.z.array(timelineStepSchema);
|
|
278
299
|
var STEP_TYPES = [
|
|
@@ -285,7 +306,7 @@ var STEP_TYPES = [
|
|
|
285
306
|
"delete",
|
|
286
307
|
"readReceipt",
|
|
287
308
|
"system",
|
|
288
|
-
"
|
|
309
|
+
"delay"
|
|
289
310
|
];
|
|
290
311
|
var CONFIG_VERSION = 1;
|
|
291
312
|
var configSchema = zod.z.object({
|
|
@@ -400,14 +421,14 @@ function validateConfig(raw) {
|
|
|
400
421
|
}
|
|
401
422
|
if (step.type === "reaction" || step.type === "edit" || step.type === "delete") {
|
|
402
423
|
const target = step.target;
|
|
403
|
-
if (target === "$prev") {
|
|
424
|
+
if (!target || target === "$prev") {
|
|
404
425
|
if (priorMessages === 0) {
|
|
405
426
|
diagnostics.push({
|
|
406
427
|
code: "W_NO_PREV",
|
|
407
428
|
severity: "warning",
|
|
408
|
-
message:
|
|
429
|
+
message: "Default target has no preceding message.",
|
|
409
430
|
location: `${loc}.target`,
|
|
410
|
-
hint: "Place this after a message, or
|
|
431
|
+
hint: "Place this after a message, or set a target message id."
|
|
411
432
|
});
|
|
412
433
|
}
|
|
413
434
|
} else if (!messageIds.has(target)) {
|
|
@@ -428,13 +449,14 @@ function validateConfig(raw) {
|
|
|
428
449
|
exports.CONFIG_VERSION = CONFIG_VERSION;
|
|
429
450
|
exports.STEP_TYPES = STEP_TYPES;
|
|
430
451
|
exports.assetModeSchema = assetModeSchema;
|
|
431
|
-
exports.beatStepSchema = beatStepSchema;
|
|
432
452
|
exports.buildContentNodeSchema = buildContentNodeSchema;
|
|
453
|
+
exports.composerModeSchema = composerModeSchema;
|
|
433
454
|
exports.composerTypeStepSchema = composerTypeStepSchema;
|
|
434
455
|
exports.configJsonSchema = configJsonSchema;
|
|
435
456
|
exports.configSchema = configSchema;
|
|
436
457
|
exports.contentNodeSchema = contentNodeSchema;
|
|
437
458
|
exports.contentSchema = contentSchema;
|
|
459
|
+
exports.delayStepSchema = delayStepSchema;
|
|
438
460
|
exports.deleteStepSchema = deleteStepSchema;
|
|
439
461
|
exports.editStepSchema = editStepSchema;
|
|
440
462
|
exports.fitModeSchema = fitModeSchema;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/meta.ts","../src/participants.ts","../src/pacing.ts","../src/content-nodes.ts","../src/content-registry.ts","../src/content-sugar.ts","../src/timeline.ts","../src/config.ts","../src/validate.ts"],"names":["z"],"mappings":";;;;;AAGO,IAAM,UAAA,GAAaA,MAAE,MAAA,CAAO;AAAA,EACjC,OAAOA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA,EAAS;AAAA,EACjC,QAAQA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA;AAC3B,CAAC;AASM,IAAM,gBAAgBA,KAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,OAAA,EAAS,OAAO,CAAC;AAQzD,IAAM,kBAAkBA,KAAA,CAAE,IAAA,CAAK,CAAC,OAAA,EAAS,MAAA,EAAQ,MAAM,CAAC;AAQxD,IAAM,kBAAkBA,KAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,KAAK,CAAC;AAIhD,IAAM,aAAA,GAAgBA,MAAE,MAAA,CAAO;AAAA,EACpC,EAAA,EAAIA,KAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC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A,IAAI,WAAW,OAAA,EAAS;AACtB,QAAA,IAAI,kBAAkB,CAAA,EAAG;AACvB,UAAA,WAAA,CAAY,IAAA,CAAK;AAAA,YACf,IAAA,EAAM,WAAA;AAAA,YACN,QAAA,EAAU,SAAA;AAAA,YACV,OAAA,EAAS,0CAAA;AAAA,YACT,QAAA,EAAU,GAAG,GAAG,CAAA,OAAA,CAAA;AAAA,YAChB,IAAA,EAAM;AAAA,WACP,CAAA;AAAA,QACH;AAAA,MACF,CAAA,MAAA,IAAW,CAAC,UAAA,CAAW,GAAA,CAAI,MAAM,CAAA,EAAG;AAClC,QAAA,WAAA,CAAY,IAAA,CAAK;AAAA,UACf,IAAA,EAAM,UAAA;AAAA,UACN,QAAA,EAAU,SAAA;AAAA,UACV,OAAA,EAAS,WAAW,MAAM,CAAA,kCAAA,CAAA;AAAA,UAC1B,QAAA,EAAU,GAAG,GAAG,CAAA,OAAA,CAAA;AAAA,UAChB,IAAA,EAAM;AAAA,SACP,CAAA;AAAA,MACH;AAAA,IACF;AAEA,IAAA,IAAI,IAAA,CAAK,IAAA,KAAS,SAAA,IAAa,IAAA,CAAK,SAAS,QAAA,EAAU,aAAA,EAAA;AAAA,EACzD,CAAC,CAAA;AAED,EAAA,OAAO,WAAA;AACT","file":"index.cjs","sourcesContent":["import { z } from \"zod\";\n\n/** A pixel dimension pair (authoring reference; the exact frame for video). */\nexport const sizeSchema = z.object({\n width: z.number().int().positive(),\n height: z.number().int().positive(),\n});\nexport type Size = z.infer<typeof sizeSchema>;\n\n/**\n * How the rendered conversation fills its container.\n * - `reflow`: container queries + ResizeObserver; bubbles re-wrap on small screens.\n * - `scale`: CSS transform scale-to-fit, preserves exact layout.\n * - `fixed`: clip to canvas.\n */\nexport const fitModeSchema = z.enum([\"reflow\", \"scale\", \"fixed\"]);\nexport type FitMode = z.infer<typeof fitModeSchema>;\n\n/**\n * Color theme. `auto` inherits the host page's `prefers-color-scheme` (live\n * preview) and falls back to `light`; video export resolves `auto` to a\n * concrete mode and defaults to `light` when unspecified.\n */\nexport const themeModeSchema = z.enum([\"light\", \"dark\", \"auto\"]);\nexport type ThemeMode = z.infer<typeof themeModeSchema>;\n\n/**\n * Asset resolution strategy.\n * - `inline`: embed images as data URLs (self-contained config; default).\n * - `url`: reference hosted images (smaller config; user hosts their own).\n */\nexport const assetModeSchema = z.enum([\"inline\", \"url\"]);\nexport type AssetMode = z.infer<typeof assetModeSchema>;\n\n/** Reference to a skin plus its skin-specific options (validated by the skin). */\nexport const skinRefSchema = z.object({\n id: z.string().min(1),\n options: z.record(z.string(), z.unknown()).optional(),\n});\nexport type SkinRef = z.infer<typeof skinRefSchema>;\n\n/** Top-level rendering/authoring metadata. */\nexport const metaSchema = z.object({\n /** Authoring reference size; fixed frame for video. */\n canvas: sizeSchema,\n fps: z.number().int().positive().default(30),\n fit: fitModeSchema.default(\"reflow\"),\n theme: themeModeSchema.default(\"auto\"),\n skin: skinRefSchema,\n /** Seed for all deterministic jitter (no `Math.random`). */\n seed: z.number().int().default(42),\n /** Canvas background: `\"transparent\"` or any CSS color. */\n background: z.string().default(\"transparent\"),\n assets: assetModeSchema.default(\"inline\"),\n});\n\n/** `meta` as it appears after parsing (defaults applied). */\nexport type Meta = z.infer<typeof metaSchema>;\n/** `meta` as authored (fields with defaults are optional). */\nexport type MetaInput = z.input<typeof metaSchema>;\n","import { z } from \"zod\";\n\n/** Whether a participant is a human or an app/bot (changes how skins render it). */\nexport const participantKindSchema = z.enum([\"person\", \"app\"]);\nexport type ParticipantKind = z.infer<typeof participantKindSchema>;\n\n/** A speaker in the conversation. */\nexport const participantSchema = z.object({\n /** Stable id referenced by timeline steps (`from`, `target`, …). */\n id: z.string().min(1),\n name: z.string().min(1),\n /** Avatar asset (data URL or referenced URL per `meta.assets`). */\n avatar: z.string().optional(),\n /** Accent color (CSS color) some skins use for the author. */\n color: z.string().optional(),\n /** The viewer — rendered as the \"self\" side and the composer's author. */\n isSelf: z.boolean().optional(),\n kind: participantKindSchema.default(\"person\"),\n});\nexport type Participant = z.infer<typeof participantSchema>;\nexport type ParticipantInput = z.input<typeof participantSchema>;\n\nexport const participantsSchema = z.array(participantSchema);\n","import { z } from \"zod\";\n\n/**\n * Global auto-pacing defaults. Every value is overridable per step in the\n * timeline; the engine computes delays/durations from these and bakes in\n * seeded, deterministic jitter (`humanize`).\n */\nexport const pacingSchema = z.object({\n /** Gap before an incoming message ≈ reading time of the prior message. */\n readingWpm: z.number().positive().default(240),\n /** Chars/sec for composer typing + sender typing duration. */\n typingCps: z.number().positive().default(14),\n /** Lag between a message and a reaction landing. */\n reactionDelayMs: z.number().nonnegative().default(700),\n /** Baseline beat between messages. */\n interMessageGapMs: z.number().nonnegative().default(900),\n /** ±fraction of seeded jitter so pacing doesn't feel robotic (0–1). */\n humanize: z.number().min(0).max(1).default(0.15),\n /** Delay before the first event. */\n startDelayMs: z.number().nonnegative().default(400),\n});\nexport type Pacing = z.infer<typeof pacingSchema>;\nexport type PacingInput = z.input<typeof pacingSchema>;\n","import { z } from \"zod\";\n\n/**\n * Inline marks inside a text node. `text` runs carry plain content; the others\n * are the recognized marks (`code`, `link`, `mention`, `emoji`). The set is\n * intentionally small in v1 — new marks can be added without a schema-version\n * bump (unknown content node types are handled leniently; see the registry).\n */\nexport const inlineTextSchema = z.object({\n type: z.literal(\"text\"),\n value: z.string(),\n});\nexport const inlineCodeSchema = z.object({\n type: z.literal(\"code\"),\n value: z.string(),\n});\nexport const inlineLinkSchema = z.object({\n type: z.literal(\"link\"),\n href: z.string(),\n label: z.string().optional(),\n});\nexport const inlineMentionSchema = z.object({\n type: z.literal(\"mention\"),\n /** Display label as authored, e.g. `\"@PostHog\"`. */\n label: z.string(),\n /** Resolved participant id, filled when the mention binds to a participant. */\n id: z.string().optional(),\n});\nexport const inlineEmojiSchema = z.object({\n type: z.literal(\"emoji\"),\n /** The rendered glyph, e.g. `\"🦔\"`. */\n value: z.string(),\n /** Optional shortcode, e.g. `\"hedgehog\"`. */\n shortcode: z.string().optional(),\n});\n\nexport const inlineNodeSchema = z.discriminatedUnion(\"type\", [\n inlineTextSchema,\n inlineCodeSchema,\n inlineLinkSchema,\n inlineMentionSchema,\n inlineEmojiSchema,\n]);\nexport type InlineNode = z.infer<typeof inlineNodeSchema>;\n\n/** A block of inline content. */\nexport const textNodeSchema = z.object({\n type: z.literal(\"text\"),\n spans: z.array(inlineNodeSchema),\n});\nexport type TextNode = z.infer<typeof textNodeSchema>;\n\n/** An in-message image (same hosting model as avatars, per `meta.assets`). */\nexport const imageNodeSchema = z.object({\n type: z.literal(\"image\"),\n src: z.string(),\n alt: z.string().optional(),\n width: z.number().positive().optional(),\n height: z.number().positive().optional(),\n});\nexport type ImageNode = z.infer<typeof imageNodeSchema>;\n\n/**\n * A content node whose `type` the runtime doesn't recognize. It validates\n * leniently (only `type` is required) and is skipped by skins that don't handle\n * it — so future node types (`attachment`, `linkPreview`, …) slot in without\n * breaking older runtimes or bumping the schema version.\n */\nexport interface UnknownContentNode {\n type: string;\n [key: string]: unknown;\n}\n\n/** The body of a message: an ordered list of content nodes. */\nexport type ContentNode = TextNode | ImageNode | UnknownContentNode;\n","import { z } from \"zod\";\nimport {\n imageNodeSchema,\n textNodeSchema,\n type ContentNode,\n} from \"./content-nodes.js\";\n\n/**\n * The content-type registry. Each message body node has a `type` resolved\n * through here. v1 registers `text` and `image`; additional types can be\n * registered (with their own strict schema) without a schema-version bump.\n *\n * Nodes whose `type` is **not** registered validate leniently (only `type` is\n * required) and are skipped by skins that don't handle them. Nodes whose `type`\n * **is** registered must satisfy that type's schema — so a malformed `text`\n * node is an error rather than silently passing through the lenient path.\n */\nconst registry = new Map<string, z.ZodTypeAny>([\n [\"text\", textNodeSchema],\n [\"image\", imageNodeSchema],\n]);\n\n/** Register (or override) the strict schema for a content node type. */\nexport function registerContentNodeType(\n type: string,\n schema: z.ZodTypeAny,\n): void {\n registry.set(type, schema);\n}\n\n/** The content node types the runtime validates strictly. */\nexport function knownContentNodeTypes(): string[] {\n return [...registry.keys()];\n}\n\nexport function isKnownContentNodeType(type: string): boolean {\n return registry.has(type);\n}\n\n/** Accepts any object with a string `type` that isn't a registered type. */\nconst lenientUnknownNodeSchema = z\n .looseObject({ type: z.string() })\n .refine((node) => !registry.has(node.type), {\n message: \"malformed content node for a registered type\",\n });\n\n/**\n * Build a content-node schema from the current registry state. Call this after\n * registering a new type to pick it up; `contentNodeSchema` below is the\n * default built from the v1 registry (`text` + `image`).\n */\nexport function buildContentNodeSchema(): z.ZodType<ContentNode> {\n return z.union([\n ...registry.values(),\n lenientUnknownNodeSchema,\n ]) as unknown as z.ZodType<ContentNode>;\n}\n\n/** Default content-node schema (text + image + lenient unknown). */\nexport const contentNodeSchema = buildContentNodeSchema();\n\n/** A message body: an ordered array of content nodes. */\nexport const contentSchema = z.array(contentNodeSchema);\n","import type {\n ContentNode,\n ImageNode,\n InlineNode,\n TextNode,\n} from \"./content-nodes.js\";\n\n/**\n * Matches an inline mark: a backtick code span, an http(s) link, or an\n * `@mention`. Everything else becomes plain text runs.\n */\nconst INLINE_TOKEN = /`([^`]+)`|(https?:\\/\\/[^\\s]+)|(@[A-Za-z0-9_][\\w.-]*)/g;\n\n/**\n * Parse a plain authoring string into inline nodes, extracting inline `code`,\n * links, and `@mentions`. Emoji are left inside text runs in v1 (they render\n * fine and a dedicated emoji mark can be authored explicitly).\n */\nexport function parseInline(text: string): InlineNode[] {\n if (text.length === 0) return [];\n const spans: InlineNode[] = [];\n const re = new RegExp(INLINE_TOKEN.source, \"g\");\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(text)) !== null) {\n const matchText = match[0] ?? \"\";\n if (match.index > lastIndex) {\n spans.push({ type: \"text\", value: text.slice(lastIndex, match.index) });\n }\n if (match[1] !== undefined) {\n spans.push({ type: \"code\", value: match[1] });\n } else if (match[2] !== undefined) {\n spans.push({ type: \"link\", href: match[2] });\n } else if (match[3] !== undefined) {\n spans.push({ type: \"mention\", label: match[3] });\n }\n lastIndex = match.index + matchText.length;\n }\n if (lastIndex < text.length) {\n spans.push({ type: \"text\", value: text.slice(lastIndex) });\n }\n return spans;\n}\n\n/** Convenience shape for authoring an in-message image. */\nexport interface ImageSugar {\n src: string;\n alt?: string;\n width?: number;\n height?: number;\n}\n\n/** `text` string → a single text content node. */\nexport function textToContentNode(text: string): TextNode {\n return { type: \"text\", spans: parseInline(text) };\n}\n\n/** `image` sugar → an image content node (drops undefined optionals). */\nexport function imageToContentNode(image: ImageSugar): ImageNode {\n const node: ImageNode = { type: \"image\", src: image.src };\n if (image.alt !== undefined) node.alt = image.alt;\n if (image.width !== undefined) node.width = image.width;\n if (image.height !== undefined) node.height = image.height;\n return node;\n}\n\n/** The sugar fields a message may carry instead of explicit `content`. */\nexport interface MessageBodySugar {\n /** Authored text (parsed into inline marks). */\n text?: string;\n /** In-message images, rendered after the text. */\n images?: ImageSugar[];\n /** Explicit content nodes; when present, wins over `text`/`images`. */\n content?: ContentNode[];\n}\n\n/**\n * Resolve a message's body sugar to content nodes. Explicit `content` is\n * authoritative; otherwise the text node (if any) comes first, then images —\n * matching the \"here's the toast: [image]\" ordering in the spec example.\n */\nexport function toContentNodes(body: MessageBodySugar): ContentNode[] {\n if (body.content) return body.content;\n const nodes: ContentNode[] = [];\n if (body.text !== undefined && body.text.length > 0) {\n nodes.push(textToContentNode(body.text));\n }\n if (body.images) {\n for (const image of body.images) nodes.push(imageToContentNode(image));\n }\n return nodes;\n}\n","import { z } from \"zod\";\nimport { contentSchema } from \"./content-registry.js\";\n\n/**\n * Per-step overrides shared by every step. The engine computes timing from the\n * pacing model; these win over the computed values.\n */\nconst stepBaseShape = {\n /** Optional id so reactions/edits/deletes can target this step's message. */\n id: z.string().optional(),\n /** Override the computed gap before this step (ms, relative to the prior). */\n delay: z.number().optional(),\n /** Reveal with no animation and no computed delay. */\n instant: z.boolean().optional(),\n /** Extra pause held after this step completes (ms). */\n holdAfter: z.number().nonnegative().optional(),\n};\n\n/** Authoring sugar for an in-message image (compiled to an image node). */\nexport const imageSugarSchema = z.object({\n src: z.string(),\n alt: z.string().optional(),\n width: z.number().positive().optional(),\n height: z.number().positive().optional(),\n});\n\n/** Message-body sugar fields; `content` (explicit nodes) wins when present. */\nconst bodyShape = {\n text: z.string().optional(),\n images: z.array(imageSugarSchema).optional(),\n content: contentSchema.optional(),\n};\n\n/** Optional typing indicator preceding a message. */\nconst messageTypingSchema = z.union([\n z.boolean(),\n z.object({ showTypingFor: z.number().nonnegative().optional() }),\n]);\n\n/** An incoming message, optionally preceded by a typing indicator. */\nexport const messageStepSchema = z.object({\n type: z.literal(\"message\"),\n from: z.string(),\n typing: messageTypingSchema.optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** A reaction landing on a target message (`$prev` or a message id). */\nexport const reactionStepSchema = z.object({\n type: z.literal(\"reaction\"),\n target: z.string(),\n emoji: z.string(),\n from: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** A standalone typing indicator (no message necessarily follows). */\nexport const typingStepSchema = z.object({\n type: z.literal(\"typing\"),\n from: z.string(),\n showTypingFor: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** The self participant typing into the composer, char by char. */\nexport const composerTypeStepSchema = z.object({\n type: z.literal(\"composerType\"),\n from: z.string(),\n text: z.string(),\n /** Override the computed typing duration (ms). */\n typingDuration: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** Commit the composer's current text to the thread. */\nexport const sendStepSchema = z.object({\n type: z.literal(\"send\"),\n from: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** Edit a previously sent message's body. */\nexport const editStepSchema = z.object({\n type: z.literal(\"edit\"),\n target: z.string(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** Delete a previously sent message. */\nexport const deleteStepSchema = z.object({\n type: z.literal(\"delete\"),\n target: z.string(),\n ...stepBaseShape,\n});\n\n/** A read receipt (optionally by a participant, optionally up to a message). */\nexport const readReceiptStepSchema = z.object({\n type: z.literal(\"readReceipt\"),\n by: z.string().optional(),\n target: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** An app/system card (e.g. \"Pull request opened\" with action buttons). */\nexport const systemStepSchema = z.object({\n type: z.literal(\"system\"),\n from: z.string().optional(),\n /** Named card variant the skin renders, e.g. `\"pr-opened\"`. */\n card: z.string().optional(),\n actions: z\n .array(z.object({ label: z.string(), href: z.string().optional() }))\n .optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** An explicit pause in the timeline. */\nexport const beatStepSchema = z.object({\n type: z.literal(\"beat\"),\n duration: z.number().nonnegative(),\n ...stepBaseShape,\n});\n\nexport const timelineStepSchema = z.discriminatedUnion(\"type\", [\n messageStepSchema,\n reactionStepSchema,\n typingStepSchema,\n composerTypeStepSchema,\n sendStepSchema,\n editStepSchema,\n deleteStepSchema,\n readReceiptStepSchema,\n systemStepSchema,\n beatStepSchema,\n]);\nexport type TimelineStep = z.infer<typeof timelineStepSchema>;\nexport type TimelineStepInput = z.input<typeof timelineStepSchema>;\n\nexport const timelineSchema = z.array(timelineStepSchema);\n\n/** The discriminant values of every timeline step. */\nexport const STEP_TYPES = [\n \"message\",\n \"reaction\",\n \"typing\",\n \"composerType\",\n \"send\",\n \"edit\",\n \"delete\",\n \"readReceipt\",\n \"system\",\n \"beat\",\n] as const;\nexport type StepType = (typeof STEP_TYPES)[number];\n","import { z } from \"zod\";\nimport { metaSchema } from \"./meta.js\";\nimport { participantsSchema } from \"./participants.js\";\nimport { pacingSchema } from \"./pacing.js\";\nimport { timelineSchema } from \"./timeline.js\";\n\n/**\n * The config schema version. Distinct from the `@typecaast/schema` package\n * version (related but versioned independently — see PLAN §22). A config newer\n * than the installed runtime fails parsing with a clear error.\n */\nexport const CONFIG_VERSION = 1;\n\n/** The complete Typecaast config: the single source of truth for a simulation. */\nexport const configSchema = z.object({\n version: z.literal(CONFIG_VERSION),\n meta: metaSchema,\n participants: participantsSchema,\n /** Optional; omitted pacing resolves to the full default model. */\n pacing: pacingSchema.default(() => pacingSchema.parse({})),\n timeline: timelineSchema,\n});\n\n/** A parsed config (defaults applied). */\nexport type Config = z.infer<typeof configSchema>;\n/** A config as authored (fields with defaults are optional). */\nexport type ConfigInput = z.input<typeof configSchema>;\n\n/**\n * Generate the JSON Schema for a Typecaast config (for editor autocomplete and\n * `$schema` references). Lazy so importing the package never eagerly runs the\n * conversion. Refinements (e.g. the lenient content-node guard) are not\n * representable in JSON Schema and are dropped.\n */\nexport function configJsonSchema(): Record<string, unknown> {\n return z.toJSONSchema(configSchema, {\n unrepresentable: \"any\",\n target: \"draft-7\",\n }) as Record<string, unknown>;\n}\n","import { CONFIG_VERSION, configSchema } from \"./config.js\";\n\n/** Diagnostic severity tiers (PLAN §23). */\nexport type Severity = \"error\" | \"warning\" | \"info\";\n\n/**\n * A single validation finding. Every diagnostic carries a stable `code`, the\n * offending `location` (step/message/path), and a `hint` for remediation.\n */\nexport interface Diagnostic {\n code: string;\n severity: Severity;\n message: string;\n /** Dotted/indexed path, e.g. `timeline[3].from` or `meta.canvas.width`. */\n location?: string;\n hint?: string;\n}\n\nfunction formatPath(path: ReadonlyArray<PropertyKey>): string {\n let out = \"\";\n for (const key of path) {\n if (typeof key === \"number\") out += `[${key}]`;\n else if (out === \"\") out += String(key);\n else out += `.${String(key)}`;\n }\n return out;\n}\n\n/** Read an optional `from`/`by`/`target` field off any step shape. */\nfunction field(step: unknown, key: string): string | undefined {\n const value = (step as Record<string, unknown>)[key];\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * Validate a parsed config value (already JSON-decoded). Returns all\n * diagnostics — schema errors, then semantic checks (reference integrity,\n * target resolution). Reusable by the CLI and the builder's lint panel.\n *\n * A version newer than the runtime short-circuits with a single hard error.\n */\nexport function validateConfig(raw: unknown): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n if (raw && typeof raw === \"object\" && \"version\" in raw) {\n const version = (raw as { version: unknown }).version;\n if (typeof version === \"number\" && version > CONFIG_VERSION) {\n return [\n {\n code: \"E_VERSION\",\n severity: \"error\",\n message: `Config version ${version} is newer than this runtime supports (max ${CONFIG_VERSION}).`,\n location: \"version\",\n hint: \"Upgrade Typecaast (e.g. `npm i @typecaast/cli@latest`).\",\n },\n ];\n }\n }\n\n const result = configSchema.safeParse(raw);\n if (!result.success) {\n for (const issue of result.error.issues) {\n diagnostics.push({\n code: \"E_SCHEMA\",\n severity: \"error\",\n message: issue.message,\n location: formatPath(issue.path) || undefined,\n });\n }\n return diagnostics;\n }\n\n const config = result.data;\n\n // Duplicate participant ids.\n const ids = config.participants.map((p) => p.id);\n const idSet = new Set(ids);\n for (const dup of new Set(ids.filter((id, i) => ids.indexOf(id) !== i))) {\n diagnostics.push({\n code: \"E_DUP_PARTICIPANT\",\n severity: \"error\",\n message: `Duplicate participant id \"${dup}\".`,\n location: \"participants\",\n hint: \"Participant ids must be unique.\",\n });\n }\n\n const hasSelf = config.participants.some((p) => p.isSelf);\n let warnedNoSelf = false;\n const messageIds = new Set<string>();\n let priorMessages = 0;\n\n config.timeline.forEach((step, i) => {\n const loc = `timeline[${i}]`;\n\n const from = field(step, \"from\");\n if (from !== undefined && !idSet.has(from)) {\n diagnostics.push({\n code: \"E_REF_PARTICIPANT\",\n severity: \"error\",\n message: `Step references unknown participant \"${from}\".`,\n location: `${loc}.from`,\n hint: `Add a participant with id \"${from}\" or fix the reference.`,\n });\n }\n\n if (step.type === \"readReceipt\") {\n const by = field(step, \"by\");\n if (by !== undefined && !idSet.has(by)) {\n diagnostics.push({\n code: \"E_REF_PARTICIPANT\",\n severity: \"error\",\n message: `Read receipt references unknown participant \"${by}\".`,\n location: `${loc}.by`,\n hint: `Add a participant with id \"${by}\" or fix the reference.`,\n });\n }\n }\n\n if (\n (step.type === \"composerType\" || step.type === \"send\") &&\n !hasSelf &&\n !warnedNoSelf\n ) {\n warnedNoSelf = true;\n diagnostics.push({\n code: \"W_NO_SELF\",\n severity: \"warning\",\n message: \"The composer is used but no participant is marked as self.\",\n location: loc,\n hint: 'Mark a participant with `\"isSelf\": true`.',\n });\n }\n\n if (\n (step.type === \"message\" || step.type === \"system\") &&\n typeof step.id === \"string\"\n ) {\n messageIds.add(step.id);\n }\n\n if (\n step.type === \"reaction\" ||\n step.type === \"edit\" ||\n step.type === \"delete\"\n ) {\n const target = step.target;\n if (target === \"$prev\") {\n if (priorMessages === 0) {\n diagnostics.push({\n code: \"W_NO_PREV\",\n severity: \"warning\",\n message: '\"$prev\" target has no preceding message.',\n location: `${loc}.target`,\n hint: \"Place this after a message, or target a message id.\",\n });\n }\n } else if (!messageIds.has(target)) {\n diagnostics.push({\n code: \"W_TARGET\",\n severity: \"warning\",\n message: `Target \"${target}\" matches no preceding message id.`,\n location: `${loc}.target`,\n hint: 'Give the target message an `\"id\"`, or check the reference.',\n });\n }\n }\n\n if (step.type === \"message\" || step.type === \"system\") priorMessages++;\n });\n\n return diagnostics;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/meta.ts","../src/participants.ts","../src/pacing.ts","../src/content-nodes.ts","../src/content-registry.ts","../src/content-sugar.ts","../src/timeline.ts","../src/config.ts","../src/validate.ts"],"names":["z"],"mappings":";;;;;AAGO,IAAM,UAAA,GAAaA,MAAE,MAAA,CAAO;AAAA,EACjC,OAAOA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA,EAAS;AAAA,EACjC,QAAQA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA;AAC3B,CAAC;AAgBM,IAAM,gBAAgBA,KAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,OAAA,EAAS,OAAO,CAAC;AASzD,IAAM,qBAAqBA,KAAA,CAAE,IAAA,CAAK,CAAC,MAAA,EAAQ,QAAA,EAAU,OAAO,CAAC;AAQ7D,IAAM,kBAAkBA,KAAA,CAAE,IAAA,CAAK,CAAC,OAAA,EAAS,MAAA,EAAQ,MAAM,CAAC;AAQxD,IAAM,kBAAkBA,KAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,KAAK,CAAC;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ference; the exact frame for video). */\nexport const sizeSchema = z.object({\n width: z.number().int().positive(),\n height: z.number().int().positive(),\n});\nexport type Size = z.infer<typeof sizeSchema>;\n\n/**\n * How the rendered conversation fills its container. The widget is\n * **container-driven** in the first two modes — its size never grows\n * with content; messages clip when they overflow the bottom-anchored\n * thread.\n * - `reflow`: fills the container in both axes; bubbles re-wrap to the\n * container width.\n * - `scale`: renders at the exact authored canvas size and CSS-scales\n * to fit (preserves the canonical layout — letterboxes if the\n * container's aspect doesn't match the canvas).\n * - `fixed`: pins the widget to the authored canvas px; clips. The only\n * non-container-driven mode.\n */\nexport const fitModeSchema = z.enum([\"reflow\", \"scale\", \"fixed\"]);\nexport type FitMode = z.infer<typeof fitModeSchema>;\n\n/**\n * Reply-box (composer) visibility:\n * - `auto`: shown only while someone is typing/sending (default).\n * - `always`: keep the message input visible the whole time.\n * - `never`: never show it.\n */\nexport const composerModeSchema = z.enum([\"auto\", \"always\", \"never\"]);\nexport type ComposerMode = z.infer<typeof composerModeSchema>;\n\n/**\n * Color theme. `auto` inherits the host page's `prefers-color-scheme` (live\n * preview) and falls back to `light`; video export resolves `auto` to a\n * concrete mode and defaults to `light` when unspecified.\n */\nexport const themeModeSchema = z.enum([\"light\", \"dark\", \"auto\"]);\nexport type ThemeMode = z.infer<typeof themeModeSchema>;\n\n/**\n * Asset resolution strategy.\n * - `inline`: embed images as data URLs (self-contained config; default).\n * - `url`: reference hosted images (smaller config; user hosts their own).\n */\nexport const assetModeSchema = z.enum([\"inline\", \"url\"]);\nexport type AssetMode = z.infer<typeof assetModeSchema>;\n\n/** Reference to a skin plus its skin-specific options (validated by the skin). */\nexport const skinRefSchema = z.object({\n id: z.string().min(1),\n options: z.record(z.string(), z.unknown()).optional(),\n});\nexport type SkinRef = z.infer<typeof skinRefSchema>;\n\n/** Top-level rendering/authoring metadata. */\nexport const metaSchema = z.object({\n /** Authoring reference size; fixed frame for video. */\n canvas: sizeSchema,\n fps: z.number().int().positive().default(30),\n fit: fitModeSchema.default(\"reflow\"),\n theme: themeModeSchema.default(\"auto\"),\n skin: skinRefSchema,\n /** Seed for all deterministic jitter (no `Math.random`). */\n seed: z.number().int().default(42),\n /** Canvas background: `\"transparent\"` or any CSS color. */\n background: z.string().default(\"transparent\"),\n assets: assetModeSchema.default(\"inline\"),\n /** Reply-box visibility (see `composerModeSchema`). */\n composer: composerModeSchema.default(\"auto\"),\n /**\n * Auto-replay when the timeline reaches the end. Honored by the builder\n * preview and by `<Typecaast>` when the consumer doesn't pass an explicit\n * `loop` prop.\n */\n loop: z.boolean().default(false),\n});\n\n/** `meta` as it appears after parsing (defaults applied). */\nexport type Meta = z.infer<typeof metaSchema>;\n/** `meta` as authored (fields with defaults are optional). */\nexport type MetaInput = z.input<typeof metaSchema>;\n","import { z } from \"zod\";\n\n/** Whether a participant is a human or an app/bot (changes how skins render it). */\nexport const participantKindSchema = z.enum([\"person\", \"app\"]);\nexport type ParticipantKind = z.infer<typeof participantKindSchema>;\n\n/** A speaker in the conversation. */\nexport const participantSchema = z.object({\n /** Stable id referenced by timeline steps (`from`, `target`, …). */\n id: z.string().min(1),\n name: z.string().min(1),\n /** Avatar asset (data URL or referenced URL per `meta.assets`). */\n avatar: z.string().optional(),\n /** Accent color (CSS color) some skins use for the author. */\n color: z.string().optional(),\n /** The viewer — rendered as the \"self\" side and the composer's author. */\n isSelf: z.boolean().optional(),\n kind: participantKindSchema.default(\"person\"),\n});\nexport type Participant = z.infer<typeof participantSchema>;\nexport type ParticipantInput = z.input<typeof participantSchema>;\n\nexport const participantsSchema = z.array(participantSchema);\n","import { z } from \"zod\";\n\n/**\n * Global auto-pacing defaults. Every value is overridable per step in the\n * timeline; the engine computes delays/durations from these and bakes in\n * seeded, deterministic jitter (`humanize`).\n */\nexport const pacingSchema = z.object({\n /** Gap before an incoming message ≈ reading time of the prior message. */\n readingWpm: z.number().positive().default(240),\n /** Chars/sec for composer typing + sender typing duration. */\n typingCps: z.number().positive().default(14),\n /** ±fraction of seeded jitter so pacing doesn't feel robotic (0–1). */\n humanize: z.number().min(0).max(1).default(0.15),\n /** Delay before the first event. */\n startDelayMs: z.number().nonnegative().default(400),\n});\nexport type Pacing = z.infer<typeof pacingSchema>;\nexport type PacingInput = z.input<typeof pacingSchema>;\n","import { z } from \"zod\";\n\n/**\n * Inline marks inside a text node. `text` runs carry plain content; the others\n * are the recognized marks (`code`, `link`, `mention`, `emoji`). The set is\n * intentionally small in v1 — new marks can be added without a schema-version\n * bump (unknown content node types are handled leniently; see the registry).\n */\nexport const inlineTextSchema = z.object({\n type: z.literal(\"text\"),\n value: z.string(),\n});\nexport const inlineCodeSchema = z.object({\n type: z.literal(\"code\"),\n value: z.string(),\n});\nexport const inlineLinkSchema = z.object({\n type: z.literal(\"link\"),\n href: z.string(),\n label: z.string().optional(),\n});\nexport const inlineMentionSchema = z.object({\n type: z.literal(\"mention\"),\n /** Display label as authored, e.g. `\"@PostHog\"`. */\n label: z.string(),\n /** Resolved participant id, filled when the mention binds to a participant. */\n id: z.string().optional(),\n});\nexport const inlineEmojiSchema = z.object({\n type: z.literal(\"emoji\"),\n /** The rendered glyph, e.g. `\"🦔\"`. */\n value: z.string(),\n /** Optional shortcode, e.g. `\"hedgehog\"`. */\n shortcode: z.string().optional(),\n});\n\nexport const inlineNodeSchema = z.discriminatedUnion(\"type\", [\n inlineTextSchema,\n inlineCodeSchema,\n inlineLinkSchema,\n inlineMentionSchema,\n inlineEmojiSchema,\n]);\nexport type InlineNode = z.infer<typeof inlineNodeSchema>;\n\n/** A block of inline content. */\nexport const textNodeSchema = z.object({\n type: z.literal(\"text\"),\n spans: z.array(inlineNodeSchema),\n});\nexport type TextNode = z.infer<typeof textNodeSchema>;\n\n/** An in-message image (same hosting model as avatars, per `meta.assets`). */\nexport const imageNodeSchema = z.object({\n type: z.literal(\"image\"),\n src: z.string(),\n alt: z.string().optional(),\n width: z.number().positive().optional(),\n height: z.number().positive().optional(),\n});\nexport type ImageNode = z.infer<typeof imageNodeSchema>;\n\n/**\n * A content node whose `type` the runtime doesn't recognize. It validates\n * leniently (only `type` is required) and is skipped by skins that don't handle\n * it — so future node types (`attachment`, `linkPreview`, …) slot in without\n * breaking older runtimes or bumping the schema version.\n */\nexport interface UnknownContentNode {\n type: string;\n [key: string]: unknown;\n}\n\n/** The body of a message: an ordered list of content nodes. */\nexport type ContentNode = TextNode | ImageNode | UnknownContentNode;\n","import { z } from \"zod\";\nimport {\n imageNodeSchema,\n textNodeSchema,\n type ContentNode,\n} from \"./content-nodes.js\";\n\n/**\n * The content-type registry. Each message body node has a `type` resolved\n * through here. v1 registers `text` and `image`; additional types can be\n * registered (with their own strict schema) without a schema-version bump.\n *\n * Nodes whose `type` is **not** registered validate leniently (only `type` is\n * required) and are skipped by skins that don't handle them. Nodes whose `type`\n * **is** registered must satisfy that type's schema — so a malformed `text`\n * node is an error rather than silently passing through the lenient path.\n */\nconst registry = new Map<string, z.ZodTypeAny>([\n [\"text\", textNodeSchema],\n [\"image\", imageNodeSchema],\n]);\n\n/** Register (or override) the strict schema for a content node type. */\nexport function registerContentNodeType(\n type: string,\n schema: z.ZodTypeAny,\n): void {\n registry.set(type, schema);\n}\n\n/** The content node types the runtime validates strictly. */\nexport function knownContentNodeTypes(): string[] {\n return [...registry.keys()];\n}\n\nexport function isKnownContentNodeType(type: string): boolean {\n return registry.has(type);\n}\n\n/** Accepts any object with a string `type` that isn't a registered type. */\nconst lenientUnknownNodeSchema = z\n .looseObject({ type: z.string() })\n .refine((node) => !registry.has(node.type), {\n message: \"malformed content node for a registered type\",\n });\n\n/**\n * Build a content-node schema from the current registry state. Call this after\n * registering a new type to pick it up; `contentNodeSchema` below is the\n * default built from the v1 registry (`text` + `image`).\n */\nexport function buildContentNodeSchema(): z.ZodType<ContentNode> {\n return z.union([\n ...registry.values(),\n lenientUnknownNodeSchema,\n ]) as unknown as z.ZodType<ContentNode>;\n}\n\n/** Default content-node schema (text + image + lenient unknown). */\nexport const contentNodeSchema = buildContentNodeSchema();\n\n/** A message body: an ordered array of content nodes. */\nexport const contentSchema = z.array(contentNodeSchema);\n","import type {\n ContentNode,\n ImageNode,\n InlineNode,\n TextNode,\n} from \"./content-nodes.js\";\n\n/**\n * Matches an inline mark: a backtick code span, an http(s) link, or an\n * `@mention`. Everything else becomes plain text runs.\n */\nconst INLINE_TOKEN = /`([^`]+)`|(https?:\\/\\/[^\\s]+)|(@[A-Za-z0-9_][\\w.-]*)/g;\n\n/**\n * Parse a plain authoring string into inline nodes, extracting inline `code`,\n * links, and `@mentions`. Emoji are left inside text runs in v1 (they render\n * fine and a dedicated emoji mark can be authored explicitly).\n */\nexport function parseInline(text: string): InlineNode[] {\n if (text.length === 0) return [];\n const spans: InlineNode[] = [];\n const re = new RegExp(INLINE_TOKEN.source, \"g\");\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(text)) !== null) {\n const matchText = match[0] ?? \"\";\n if (match.index > lastIndex) {\n spans.push({ type: \"text\", value: text.slice(lastIndex, match.index) });\n }\n if (match[1] !== undefined) {\n spans.push({ type: \"code\", value: match[1] });\n } else if (match[2] !== undefined) {\n spans.push({ type: \"link\", href: match[2] });\n } else if (match[3] !== undefined) {\n spans.push({ type: \"mention\", label: match[3] });\n }\n lastIndex = match.index + matchText.length;\n }\n if (lastIndex < text.length) {\n spans.push({ type: \"text\", value: text.slice(lastIndex) });\n }\n return spans;\n}\n\n/** Convenience shape for authoring an in-message image. */\nexport interface ImageSugar {\n src: string;\n alt?: string;\n width?: number;\n height?: number;\n}\n\n/** `text` string → a single text content node. */\nexport function textToContentNode(text: string): TextNode {\n return { type: \"text\", spans: parseInline(text) };\n}\n\n/** `image` sugar → an image content node (drops undefined optionals). */\nexport function imageToContentNode(image: ImageSugar): ImageNode {\n const node: ImageNode = { type: \"image\", src: image.src };\n if (image.alt !== undefined) node.alt = image.alt;\n if (image.width !== undefined) node.width = image.width;\n if (image.height !== undefined) node.height = image.height;\n return node;\n}\n\n/** The sugar fields a message may carry instead of explicit `content`. */\nexport interface MessageBodySugar {\n /** Authored text (parsed into inline marks). */\n text?: string;\n /** In-message images, rendered after the text. */\n images?: ImageSugar[];\n /** Explicit content nodes; when present, wins over `text`/`images`. */\n content?: ContentNode[];\n}\n\n/**\n * Resolve a message's body sugar to content nodes. Explicit `content` is\n * authoritative; otherwise the text node (if any) comes first, then images —\n * matching the \"here's the toast: [image]\" ordering in the spec example.\n */\nexport function toContentNodes(body: MessageBodySugar): ContentNode[] {\n if (body.content) return body.content;\n const nodes: ContentNode[] = [];\n if (body.text !== undefined && body.text.length > 0) {\n nodes.push(textToContentNode(body.text));\n }\n if (body.images) {\n for (const image of body.images) nodes.push(imageToContentNode(image));\n }\n return nodes;\n}\n","import { z } from \"zod\";\nimport { contentSchema } from \"./content-registry.js\";\n\n/**\n * Per-step overrides shared by every step. The engine computes timing from the\n * pacing model; these win over the computed values. Use a dedicated `delay`\n * step type to insert explicit pauses on the timeline.\n */\nconst stepBaseShape = {\n /** Optional id so reactions/edits/deletes can target this step's message. */\n id: z.string().optional(),\n /** Reveal with no animation and no computed delay. */\n instant: z.boolean().optional(),\n};\n\n/** Authoring sugar for an in-message image (compiled to an image node). */\nexport const imageSugarSchema = z.object({\n src: z.string(),\n alt: z.string().optional(),\n width: z.number().positive().optional(),\n height: z.number().positive().optional(),\n});\n\n/** Message-body sugar fields; `content` (explicit nodes) wins when present. */\nconst bodyShape = {\n text: z.string().optional(),\n images: z.array(imageSugarSchema).optional(),\n content: contentSchema.optional(),\n};\n\n/** Optional typing indicator preceding a message. */\nconst messageTypingSchema = z.union([\n z.boolean(),\n z.object({ showTypingFor: z.number().nonnegative().optional() }),\n]);\n\n/** An incoming message, optionally preceded by a typing indicator. */\nexport const messageStepSchema = z.object({\n type: z.literal(\"message\"),\n from: z.string(),\n typing: messageTypingSchema.optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** A reaction landing on a target message (`$prev` or a message id). */\nexport const reactionStepSchema = z.object({\n type: z.literal(\"reaction\"),\n /** Message id to react to. Defaults to `$prev` (the most-recent message). */\n target: z.string().optional(),\n emoji: z.string(),\n /** Emoji shortcode without colons, e.g. `\"eyes\"` — shown in skin tooltips. */\n shortcode: z.string().optional(),\n from: z.string().optional(),\n /** Gap from when the target appears, before the reaction lands (ms). */\n delay: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** A standalone typing indicator (no message necessarily follows). */\nexport const typingStepSchema = z.object({\n type: z.literal(\"typing\"),\n from: z.string(),\n showTypingFor: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** The self participant typing into the composer, char by char. */\nexport const composerTypeStepSchema = z.object({\n type: z.literal(\"composerType\"),\n from: z.string(),\n text: z.string(),\n /** Override the computed typing duration (ms). */\n typingDuration: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** Commit the composer's current text to the thread. */\nexport const sendStepSchema = z.object({\n type: z.literal(\"send\"),\n from: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** Edit a previously sent message's body. */\nexport const editStepSchema = z.object({\n type: z.literal(\"edit\"),\n /** Message id to edit. Defaults to `$prev` (the most-recent message). */\n target: z.string().optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** Delete a previously sent message. */\nexport const deleteStepSchema = z.object({\n type: z.literal(\"delete\"),\n /** Message id to delete. Defaults to `$prev` (the most-recent message). */\n target: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** A read receipt (optionally by a participant, optionally up to a message). */\nexport const readReceiptStepSchema = z.object({\n type: z.literal(\"readReceipt\"),\n by: z.string().optional(),\n target: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** An app/system card (e.g. \"Pull request opened\" with action buttons). */\nexport const systemStepSchema = z.object({\n type: z.literal(\"system\"),\n from: z.string().optional(),\n /** Named card variant the skin renders, e.g. `\"pr-opened\"`. */\n card: z.string().optional(),\n /**\n * Buttons rendered alongside the system message. When `href` is set the\n * skin should render the button as a link that opens in a new tab; when\n * absent it should be visibly inert (e.g. `cursor: not-allowed`). `variant`\n * controls visual emphasis; if omitted the first action defaults to\n * `\"primary\"` and the rest to `\"secondary\"`.\n */\n actions: z\n .array(\n z.object({\n label: z.string(),\n href: z.string().optional(),\n variant: z.enum([\"primary\", \"secondary\"]).optional(),\n }),\n )\n .optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** An explicit pause in the timeline (formerly `beat`). */\nexport const delayStepSchema = z.object({\n type: z.literal(\"delay\"),\n duration: z.number().nonnegative(),\n ...stepBaseShape,\n});\n\nexport const timelineStepSchema = z.discriminatedUnion(\"type\", [\n messageStepSchema,\n reactionStepSchema,\n typingStepSchema,\n composerTypeStepSchema,\n sendStepSchema,\n editStepSchema,\n deleteStepSchema,\n readReceiptStepSchema,\n systemStepSchema,\n delayStepSchema,\n]);\nexport type TimelineStep = z.infer<typeof timelineStepSchema>;\nexport type TimelineStepInput = z.input<typeof timelineStepSchema>;\n\nexport const timelineSchema = z.array(timelineStepSchema);\n\n/** The discriminant values of every timeline step. */\nexport const STEP_TYPES = [\n \"message\",\n \"reaction\",\n \"typing\",\n \"composerType\",\n \"send\",\n \"edit\",\n \"delete\",\n \"readReceipt\",\n \"system\",\n \"delay\",\n] as const;\nexport type StepType = (typeof STEP_TYPES)[number];\n","import { z } from \"zod\";\nimport { metaSchema } from \"./meta.js\";\nimport { participantsSchema } from \"./participants.js\";\nimport { pacingSchema } from \"./pacing.js\";\nimport { timelineSchema } from \"./timeline.js\";\n\n/**\n * The config schema version. Distinct from the `@typecaast/schema` package\n * version (related but versioned independently — see PLAN §22). A config newer\n * than the installed runtime fails parsing with a clear error.\n */\nexport const CONFIG_VERSION = 1;\n\n/** The complete Typecaast config: the single source of truth for a simulation. */\nexport const configSchema = z.object({\n version: z.literal(CONFIG_VERSION),\n meta: metaSchema,\n participants: participantsSchema,\n /** Optional; omitted pacing resolves to the full default model. */\n pacing: pacingSchema.default(() => pacingSchema.parse({})),\n timeline: timelineSchema,\n});\n\n/** A parsed config (defaults applied). */\nexport type Config = z.infer<typeof configSchema>;\n/** A config as authored (fields with defaults are optional). */\nexport type ConfigInput = z.input<typeof configSchema>;\n\n/**\n * Generate the JSON Schema for a Typecaast config (for editor autocomplete and\n * `$schema` references). Lazy so importing the package never eagerly runs the\n * conversion. Refinements (e.g. the lenient content-node guard) are not\n * representable in JSON Schema and are dropped.\n */\nexport function configJsonSchema(): Record<string, unknown> {\n return z.toJSONSchema(configSchema, {\n unrepresentable: \"any\",\n target: \"draft-7\",\n }) as Record<string, unknown>;\n}\n","import { CONFIG_VERSION, configSchema } from \"./config.js\";\n\n/** Diagnostic severity tiers (PLAN §23). */\nexport type Severity = \"error\" | \"warning\" | \"info\";\n\n/**\n * A single validation finding. Every diagnostic carries a stable `code`, the\n * offending `location` (step/message/path), and a `hint` for remediation.\n */\nexport interface Diagnostic {\n code: string;\n severity: Severity;\n message: string;\n /** Dotted/indexed path, e.g. `timeline[3].from` or `meta.canvas.width`. */\n location?: string;\n hint?: string;\n}\n\nfunction formatPath(path: ReadonlyArray<PropertyKey>): string {\n let out = \"\";\n for (const key of path) {\n if (typeof key === \"number\") out += `[${key}]`;\n else if (out === \"\") out += String(key);\n else out += `.${String(key)}`;\n }\n return out;\n}\n\n/** Read an optional `from`/`by`/`target` field off any step shape. */\nfunction field(step: unknown, key: string): string | undefined {\n const value = (step as Record<string, unknown>)[key];\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * Validate a parsed config value (already JSON-decoded). Returns all\n * diagnostics — schema errors, then semantic checks (reference integrity,\n * target resolution). Reusable by the CLI and the builder's lint panel.\n *\n * A version newer than the runtime short-circuits with a single hard error.\n */\nexport function validateConfig(raw: unknown): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n if (raw && typeof raw === \"object\" && \"version\" in raw) {\n const version = (raw as { version: unknown }).version;\n if (typeof version === \"number\" && version > CONFIG_VERSION) {\n return [\n {\n code: \"E_VERSION\",\n severity: \"error\",\n message: `Config version ${version} is newer than this runtime supports (max ${CONFIG_VERSION}).`,\n location: \"version\",\n hint: \"Upgrade Typecaast (e.g. `npm i @typecaast/cli@latest`).\",\n },\n ];\n }\n }\n\n const result = configSchema.safeParse(raw);\n if (!result.success) {\n for (const issue of result.error.issues) {\n diagnostics.push({\n code: \"E_SCHEMA\",\n severity: \"error\",\n message: issue.message,\n location: formatPath(issue.path) || undefined,\n });\n }\n return diagnostics;\n }\n\n const config = result.data;\n\n // Duplicate participant ids.\n const ids = config.participants.map((p) => p.id);\n const idSet = new Set(ids);\n for (const dup of new Set(ids.filter((id, i) => ids.indexOf(id) !== i))) {\n diagnostics.push({\n code: \"E_DUP_PARTICIPANT\",\n severity: \"error\",\n message: `Duplicate participant id \"${dup}\".`,\n location: \"participants\",\n hint: \"Participant ids must be unique.\",\n });\n }\n\n const hasSelf = config.participants.some((p) => p.isSelf);\n let warnedNoSelf = false;\n const messageIds = new Set<string>();\n let priorMessages = 0;\n\n config.timeline.forEach((step, i) => {\n const loc = `timeline[${i}]`;\n\n const from = field(step, \"from\");\n if (from !== undefined && !idSet.has(from)) {\n diagnostics.push({\n code: \"E_REF_PARTICIPANT\",\n severity: \"error\",\n message: `Step references unknown participant \"${from}\".`,\n location: `${loc}.from`,\n hint: `Add a participant with id \"${from}\" or fix the reference.`,\n });\n }\n\n if (step.type === \"readReceipt\") {\n const by = field(step, \"by\");\n if (by !== undefined && !idSet.has(by)) {\n diagnostics.push({\n code: \"E_REF_PARTICIPANT\",\n severity: \"error\",\n message: `Read receipt references unknown participant \"${by}\".`,\n location: `${loc}.by`,\n hint: `Add a participant with id \"${by}\" or fix the reference.`,\n });\n }\n }\n\n if (\n (step.type === \"composerType\" || step.type === \"send\") &&\n !hasSelf &&\n !warnedNoSelf\n ) {\n warnedNoSelf = true;\n diagnostics.push({\n code: \"W_NO_SELF\",\n severity: \"warning\",\n message: \"The composer is used but no participant is marked as self.\",\n location: loc,\n hint: 'Mark a participant with `\"isSelf\": true`.',\n });\n }\n\n if (\n (step.type === \"message\" || step.type === \"system\") &&\n typeof step.id === \"string\"\n ) {\n messageIds.add(step.id);\n }\n\n if (\n step.type === \"reaction\" ||\n step.type === \"edit\" ||\n step.type === \"delete\"\n ) {\n const target = step.target;\n // Blank/`$prev` both mean \"the most-recent message\".\n if (!target || target === \"$prev\") {\n if (priorMessages === 0) {\n diagnostics.push({\n code: \"W_NO_PREV\",\n severity: \"warning\",\n message: \"Default target has no preceding message.\",\n location: `${loc}.target`,\n hint: \"Place this after a message, or set a target message id.\",\n });\n }\n } else if (!messageIds.has(target)) {\n diagnostics.push({\n code: \"W_TARGET\",\n severity: \"warning\",\n message: `Target \"${target}\" matches no preceding message id.`,\n location: `${loc}.target`,\n hint: 'Give the target message an `\"id\"`, or check the reference.',\n });\n }\n }\n\n if (step.type === \"message\" || step.type === \"system\") priorMessages++;\n });\n\n return diagnostics;\n}\n"]}
|