@magicborn/dialogue-forge 0.1.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/README.md +233 -0
- package/bin/dialogue-forge.js +78 -0
- package/demo/app/layout.tsx +36 -0
- package/demo/app/page.tsx +440 -0
- package/demo/components/ThemeSwitcher.tsx +611 -0
- package/demo/next.config.mjs +7 -0
- package/demo/package.json +29 -0
- package/demo/postcss.config.mjs +7 -0
- package/demo/public/logo.svg +1 -0
- package/demo/styles/globals.css +19 -0
- package/demo/tailwind.config.ts +90 -0
- package/demo/tsconfig.json +42 -0
- package/dist/components/ChoiceEdgeV2.d.ts +3 -0
- package/dist/components/ChoiceEdgeV2.js +103 -0
- package/dist/components/CodeBlock.d.ts +8 -0
- package/dist/components/CodeBlock.js +24 -0
- package/dist/components/ConditionAutocomplete.d.ts +14 -0
- package/dist/components/ConditionAutocomplete.js +284 -0
- package/dist/components/ConditionalNodeV2.d.ts +16 -0
- package/dist/components/ConditionalNodeV2.js +147 -0
- package/dist/components/DialogueEditorV2.d.ts +22 -0
- package/dist/components/DialogueEditorV2.js +1170 -0
- package/dist/components/EdgeIcon.d.ts +8 -0
- package/dist/components/EdgeIcon.js +13 -0
- package/dist/components/ExampleLoader.d.ts +11 -0
- package/dist/components/ExampleLoader.js +52 -0
- package/dist/components/ExampleLoaderButton.d.ts +15 -0
- package/dist/components/ExampleLoaderButton.js +102 -0
- package/dist/components/FlagManager.d.ts +11 -0
- package/dist/components/FlagManager.js +282 -0
- package/dist/components/FlagSelector.d.ts +11 -0
- package/dist/components/FlagSelector.js +235 -0
- package/dist/components/GuidePanel.d.ts +7 -0
- package/dist/components/GuidePanel.js +1176 -0
- package/dist/components/Minimap.d.ts +16 -0
- package/dist/components/Minimap.js +93 -0
- package/dist/components/NPCEdgeV2.d.ts +3 -0
- package/dist/components/NPCEdgeV2.js +104 -0
- package/dist/components/NPCNodeV2.d.ts +26 -0
- package/dist/components/NPCNodeV2.js +86 -0
- package/dist/components/NodeEditor.d.ts +18 -0
- package/dist/components/NodeEditor.js +1025 -0
- package/dist/components/PlayView.d.ts +12 -0
- package/dist/components/PlayView.js +307 -0
- package/dist/components/PlayerNodeV2.d.ts +16 -0
- package/dist/components/PlayerNodeV2.js +139 -0
- package/dist/components/ReactFlowPOC.d.ts +61 -0
- package/dist/components/ReactFlowPOC.js +312 -0
- package/dist/components/ScenePlayer.d.ts +18 -0
- package/dist/components/ScenePlayer.js +196 -0
- package/dist/components/YarnView.d.ts +9 -0
- package/dist/components/YarnView.js +45 -0
- package/dist/components/ZoomControls.d.ts +11 -0
- package/dist/components/ZoomControls.js +34 -0
- package/dist/esm/components/ChoiceEdgeV2.d.ts +3 -0
- package/dist/esm/components/ChoiceEdgeV2.js +67 -0
- package/dist/esm/components/CodeBlock.d.ts +8 -0
- package/dist/esm/components/CodeBlock.js +18 -0
- package/dist/esm/components/ConditionAutocomplete.d.ts +14 -0
- package/dist/esm/components/ConditionAutocomplete.js +248 -0
- package/dist/esm/components/ConditionalNodeV2.d.ts +16 -0
- package/dist/esm/components/ConditionalNodeV2.js +111 -0
- package/dist/esm/components/DialogueEditorV2.d.ts +22 -0
- package/dist/esm/components/DialogueEditorV2.js +1134 -0
- package/dist/esm/components/EdgeIcon.d.ts +8 -0
- package/dist/esm/components/EdgeIcon.js +7 -0
- package/dist/esm/components/ExampleLoader.d.ts +11 -0
- package/dist/esm/components/ExampleLoader.js +46 -0
- package/dist/esm/components/ExampleLoaderButton.d.ts +15 -0
- package/dist/esm/components/ExampleLoaderButton.js +66 -0
- package/dist/esm/components/FlagManager.d.ts +11 -0
- package/dist/esm/components/FlagManager.js +246 -0
- package/dist/esm/components/FlagSelector.d.ts +11 -0
- package/dist/esm/components/FlagSelector.js +199 -0
- package/dist/esm/components/GuidePanel.d.ts +7 -0
- package/dist/esm/components/GuidePanel.js +1140 -0
- package/dist/esm/components/Minimap.d.ts +16 -0
- package/dist/esm/components/Minimap.js +57 -0
- package/dist/esm/components/NPCEdgeV2.d.ts +3 -0
- package/dist/esm/components/NPCEdgeV2.js +68 -0
- package/dist/esm/components/NPCNodeV2.d.ts +26 -0
- package/dist/esm/components/NPCNodeV2.js +80 -0
- package/dist/esm/components/NodeEditor.d.ts +18 -0
- package/dist/esm/components/NodeEditor.js +989 -0
- package/dist/esm/components/PlayView.d.ts +12 -0
- package/dist/esm/components/PlayView.js +271 -0
- package/dist/esm/components/PlayerNodeV2.d.ts +16 -0
- package/dist/esm/components/PlayerNodeV2.js +103 -0
- package/dist/esm/components/ReactFlowPOC.d.ts +61 -0
- package/dist/esm/components/ReactFlowPOC.js +275 -0
- package/dist/esm/components/ScenePlayer.d.ts +18 -0
- package/dist/esm/components/ScenePlayer.js +160 -0
- package/dist/esm/components/YarnView.d.ts +9 -0
- package/dist/esm/components/YarnView.js +39 -0
- package/dist/esm/components/ZoomControls.d.ts +11 -0
- package/dist/esm/components/ZoomControls.js +28 -0
- package/dist/esm/examples/example-loader.d.ts +29 -0
- package/dist/esm/examples/example-loader.js +103 -0
- package/dist/esm/examples/examples-registry.d.ts +38 -0
- package/dist/esm/examples/examples-registry.js +153 -0
- package/dist/esm/examples/index.d.ts +26 -0
- package/dist/esm/examples/index.js +50 -0
- package/dist/esm/examples/legacy-examples.d.ts +9 -0
- package/dist/esm/examples/legacy-examples.js +814 -0
- package/dist/esm/examples/yarn-examples.d.ts +35 -0
- package/dist/esm/examples/yarn-examples.js +181 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/lib/flag-manager.d.ts +21 -0
- package/dist/esm/lib/flag-manager.js +93 -0
- package/dist/esm/lib/yarn-converter/__tests__/round-trip.test.d.ts +1 -0
- package/dist/esm/lib/yarn-converter/__tests__/round-trip.test.js +169 -0
- package/dist/esm/lib/yarn-converter.d.ts +17 -0
- package/dist/esm/lib/yarn-converter.js +521 -0
- package/dist/esm/lib/yarn-runner/__tests__/condition-evaluator.test.d.ts +1 -0
- package/dist/esm/lib/yarn-runner/__tests__/condition-evaluator.test.js +171 -0
- package/dist/esm/lib/yarn-runner/__tests__/node-processor.test.d.ts +1 -0
- package/dist/esm/lib/yarn-runner/__tests__/node-processor.test.js +237 -0
- package/dist/esm/lib/yarn-runner/__tests__/variable-manager.test.d.ts +1 -0
- package/dist/esm/lib/yarn-runner/__tests__/variable-manager.test.js +106 -0
- package/dist/esm/lib/yarn-runner/condition-evaluator.d.ts +12 -0
- package/dist/esm/lib/yarn-runner/condition-evaluator.js +56 -0
- package/dist/esm/lib/yarn-runner/index.d.ts +12 -0
- package/dist/esm/lib/yarn-runner/index.js +11 -0
- package/dist/esm/lib/yarn-runner/node-processor.d.ts +18 -0
- package/dist/esm/lib/yarn-runner/node-processor.js +129 -0
- package/dist/esm/lib/yarn-runner/variable-manager.d.ts +51 -0
- package/dist/esm/lib/yarn-runner/variable-manager.js +120 -0
- package/dist/esm/lib/yarn-runner/variable-operations.d.ts +16 -0
- package/dist/esm/lib/yarn-runner/variable-operations.js +88 -0
- package/dist/esm/types/conditionals.d.ts +29 -0
- package/dist/esm/types/conditionals.js +1 -0
- package/dist/esm/types/constants.d.ts +59 -0
- package/dist/esm/types/constants.js +55 -0
- package/dist/esm/types/flags.d.ts +49 -0
- package/dist/esm/types/flags.js +49 -0
- package/dist/esm/types/game-state.d.ts +62 -0
- package/dist/esm/types/game-state.js +6 -0
- package/dist/esm/types/index.d.ts +77 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/utils/constants.d.ts +5 -0
- package/dist/esm/utils/constants.js +5 -0
- package/dist/esm/utils/feature-flags.d.ts +11 -0
- package/dist/esm/utils/feature-flags.js +11 -0
- package/dist/esm/utils/game-state-flattener.d.ts +41 -0
- package/dist/esm/utils/game-state-flattener.js +135 -0
- package/dist/esm/utils/layout/collision.d.ts +27 -0
- package/dist/esm/utils/layout/collision.js +74 -0
- package/dist/esm/utils/layout/index.d.ts +82 -0
- package/dist/esm/utils/layout/index.js +98 -0
- package/dist/esm/utils/layout/registry.d.ts +91 -0
- package/dist/esm/utils/layout/registry.js +148 -0
- package/dist/esm/utils/layout/strategies/dagre.d.ts +19 -0
- package/dist/esm/utils/layout/strategies/dagre.js +182 -0
- package/dist/esm/utils/layout/strategies/force.d.ts +21 -0
- package/dist/esm/utils/layout/strategies/force.js +178 -0
- package/dist/esm/utils/layout/strategies/grid.d.ts +17 -0
- package/dist/esm/utils/layout/strategies/grid.js +91 -0
- package/dist/esm/utils/layout/strategies/index.d.ts +8 -0
- package/dist/esm/utils/layout/strategies/index.js +8 -0
- package/dist/esm/utils/layout/types.d.ts +100 -0
- package/dist/esm/utils/layout/types.js +7 -0
- package/dist/esm/utils/layout.d.ts +9 -0
- package/dist/esm/utils/layout.js +17 -0
- package/dist/esm/utils/node-helpers.d.ts +7 -0
- package/dist/esm/utils/node-helpers.js +94 -0
- package/dist/esm/utils/reactflow-converter.d.ts +42 -0
- package/dist/esm/utils/reactflow-converter.js +217 -0
- package/dist/examples/example-loader.d.ts +29 -0
- package/dist/examples/example-loader.js +109 -0
- package/dist/examples/examples-registry.d.ts +38 -0
- package/dist/examples/examples-registry.js +160 -0
- package/dist/examples/index.d.ts +26 -0
- package/dist/examples/index.js +63 -0
- package/dist/examples/legacy-examples.d.ts +9 -0
- package/dist/examples/legacy-examples.js +817 -0
- package/dist/examples/yarn-examples.d.ts +35 -0
- package/dist/examples/yarn-examples.js +189 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +66 -0
- package/dist/lib/flag-manager.d.ts +21 -0
- package/dist/lib/flag-manager.js +99 -0
- package/dist/lib/yarn-converter/__tests__/round-trip.test.d.ts +1 -0
- package/dist/lib/yarn-converter/__tests__/round-trip.test.js +171 -0
- package/dist/lib/yarn-converter.d.ts +17 -0
- package/dist/lib/yarn-converter.js +525 -0
- package/dist/lib/yarn-runner/__tests__/condition-evaluator.test.d.ts +1 -0
- package/dist/lib/yarn-runner/__tests__/condition-evaluator.test.js +173 -0
- package/dist/lib/yarn-runner/__tests__/node-processor.test.d.ts +1 -0
- package/dist/lib/yarn-runner/__tests__/node-processor.test.js +239 -0
- package/dist/lib/yarn-runner/__tests__/variable-manager.test.d.ts +1 -0
- package/dist/lib/yarn-runner/__tests__/variable-manager.test.js +108 -0
- package/dist/lib/yarn-runner/condition-evaluator.d.ts +12 -0
- package/dist/lib/yarn-runner/condition-evaluator.js +60 -0
- package/dist/lib/yarn-runner/index.d.ts +12 -0
- package/dist/lib/yarn-runner/index.js +21 -0
- package/dist/lib/yarn-runner/node-processor.d.ts +18 -0
- package/dist/lib/yarn-runner/node-processor.js +133 -0
- package/dist/lib/yarn-runner/variable-manager.d.ts +51 -0
- package/dist/lib/yarn-runner/variable-manager.js +124 -0
- package/dist/lib/yarn-runner/variable-operations.d.ts +16 -0
- package/dist/lib/yarn-runner/variable-operations.js +92 -0
- package/dist/types/conditionals.d.ts +29 -0
- package/dist/types/conditionals.js +2 -0
- package/dist/types/constants.d.ts +59 -0
- package/dist/types/constants.js +58 -0
- package/dist/types/flags.d.ts +49 -0
- package/dist/types/flags.js +52 -0
- package/dist/types/game-state.d.ts +62 -0
- package/dist/types/game-state.js +7 -0
- package/dist/types/index.d.ts +77 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/constants.d.ts +5 -0
- package/dist/utils/constants.js +8 -0
- package/dist/utils/feature-flags.d.ts +11 -0
- package/dist/utils/feature-flags.js +14 -0
- package/dist/utils/game-state-flattener.d.ts +41 -0
- package/dist/utils/game-state-flattener.js +140 -0
- package/dist/utils/layout/collision.d.ts +27 -0
- package/dist/utils/layout/collision.js +77 -0
- package/dist/utils/layout/index.d.ts +82 -0
- package/dist/utils/layout/index.js +109 -0
- package/dist/utils/layout/registry.d.ts +91 -0
- package/dist/utils/layout/registry.js +151 -0
- package/dist/utils/layout/strategies/dagre.d.ts +19 -0
- package/dist/utils/layout/strategies/dagre.js +189 -0
- package/dist/utils/layout/strategies/force.d.ts +21 -0
- package/dist/utils/layout/strategies/force.js +182 -0
- package/dist/utils/layout/strategies/grid.d.ts +17 -0
- package/dist/utils/layout/strategies/grid.js +95 -0
- package/dist/utils/layout/strategies/index.d.ts +8 -0
- package/dist/utils/layout/strategies/index.js +14 -0
- package/dist/utils/layout/types.d.ts +100 -0
- package/dist/utils/layout/types.js +8 -0
- package/dist/utils/layout.d.ts +9 -0
- package/dist/utils/layout.js +25 -0
- package/dist/utils/node-helpers.d.ts +7 -0
- package/dist/utils/node-helpers.js +101 -0
- package/dist/utils/reactflow-converter.d.ts +42 -0
- package/dist/utils/reactflow-converter.js +223 -0
- package/package.json +70 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadExampleDialogue = loadExampleDialogue;
|
|
4
|
+
exports.getFlagSchemaForExample = getFlagSchemaForExample;
|
|
5
|
+
exports.getAllExamples = getAllExamples;
|
|
6
|
+
exports.loadExampleDialogueSync = loadExampleDialogueSync;
|
|
7
|
+
const yarn_converter_1 = require("../lib/yarn-converter");
|
|
8
|
+
const examples_registry_1 = require("./examples-registry");
|
|
9
|
+
/**
|
|
10
|
+
* Load an example dialogue from a Yarn file
|
|
11
|
+
* This is the unified way to load examples - all examples are Yarn files
|
|
12
|
+
*/
|
|
13
|
+
async function loadExampleDialogue(exampleId) {
|
|
14
|
+
const metadata = (0, examples_registry_1.getExampleMetadata)(exampleId);
|
|
15
|
+
if (!metadata) {
|
|
16
|
+
console.warn(`Example not found: ${exampleId}`);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
// Dynamically import the Yarn file
|
|
21
|
+
// In a build environment, these will be bundled
|
|
22
|
+
// In Node.js/test environment, we'll read from filesystem
|
|
23
|
+
const yarnContent = await loadYarnFile(metadata.filename);
|
|
24
|
+
if (!yarnContent) {
|
|
25
|
+
console.warn(`Failed to load Yarn file: ${metadata.filename}`);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
// Convert Yarn to DialogueTree
|
|
29
|
+
const dialogue = (0, yarn_converter_1.importFromYarn)(yarnContent, metadata.title);
|
|
30
|
+
// Update node count in metadata if not set
|
|
31
|
+
if (!metadata.nodeCount) {
|
|
32
|
+
metadata.nodeCount = Object.keys(dialogue.nodes).length;
|
|
33
|
+
}
|
|
34
|
+
return dialogue;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error(`Error loading example ${exampleId}:`, error);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Load Yarn file content
|
|
43
|
+
* This handles both browser (bundled) and Node.js (filesystem) environments
|
|
44
|
+
*/
|
|
45
|
+
async function loadYarnFile(filename) {
|
|
46
|
+
// In browser/build environment, we'll need to import as text
|
|
47
|
+
// For now, we'll use a simple approach that works in both
|
|
48
|
+
try {
|
|
49
|
+
// Try to import as a module (works in bundlers like Vite/Webpack)
|
|
50
|
+
if (typeof window !== 'undefined') {
|
|
51
|
+
// Browser environment - files should be imported as text
|
|
52
|
+
// This will be handled by the bundler configuration
|
|
53
|
+
const response = await fetch(`/examples/${filename}`);
|
|
54
|
+
if (response.ok) {
|
|
55
|
+
return await response.text();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Node.js/test environment - read from filesystem
|
|
59
|
+
if (typeof require !== 'undefined') {
|
|
60
|
+
const fs = require('fs');
|
|
61
|
+
const path = require('path');
|
|
62
|
+
const filePath = path.join(__dirname, filename);
|
|
63
|
+
if (fs.existsSync(filePath)) {
|
|
64
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error(`Error loading Yarn file ${filename}:`, error);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get flag schema for an example
|
|
76
|
+
*/
|
|
77
|
+
function getFlagSchemaForExample(exampleId) {
|
|
78
|
+
const metadata = (0, examples_registry_1.getExampleMetadata)(exampleId);
|
|
79
|
+
if (!metadata) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return (0, examples_registry_1.getExampleFlagSchema)(metadata.flagSchemaId);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get all examples with their metadata
|
|
86
|
+
*/
|
|
87
|
+
function getAllExamples() {
|
|
88
|
+
return examples_registry_1.examplesRegistry.map(metadata => ({
|
|
89
|
+
...metadata,
|
|
90
|
+
flagSchema: (0, examples_registry_1.getExampleFlagSchema)(metadata.flagSchemaId)
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Synchronous version for use with pre-loaded examples
|
|
95
|
+
* This is used when examples are bundled/inlined
|
|
96
|
+
*/
|
|
97
|
+
function loadExampleDialogueSync(exampleId, yarnContent) {
|
|
98
|
+
const metadata = (0, examples_registry_1.getExampleMetadata)(exampleId);
|
|
99
|
+
if (!metadata) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
return (0, yarn_converter_1.importFromYarn)(yarnContent, metadata.title);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.error(`Error loading example ${exampleId}:`, error);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FlagSchema } from '../types/flags';
|
|
2
|
+
/**
|
|
3
|
+
* Example metadata - describes each example file
|
|
4
|
+
*/
|
|
5
|
+
export interface ExampleMetadata {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
filename: string;
|
|
10
|
+
flagSchemaId: string;
|
|
11
|
+
nodeCount?: number;
|
|
12
|
+
features: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Registry of all available examples
|
|
16
|
+
* This is the single source of truth for example discovery
|
|
17
|
+
*/
|
|
18
|
+
export declare const examplesRegistry: ExampleMetadata[];
|
|
19
|
+
/**
|
|
20
|
+
* Flag schemas for examples
|
|
21
|
+
*/
|
|
22
|
+
export declare const exampleFlagSchemas: Record<string, FlagSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Get example metadata by ID
|
|
25
|
+
*/
|
|
26
|
+
export declare function getExampleMetadata(id: string): ExampleMetadata | null;
|
|
27
|
+
/**
|
|
28
|
+
* List all available example IDs
|
|
29
|
+
*/
|
|
30
|
+
export declare function listExampleIds(): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Get flag schema by ID
|
|
33
|
+
*/
|
|
34
|
+
export declare function getExampleFlagSchema(id: string): FlagSchema | null;
|
|
35
|
+
/**
|
|
36
|
+
* List all available flag schema IDs
|
|
37
|
+
*/
|
|
38
|
+
export declare function listFlagSchemaIds(): string[];
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exampleFlagSchemas = exports.examplesRegistry = void 0;
|
|
4
|
+
exports.getExampleMetadata = getExampleMetadata;
|
|
5
|
+
exports.listExampleIds = listExampleIds;
|
|
6
|
+
exports.getExampleFlagSchema = getExampleFlagSchema;
|
|
7
|
+
exports.listFlagSchemaIds = listFlagSchemaIds;
|
|
8
|
+
const constants_1 = require("../types/constants");
|
|
9
|
+
/**
|
|
10
|
+
* Registry of all available examples
|
|
11
|
+
* This is the single source of truth for example discovery
|
|
12
|
+
*/
|
|
13
|
+
exports.examplesRegistry = [
|
|
14
|
+
{
|
|
15
|
+
id: 'basic',
|
|
16
|
+
title: 'Basic Dialogue Example',
|
|
17
|
+
description: 'Simple dialogue with player choices',
|
|
18
|
+
filename: 'basic-dialogue.yarn',
|
|
19
|
+
flagSchemaId: 'basic',
|
|
20
|
+
features: ['basic-choices']
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'conditional',
|
|
24
|
+
title: 'Conditional Dialogue Example',
|
|
25
|
+
description: 'Dialogue with conditional choices based on flags',
|
|
26
|
+
filename: 'conditional-dialogue.yarn',
|
|
27
|
+
flagSchemaId: 'conditional',
|
|
28
|
+
features: ['conditional-choices', 'flag-checks']
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'quest-progression',
|
|
32
|
+
title: 'Quest Progression Example',
|
|
33
|
+
description: 'Quest system with progression and rewards',
|
|
34
|
+
filename: 'quest-progression.yarn',
|
|
35
|
+
flagSchemaId: 'rpg',
|
|
36
|
+
features: ['quest-progression', 'flag-setting']
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'complex-conditional',
|
|
40
|
+
title: 'Complex Conditional Example',
|
|
41
|
+
description: 'Advanced conditional logic with multiple branches',
|
|
42
|
+
filename: 'complex-conditional.yarn',
|
|
43
|
+
flagSchemaId: 'complex_conditional',
|
|
44
|
+
features: ['conditional-nodes', 'multiple-branches', 'complex-conditions']
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'variable-operations',
|
|
48
|
+
title: 'Variable Operations Example',
|
|
49
|
+
description: 'Demonstrates variable operations, interpolation, and numeric calculations',
|
|
50
|
+
filename: 'variable-operations-example.yarn',
|
|
51
|
+
flagSchemaId: 'rpg',
|
|
52
|
+
features: ['variable-operations', 'variable-interpolation', 'numeric-calculations', 'string-variables']
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
/**
|
|
56
|
+
* Flag schemas for examples
|
|
57
|
+
*/
|
|
58
|
+
exports.exampleFlagSchemas = {
|
|
59
|
+
basic: {
|
|
60
|
+
categories: ['quests', 'items', 'stats'],
|
|
61
|
+
flags: [
|
|
62
|
+
{ id: 'quest_intro', name: 'Introduction Quest', type: constants_1.FLAG_TYPE.QUEST, category: 'quests', valueType: constants_1.FLAG_VALUE_TYPE.STRING },
|
|
63
|
+
{ id: 'item_key', name: 'Key', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
64
|
+
{ id: 'stat_reputation', name: 'Reputation', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 0 },
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
conditional: {
|
|
68
|
+
categories: ['quests', 'items', 'stats'],
|
|
69
|
+
flags: [
|
|
70
|
+
{ id: 'quest_main', name: 'Main Quest', type: constants_1.FLAG_TYPE.QUEST, category: 'quests', valueType: constants_1.FLAG_VALUE_TYPE.STRING },
|
|
71
|
+
{ id: 'item_key', name: 'Key', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
72
|
+
{ id: 'stat_gold', name: 'Gold', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 0 },
|
|
73
|
+
{ id: 'stat_reputation', name: 'Reputation', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 0 },
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
rpg: {
|
|
77
|
+
categories: ['quests', 'achievements', 'items', 'stats', 'titles'],
|
|
78
|
+
flags: [
|
|
79
|
+
{ id: 'quest_dragon_slayer', name: 'Dragon Slayer Quest', type: constants_1.FLAG_TYPE.QUEST, category: 'quests', valueType: constants_1.FLAG_VALUE_TYPE.STRING },
|
|
80
|
+
{ id: 'quest_dragon_slayer_complete', name: 'Dragon Slayer Complete', type: constants_1.FLAG_TYPE.QUEST, category: 'quests' },
|
|
81
|
+
{ id: 'quest_find_key', name: 'Find the Key', type: constants_1.FLAG_TYPE.QUEST, category: 'quests', valueType: constants_1.FLAG_VALUE_TYPE.STRING },
|
|
82
|
+
{ id: 'achievement_first_quest', name: 'First Quest', type: constants_1.FLAG_TYPE.ACHIEVEMENT, category: 'achievements' },
|
|
83
|
+
{ id: 'achievement_dragon_slayer', name: 'Dragon Slayer', type: constants_1.FLAG_TYPE.ACHIEVEMENT, category: 'achievements' },
|
|
84
|
+
{ id: 'achievement_hero', name: 'Hero', type: constants_1.FLAG_TYPE.ACHIEVEMENT, category: 'achievements' },
|
|
85
|
+
{ id: 'item_ancient_key', name: 'Ancient Key', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
86
|
+
{ id: 'item_map', name: 'Treasure Map', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
87
|
+
{ id: 'item_sword', name: 'Legendary Sword', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
88
|
+
{ id: 'item_potion', name: 'Health Potion', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
89
|
+
{ id: 'stat_gold', name: 'Gold', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 0 },
|
|
90
|
+
{ id: 'stat_reputation', name: 'Reputation', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 0 },
|
|
91
|
+
{ id: 'stat_charisma', name: 'Charisma', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 10 },
|
|
92
|
+
{ id: 'stat_strength', name: 'Strength', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 10 },
|
|
93
|
+
{ id: 'stat_experience', name: 'Experience', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 0 },
|
|
94
|
+
{ id: 'title_hero', name: 'Hero', type: constants_1.FLAG_TYPE.TITLE, category: 'titles' },
|
|
95
|
+
{ id: 'title_merchant', name: 'Merchant', type: constants_1.FLAG_TYPE.TITLE, category: 'titles' },
|
|
96
|
+
{ id: 'player_name', name: 'Player Name', type: constants_1.FLAG_TYPE.GLOBAL, category: 'global', valueType: constants_1.FLAG_VALUE_TYPE.STRING, defaultValue: 'Traveler' },
|
|
97
|
+
{ id: 'location_name', name: 'Location Name', type: constants_1.FLAG_TYPE.GLOBAL, category: 'global', valueType: constants_1.FLAG_VALUE_TYPE.STRING, defaultValue: 'Town' },
|
|
98
|
+
{ id: 'player_title', name: 'Player Title', type: constants_1.FLAG_TYPE.TITLE, category: 'titles', valueType: constants_1.FLAG_VALUE_TYPE.STRING },
|
|
99
|
+
{ id: 'greeting_count', name: 'Greeting Count', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 0 },
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
complex_conditional: {
|
|
103
|
+
categories: ['quests', 'achievements', 'items', 'stats', 'titles', 'global', 'dialogue'],
|
|
104
|
+
flags: [
|
|
105
|
+
{ id: 'quest_ancient_ruins', name: 'Ancient Ruins Quest', type: constants_1.FLAG_TYPE.QUEST, category: 'quests', valueType: constants_1.FLAG_VALUE_TYPE.STRING },
|
|
106
|
+
{ id: 'quest_ancient_ruins_complete', name: 'Ancient Ruins Complete', type: constants_1.FLAG_TYPE.QUEST, category: 'quests' },
|
|
107
|
+
{ id: 'quest_treasure_hunt', name: 'Treasure Hunt', type: constants_1.FLAG_TYPE.QUEST, category: 'quests', valueType: constants_1.FLAG_VALUE_TYPE.STRING },
|
|
108
|
+
{ id: 'quest_treasure_hunt_complete', name: 'Treasure Hunt Complete', type: constants_1.FLAG_TYPE.QUEST, category: 'quests' },
|
|
109
|
+
{ id: 'quest_dragon_slayer', name: 'Dragon Slayer Quest', type: constants_1.FLAG_TYPE.QUEST, category: 'quests', valueType: constants_1.FLAG_VALUE_TYPE.STRING },
|
|
110
|
+
{ id: 'achievement_explorer', name: 'Explorer', type: constants_1.FLAG_TYPE.ACHIEVEMENT, category: 'achievements' },
|
|
111
|
+
{ id: 'achievement_rich', name: 'Rich', type: constants_1.FLAG_TYPE.ACHIEVEMENT, category: 'achievements' },
|
|
112
|
+
{ id: 'achievement_hero', name: 'Hero', type: constants_1.FLAG_TYPE.ACHIEVEMENT, category: 'achievements' },
|
|
113
|
+
{ id: 'achievement_diplomat', name: 'Diplomat', type: constants_1.FLAG_TYPE.ACHIEVEMENT, category: 'achievements' },
|
|
114
|
+
{ id: 'item_ancient_key', name: 'Ancient Key', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
115
|
+
{ id: 'item_treasure_map', name: 'Treasure Map', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
116
|
+
{ id: 'item_legendary_sword', name: 'Legendary Sword', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
117
|
+
{ id: 'item_gold_coin', name: 'Gold Coin', type: constants_1.FLAG_TYPE.ITEM, category: 'items' },
|
|
118
|
+
{ id: 'stat_gold', name: 'Gold', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 0 },
|
|
119
|
+
{ id: 'stat_reputation', name: 'Reputation', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 0 },
|
|
120
|
+
{ id: 'stat_charisma', name: 'Charisma', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 10 },
|
|
121
|
+
{ id: 'stat_strength', name: 'Strength', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 10 },
|
|
122
|
+
{ id: 'stat_wisdom', name: 'Wisdom', type: constants_1.FLAG_TYPE.STAT, category: 'stats', valueType: constants_1.FLAG_VALUE_TYPE.NUMBER, defaultValue: 10 },
|
|
123
|
+
{ id: 'title_hero', name: 'Hero', type: constants_1.FLAG_TYPE.TITLE, category: 'titles' },
|
|
124
|
+
{ id: 'title_explorer', name: 'Explorer', type: constants_1.FLAG_TYPE.TITLE, category: 'titles' },
|
|
125
|
+
{ id: 'title_merchant', name: 'Merchant', type: constants_1.FLAG_TYPE.TITLE, category: 'titles' },
|
|
126
|
+
{ id: 'global_game_started', name: 'Game Started', type: constants_1.FLAG_TYPE.GLOBAL, category: 'global' },
|
|
127
|
+
{ id: 'global_first_visit', name: 'First Visit', type: constants_1.FLAG_TYPE.GLOBAL, category: 'global' },
|
|
128
|
+
{ id: 'global_difficulty', name: 'Difficulty', type: constants_1.FLAG_TYPE.GLOBAL, category: 'global', valueType: constants_1.FLAG_VALUE_TYPE.STRING },
|
|
129
|
+
{ id: 'dialogue_met_guard', name: 'Met Guard', type: constants_1.FLAG_TYPE.DIALOGUE, category: 'dialogue' },
|
|
130
|
+
{ id: 'dialogue_hostile', name: 'Hostile Response', type: constants_1.FLAG_TYPE.DIALOGUE, category: 'dialogue' },
|
|
131
|
+
{ id: 'dialogue_friendly', name: 'Friendly Response', type: constants_1.FLAG_TYPE.DIALOGUE, category: 'dialogue' },
|
|
132
|
+
{ id: 'dialogue_seeks_knowledge', name: 'Seeks Knowledge', type: constants_1.FLAG_TYPE.DIALOGUE, category: 'dialogue' },
|
|
133
|
+
{ id: 'dialogue_offered_bribe', name: 'Offered Bribe', type: constants_1.FLAG_TYPE.DIALOGUE, category: 'dialogue' },
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Get example metadata by ID
|
|
139
|
+
*/
|
|
140
|
+
function getExampleMetadata(id) {
|
|
141
|
+
return exports.examplesRegistry.find(ex => ex.id === id) || null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* List all available example IDs
|
|
145
|
+
*/
|
|
146
|
+
function listExampleIds() {
|
|
147
|
+
return exports.examplesRegistry.map(ex => ex.id);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get flag schema by ID
|
|
151
|
+
*/
|
|
152
|
+
function getExampleFlagSchema(id) {
|
|
153
|
+
return exports.exampleFlagSchemas[id] || null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* List all available flag schema IDs
|
|
157
|
+
*/
|
|
158
|
+
function listFlagSchemaIds() {
|
|
159
|
+
return Object.keys(exports.exampleFlagSchemas);
|
|
160
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Examples System
|
|
3
|
+
*
|
|
4
|
+
* All examples are stored as Yarn files and loaded through the registry system.
|
|
5
|
+
* This provides a single, organized way to discover and load examples.
|
|
6
|
+
*
|
|
7
|
+
* Structure:
|
|
8
|
+
* - examples-registry.ts: Metadata about all examples (titles, descriptions, features)
|
|
9
|
+
* - yarn-examples.ts: Actual Yarn file contents (all examples as Yarn strings)
|
|
10
|
+
* - legacy-examples.ts: Old TypeScript examples (being migrated to Yarn format)
|
|
11
|
+
* - index.ts: Public API for loading examples (this file)
|
|
12
|
+
*/
|
|
13
|
+
export { examplesRegistry, exampleFlagSchemas, getExampleMetadata, listExampleIds, getExampleFlagSchema, listFlagSchemaIds, type ExampleMetadata } from './examples-registry';
|
|
14
|
+
/**
|
|
15
|
+
* Legacy exports for backward compatibility
|
|
16
|
+
* These maintain the old API while we migrate examples to Yarn format
|
|
17
|
+
* TODO: Remove once all examples are migrated and code is updated
|
|
18
|
+
*/
|
|
19
|
+
import { DialogueTree } from '../types';
|
|
20
|
+
import { FlagSchema } from '../types/flags';
|
|
21
|
+
export declare const exampleDialogues: Record<string, DialogueTree>;
|
|
22
|
+
export declare const demoFlagSchemas: Record<string, FlagSchema>;
|
|
23
|
+
export declare function listExamples(): string[];
|
|
24
|
+
export declare function listDemoFlagSchemas(): string[];
|
|
25
|
+
export declare function getExampleDialogue(name: string): DialogueTree | null;
|
|
26
|
+
export declare function getDemoFlagSchema(name: string): FlagSchema | null;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Unified Examples System
|
|
4
|
+
*
|
|
5
|
+
* All examples are stored as Yarn files and loaded through the registry system.
|
|
6
|
+
* This provides a single, organized way to discover and load examples.
|
|
7
|
+
*
|
|
8
|
+
* Structure:
|
|
9
|
+
* - examples-registry.ts: Metadata about all examples (titles, descriptions, features)
|
|
10
|
+
* - yarn-examples.ts: Actual Yarn file contents (all examples as Yarn strings)
|
|
11
|
+
* - legacy-examples.ts: Old TypeScript examples (being migrated to Yarn format)
|
|
12
|
+
* - index.ts: Public API for loading examples (this file)
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.demoFlagSchemas = exports.exampleDialogues = exports.listFlagSchemaIds = exports.getExampleFlagSchema = exports.listExampleIds = exports.getExampleMetadata = exports.exampleFlagSchemas = exports.examplesRegistry = void 0;
|
|
16
|
+
exports.listExamples = listExamples;
|
|
17
|
+
exports.listDemoFlagSchemas = listDemoFlagSchemas;
|
|
18
|
+
exports.getExampleDialogue = getExampleDialogue;
|
|
19
|
+
exports.getDemoFlagSchema = getDemoFlagSchema;
|
|
20
|
+
// New unified system exports
|
|
21
|
+
var examples_registry_1 = require("./examples-registry");
|
|
22
|
+
Object.defineProperty(exports, "examplesRegistry", { enumerable: true, get: function () { return examples_registry_1.examplesRegistry; } });
|
|
23
|
+
Object.defineProperty(exports, "exampleFlagSchemas", { enumerable: true, get: function () { return examples_registry_1.exampleFlagSchemas; } });
|
|
24
|
+
Object.defineProperty(exports, "getExampleMetadata", { enumerable: true, get: function () { return examples_registry_1.getExampleMetadata; } });
|
|
25
|
+
Object.defineProperty(exports, "listExampleIds", { enumerable: true, get: function () { return examples_registry_1.listExampleIds; } });
|
|
26
|
+
Object.defineProperty(exports, "getExampleFlagSchema", { enumerable: true, get: function () { return examples_registry_1.getExampleFlagSchema; } });
|
|
27
|
+
Object.defineProperty(exports, "listFlagSchemaIds", { enumerable: true, get: function () { return examples_registry_1.listFlagSchemaIds; } });
|
|
28
|
+
const yarn_examples_1 = require("./yarn-examples");
|
|
29
|
+
const examples_registry_2 = require("./examples-registry");
|
|
30
|
+
const legacy_examples_1 = require("./legacy-examples");
|
|
31
|
+
// Export legacy examples - these work alongside the new Yarn examples
|
|
32
|
+
exports.exampleDialogues = legacy_examples_1.exampleDialogues;
|
|
33
|
+
exports.demoFlagSchemas = legacy_examples_1.demoFlagSchemas;
|
|
34
|
+
function listExamples() {
|
|
35
|
+
// Combine both Yarn examples and legacy examples
|
|
36
|
+
const yarnIds = (0, examples_registry_2.listExampleIds)();
|
|
37
|
+
const legacyIds = Object.keys(legacy_examples_1.exampleDialogues);
|
|
38
|
+
return [...new Set([...yarnIds, ...legacyIds])];
|
|
39
|
+
}
|
|
40
|
+
function listDemoFlagSchemas() {
|
|
41
|
+
// Combine both systems
|
|
42
|
+
const yarnIds = (0, examples_registry_2.listFlagSchemaIds)();
|
|
43
|
+
const legacyIds = Object.keys(legacy_examples_1.demoFlagSchemas);
|
|
44
|
+
return [...new Set([...yarnIds, ...legacyIds])];
|
|
45
|
+
}
|
|
46
|
+
function getExampleDialogue(name) {
|
|
47
|
+
// Try new Yarn system first
|
|
48
|
+
const yarnDialogue = (0, yarn_examples_1.getExampleDialogue)(name);
|
|
49
|
+
if (yarnDialogue) {
|
|
50
|
+
return yarnDialogue;
|
|
51
|
+
}
|
|
52
|
+
// Fallback to legacy TypeScript examples
|
|
53
|
+
return legacy_examples_1.exampleDialogues[name] || null;
|
|
54
|
+
}
|
|
55
|
+
function getDemoFlagSchema(name) {
|
|
56
|
+
// Try new system first
|
|
57
|
+
const schema = (0, examples_registry_2.getExampleFlagSchema)(name);
|
|
58
|
+
if (schema) {
|
|
59
|
+
return schema;
|
|
60
|
+
}
|
|
61
|
+
// Fallback to legacy
|
|
62
|
+
return legacy_examples_1.demoFlagSchemas[name] || null;
|
|
63
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DialogueTree } from '../types';
|
|
2
|
+
import { FlagSchema } from '../types/flags';
|
|
3
|
+
/**
|
|
4
|
+
* Legacy TypeScript examples
|
|
5
|
+
* These are kept for backward compatibility while we migrate to Yarn format
|
|
6
|
+
* TODO: Convert these to Yarn format and remove this file
|
|
7
|
+
*/
|
|
8
|
+
export declare const demoFlagSchemas: Record<string, FlagSchema>;
|
|
9
|
+
export declare const exampleDialogues: Record<string, DialogueTree>;
|