@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.
Files changed (241) hide show
  1. package/README.md +233 -0
  2. package/bin/dialogue-forge.js +78 -0
  3. package/demo/app/layout.tsx +36 -0
  4. package/demo/app/page.tsx +440 -0
  5. package/demo/components/ThemeSwitcher.tsx +611 -0
  6. package/demo/next.config.mjs +7 -0
  7. package/demo/package.json +29 -0
  8. package/demo/postcss.config.mjs +7 -0
  9. package/demo/public/logo.svg +1 -0
  10. package/demo/styles/globals.css +19 -0
  11. package/demo/tailwind.config.ts +90 -0
  12. package/demo/tsconfig.json +42 -0
  13. package/dist/components/ChoiceEdgeV2.d.ts +3 -0
  14. package/dist/components/ChoiceEdgeV2.js +103 -0
  15. package/dist/components/CodeBlock.d.ts +8 -0
  16. package/dist/components/CodeBlock.js +24 -0
  17. package/dist/components/ConditionAutocomplete.d.ts +14 -0
  18. package/dist/components/ConditionAutocomplete.js +284 -0
  19. package/dist/components/ConditionalNodeV2.d.ts +16 -0
  20. package/dist/components/ConditionalNodeV2.js +147 -0
  21. package/dist/components/DialogueEditorV2.d.ts +22 -0
  22. package/dist/components/DialogueEditorV2.js +1170 -0
  23. package/dist/components/EdgeIcon.d.ts +8 -0
  24. package/dist/components/EdgeIcon.js +13 -0
  25. package/dist/components/ExampleLoader.d.ts +11 -0
  26. package/dist/components/ExampleLoader.js +52 -0
  27. package/dist/components/ExampleLoaderButton.d.ts +15 -0
  28. package/dist/components/ExampleLoaderButton.js +102 -0
  29. package/dist/components/FlagManager.d.ts +11 -0
  30. package/dist/components/FlagManager.js +282 -0
  31. package/dist/components/FlagSelector.d.ts +11 -0
  32. package/dist/components/FlagSelector.js +235 -0
  33. package/dist/components/GuidePanel.d.ts +7 -0
  34. package/dist/components/GuidePanel.js +1176 -0
  35. package/dist/components/Minimap.d.ts +16 -0
  36. package/dist/components/Minimap.js +93 -0
  37. package/dist/components/NPCEdgeV2.d.ts +3 -0
  38. package/dist/components/NPCEdgeV2.js +104 -0
  39. package/dist/components/NPCNodeV2.d.ts +26 -0
  40. package/dist/components/NPCNodeV2.js +86 -0
  41. package/dist/components/NodeEditor.d.ts +18 -0
  42. package/dist/components/NodeEditor.js +1025 -0
  43. package/dist/components/PlayView.d.ts +12 -0
  44. package/dist/components/PlayView.js +307 -0
  45. package/dist/components/PlayerNodeV2.d.ts +16 -0
  46. package/dist/components/PlayerNodeV2.js +139 -0
  47. package/dist/components/ReactFlowPOC.d.ts +61 -0
  48. package/dist/components/ReactFlowPOC.js +312 -0
  49. package/dist/components/ScenePlayer.d.ts +18 -0
  50. package/dist/components/ScenePlayer.js +196 -0
  51. package/dist/components/YarnView.d.ts +9 -0
  52. package/dist/components/YarnView.js +45 -0
  53. package/dist/components/ZoomControls.d.ts +11 -0
  54. package/dist/components/ZoomControls.js +34 -0
  55. package/dist/esm/components/ChoiceEdgeV2.d.ts +3 -0
  56. package/dist/esm/components/ChoiceEdgeV2.js +67 -0
  57. package/dist/esm/components/CodeBlock.d.ts +8 -0
  58. package/dist/esm/components/CodeBlock.js +18 -0
  59. package/dist/esm/components/ConditionAutocomplete.d.ts +14 -0
  60. package/dist/esm/components/ConditionAutocomplete.js +248 -0
  61. package/dist/esm/components/ConditionalNodeV2.d.ts +16 -0
  62. package/dist/esm/components/ConditionalNodeV2.js +111 -0
  63. package/dist/esm/components/DialogueEditorV2.d.ts +22 -0
  64. package/dist/esm/components/DialogueEditorV2.js +1134 -0
  65. package/dist/esm/components/EdgeIcon.d.ts +8 -0
  66. package/dist/esm/components/EdgeIcon.js +7 -0
  67. package/dist/esm/components/ExampleLoader.d.ts +11 -0
  68. package/dist/esm/components/ExampleLoader.js +46 -0
  69. package/dist/esm/components/ExampleLoaderButton.d.ts +15 -0
  70. package/dist/esm/components/ExampleLoaderButton.js +66 -0
  71. package/dist/esm/components/FlagManager.d.ts +11 -0
  72. package/dist/esm/components/FlagManager.js +246 -0
  73. package/dist/esm/components/FlagSelector.d.ts +11 -0
  74. package/dist/esm/components/FlagSelector.js +199 -0
  75. package/dist/esm/components/GuidePanel.d.ts +7 -0
  76. package/dist/esm/components/GuidePanel.js +1140 -0
  77. package/dist/esm/components/Minimap.d.ts +16 -0
  78. package/dist/esm/components/Minimap.js +57 -0
  79. package/dist/esm/components/NPCEdgeV2.d.ts +3 -0
  80. package/dist/esm/components/NPCEdgeV2.js +68 -0
  81. package/dist/esm/components/NPCNodeV2.d.ts +26 -0
  82. package/dist/esm/components/NPCNodeV2.js +80 -0
  83. package/dist/esm/components/NodeEditor.d.ts +18 -0
  84. package/dist/esm/components/NodeEditor.js +989 -0
  85. package/dist/esm/components/PlayView.d.ts +12 -0
  86. package/dist/esm/components/PlayView.js +271 -0
  87. package/dist/esm/components/PlayerNodeV2.d.ts +16 -0
  88. package/dist/esm/components/PlayerNodeV2.js +103 -0
  89. package/dist/esm/components/ReactFlowPOC.d.ts +61 -0
  90. package/dist/esm/components/ReactFlowPOC.js +275 -0
  91. package/dist/esm/components/ScenePlayer.d.ts +18 -0
  92. package/dist/esm/components/ScenePlayer.js +160 -0
  93. package/dist/esm/components/YarnView.d.ts +9 -0
  94. package/dist/esm/components/YarnView.js +39 -0
  95. package/dist/esm/components/ZoomControls.d.ts +11 -0
  96. package/dist/esm/components/ZoomControls.js +28 -0
  97. package/dist/esm/examples/example-loader.d.ts +29 -0
  98. package/dist/esm/examples/example-loader.js +103 -0
  99. package/dist/esm/examples/examples-registry.d.ts +38 -0
  100. package/dist/esm/examples/examples-registry.js +153 -0
  101. package/dist/esm/examples/index.d.ts +26 -0
  102. package/dist/esm/examples/index.js +50 -0
  103. package/dist/esm/examples/legacy-examples.d.ts +9 -0
  104. package/dist/esm/examples/legacy-examples.js +814 -0
  105. package/dist/esm/examples/yarn-examples.d.ts +35 -0
  106. package/dist/esm/examples/yarn-examples.js +181 -0
  107. package/dist/esm/index.d.ts +21 -0
  108. package/dist/esm/index.js +26 -0
  109. package/dist/esm/lib/flag-manager.d.ts +21 -0
  110. package/dist/esm/lib/flag-manager.js +93 -0
  111. package/dist/esm/lib/yarn-converter/__tests__/round-trip.test.d.ts +1 -0
  112. package/dist/esm/lib/yarn-converter/__tests__/round-trip.test.js +169 -0
  113. package/dist/esm/lib/yarn-converter.d.ts +17 -0
  114. package/dist/esm/lib/yarn-converter.js +521 -0
  115. package/dist/esm/lib/yarn-runner/__tests__/condition-evaluator.test.d.ts +1 -0
  116. package/dist/esm/lib/yarn-runner/__tests__/condition-evaluator.test.js +171 -0
  117. package/dist/esm/lib/yarn-runner/__tests__/node-processor.test.d.ts +1 -0
  118. package/dist/esm/lib/yarn-runner/__tests__/node-processor.test.js +237 -0
  119. package/dist/esm/lib/yarn-runner/__tests__/variable-manager.test.d.ts +1 -0
  120. package/dist/esm/lib/yarn-runner/__tests__/variable-manager.test.js +106 -0
  121. package/dist/esm/lib/yarn-runner/condition-evaluator.d.ts +12 -0
  122. package/dist/esm/lib/yarn-runner/condition-evaluator.js +56 -0
  123. package/dist/esm/lib/yarn-runner/index.d.ts +12 -0
  124. package/dist/esm/lib/yarn-runner/index.js +11 -0
  125. package/dist/esm/lib/yarn-runner/node-processor.d.ts +18 -0
  126. package/dist/esm/lib/yarn-runner/node-processor.js +129 -0
  127. package/dist/esm/lib/yarn-runner/variable-manager.d.ts +51 -0
  128. package/dist/esm/lib/yarn-runner/variable-manager.js +120 -0
  129. package/dist/esm/lib/yarn-runner/variable-operations.d.ts +16 -0
  130. package/dist/esm/lib/yarn-runner/variable-operations.js +88 -0
  131. package/dist/esm/types/conditionals.d.ts +29 -0
  132. package/dist/esm/types/conditionals.js +1 -0
  133. package/dist/esm/types/constants.d.ts +59 -0
  134. package/dist/esm/types/constants.js +55 -0
  135. package/dist/esm/types/flags.d.ts +49 -0
  136. package/dist/esm/types/flags.js +49 -0
  137. package/dist/esm/types/game-state.d.ts +62 -0
  138. package/dist/esm/types/game-state.js +6 -0
  139. package/dist/esm/types/index.d.ts +77 -0
  140. package/dist/esm/types/index.js +1 -0
  141. package/dist/esm/utils/constants.d.ts +5 -0
  142. package/dist/esm/utils/constants.js +5 -0
  143. package/dist/esm/utils/feature-flags.d.ts +11 -0
  144. package/dist/esm/utils/feature-flags.js +11 -0
  145. package/dist/esm/utils/game-state-flattener.d.ts +41 -0
  146. package/dist/esm/utils/game-state-flattener.js +135 -0
  147. package/dist/esm/utils/layout/collision.d.ts +27 -0
  148. package/dist/esm/utils/layout/collision.js +74 -0
  149. package/dist/esm/utils/layout/index.d.ts +82 -0
  150. package/dist/esm/utils/layout/index.js +98 -0
  151. package/dist/esm/utils/layout/registry.d.ts +91 -0
  152. package/dist/esm/utils/layout/registry.js +148 -0
  153. package/dist/esm/utils/layout/strategies/dagre.d.ts +19 -0
  154. package/dist/esm/utils/layout/strategies/dagre.js +182 -0
  155. package/dist/esm/utils/layout/strategies/force.d.ts +21 -0
  156. package/dist/esm/utils/layout/strategies/force.js +178 -0
  157. package/dist/esm/utils/layout/strategies/grid.d.ts +17 -0
  158. package/dist/esm/utils/layout/strategies/grid.js +91 -0
  159. package/dist/esm/utils/layout/strategies/index.d.ts +8 -0
  160. package/dist/esm/utils/layout/strategies/index.js +8 -0
  161. package/dist/esm/utils/layout/types.d.ts +100 -0
  162. package/dist/esm/utils/layout/types.js +7 -0
  163. package/dist/esm/utils/layout.d.ts +9 -0
  164. package/dist/esm/utils/layout.js +17 -0
  165. package/dist/esm/utils/node-helpers.d.ts +7 -0
  166. package/dist/esm/utils/node-helpers.js +94 -0
  167. package/dist/esm/utils/reactflow-converter.d.ts +42 -0
  168. package/dist/esm/utils/reactflow-converter.js +217 -0
  169. package/dist/examples/example-loader.d.ts +29 -0
  170. package/dist/examples/example-loader.js +109 -0
  171. package/dist/examples/examples-registry.d.ts +38 -0
  172. package/dist/examples/examples-registry.js +160 -0
  173. package/dist/examples/index.d.ts +26 -0
  174. package/dist/examples/index.js +63 -0
  175. package/dist/examples/legacy-examples.d.ts +9 -0
  176. package/dist/examples/legacy-examples.js +817 -0
  177. package/dist/examples/yarn-examples.d.ts +35 -0
  178. package/dist/examples/yarn-examples.js +189 -0
  179. package/dist/index.d.ts +21 -0
  180. package/dist/index.js +66 -0
  181. package/dist/lib/flag-manager.d.ts +21 -0
  182. package/dist/lib/flag-manager.js +99 -0
  183. package/dist/lib/yarn-converter/__tests__/round-trip.test.d.ts +1 -0
  184. package/dist/lib/yarn-converter/__tests__/round-trip.test.js +171 -0
  185. package/dist/lib/yarn-converter.d.ts +17 -0
  186. package/dist/lib/yarn-converter.js +525 -0
  187. package/dist/lib/yarn-runner/__tests__/condition-evaluator.test.d.ts +1 -0
  188. package/dist/lib/yarn-runner/__tests__/condition-evaluator.test.js +173 -0
  189. package/dist/lib/yarn-runner/__tests__/node-processor.test.d.ts +1 -0
  190. package/dist/lib/yarn-runner/__tests__/node-processor.test.js +239 -0
  191. package/dist/lib/yarn-runner/__tests__/variable-manager.test.d.ts +1 -0
  192. package/dist/lib/yarn-runner/__tests__/variable-manager.test.js +108 -0
  193. package/dist/lib/yarn-runner/condition-evaluator.d.ts +12 -0
  194. package/dist/lib/yarn-runner/condition-evaluator.js +60 -0
  195. package/dist/lib/yarn-runner/index.d.ts +12 -0
  196. package/dist/lib/yarn-runner/index.js +21 -0
  197. package/dist/lib/yarn-runner/node-processor.d.ts +18 -0
  198. package/dist/lib/yarn-runner/node-processor.js +133 -0
  199. package/dist/lib/yarn-runner/variable-manager.d.ts +51 -0
  200. package/dist/lib/yarn-runner/variable-manager.js +124 -0
  201. package/dist/lib/yarn-runner/variable-operations.d.ts +16 -0
  202. package/dist/lib/yarn-runner/variable-operations.js +92 -0
  203. package/dist/types/conditionals.d.ts +29 -0
  204. package/dist/types/conditionals.js +2 -0
  205. package/dist/types/constants.d.ts +59 -0
  206. package/dist/types/constants.js +58 -0
  207. package/dist/types/flags.d.ts +49 -0
  208. package/dist/types/flags.js +52 -0
  209. package/dist/types/game-state.d.ts +62 -0
  210. package/dist/types/game-state.js +7 -0
  211. package/dist/types/index.d.ts +77 -0
  212. package/dist/types/index.js +2 -0
  213. package/dist/utils/constants.d.ts +5 -0
  214. package/dist/utils/constants.js +8 -0
  215. package/dist/utils/feature-flags.d.ts +11 -0
  216. package/dist/utils/feature-flags.js +14 -0
  217. package/dist/utils/game-state-flattener.d.ts +41 -0
  218. package/dist/utils/game-state-flattener.js +140 -0
  219. package/dist/utils/layout/collision.d.ts +27 -0
  220. package/dist/utils/layout/collision.js +77 -0
  221. package/dist/utils/layout/index.d.ts +82 -0
  222. package/dist/utils/layout/index.js +109 -0
  223. package/dist/utils/layout/registry.d.ts +91 -0
  224. package/dist/utils/layout/registry.js +151 -0
  225. package/dist/utils/layout/strategies/dagre.d.ts +19 -0
  226. package/dist/utils/layout/strategies/dagre.js +189 -0
  227. package/dist/utils/layout/strategies/force.d.ts +21 -0
  228. package/dist/utils/layout/strategies/force.js +182 -0
  229. package/dist/utils/layout/strategies/grid.d.ts +17 -0
  230. package/dist/utils/layout/strategies/grid.js +95 -0
  231. package/dist/utils/layout/strategies/index.d.ts +8 -0
  232. package/dist/utils/layout/strategies/index.js +14 -0
  233. package/dist/utils/layout/types.d.ts +100 -0
  234. package/dist/utils/layout/types.js +8 -0
  235. package/dist/utils/layout.d.ts +9 -0
  236. package/dist/utils/layout.js +25 -0
  237. package/dist/utils/node-helpers.d.ts +7 -0
  238. package/dist/utils/node-helpers.js +101 -0
  239. package/dist/utils/reactflow-converter.d.ts +42 -0
  240. package/dist/utils/reactflow-converter.js +223 -0
  241. 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>;