@peter.naydenov/morph 3.1.5 → 3.3.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 (44) hide show
  1. package/.mocharc.json +1 -0
  2. package/.opencode/command/speckit.analyze.md +184 -0
  3. package/.opencode/command/speckit.checklist.md +294 -0
  4. package/.opencode/command/speckit.clarify.md +181 -0
  5. package/.opencode/command/speckit.constitution.md +82 -0
  6. package/.opencode/command/speckit.implement.md +135 -0
  7. package/.opencode/command/speckit.plan.md +89 -0
  8. package/.opencode/command/speckit.specify.md +257 -0
  9. package/.opencode/command/speckit.tasks.md +137 -0
  10. package/.opencode/command/speckit.taskstoissues.md +28 -0
  11. package/.specify/memory/constitution.md +43 -0
  12. package/.specify/scripts/bash/check-prerequisites.sh +166 -0
  13. package/.specify/scripts/bash/common.sh +156 -0
  14. package/.specify/scripts/bash/create-new-feature.sh +305 -0
  15. package/.specify/scripts/bash/setup-plan.sh +61 -0
  16. package/.specify/scripts/bash/update-agent-context.sh +790 -0
  17. package/.specify/templates/agent-file-template.md +28 -0
  18. package/.specify/templates/checklist-template.md +40 -0
  19. package/.specify/templates/plan-template.md +104 -0
  20. package/.specify/templates/spec-template.md +115 -0
  21. package/.specify/templates/tasks-template.md +251 -0
  22. package/Changelog.md +17 -0
  23. package/README.md +184 -13
  24. package/dist/methods/build.d.ts +28 -2
  25. package/dist/methods/render.d.ts +9 -20
  26. package/dist/morph.cjs +1 -1
  27. package/dist/morph.esm.mjs +1 -1
  28. package/dist/morph.umd.js +1 -1
  29. package/morph.png +0 -0
  30. package/package.json +3 -2
  31. package/simple.js +17 -0
  32. package/specs/001-extend-templates/checklists/requirements.md +35 -0
  33. package/specs/001-extend-templates/contracts/set-method.json +39 -0
  34. package/specs/001-extend-templates/data-model.md +76 -0
  35. package/specs/001-extend-templates/plan.md +90 -0
  36. package/specs/001-extend-templates/quickstart.md +56 -0
  37. package/specs/001-extend-templates/research.md +18 -0
  38. package/specs/001-extend-templates/spec.md +139 -0
  39. package/specs/001-extend-templates/tasks.md +255 -0
  40. package/src/methods/_readTemplate.js +22 -46
  41. package/src/methods/_renderHolder.js +13 -7
  42. package/src/methods/_setupActions.js +1 -8
  43. package/src/methods/build.js +458 -321
  44. package/src/methods/render.js +23 -46
@@ -1,57 +1,34 @@
1
- import _renderHolder from "./_renderHolder.js"
1
+
2
+ import _renderHolder from './_renderHolder.js'
2
3
 
3
4
 
4
5
 
5
6
  /**
6
- * Executes rendering and returns the rendered result.
7
- *
8
- * Handles both function-based and template-based rendering. Normalizes data objects
9
- * by converting nested objects to their 'text' properties and arrays to their first elements.
10
- *
11
- * @param {object|string} theData - Data to be rendered. If string, becomes the 'text' property value.
12
- * @param {string} name - Name of the render helper/template to execute
13
- * @param {object} helpers - Object containing helper functions and templates
14
- * @param {object} original - Original data context for full data access
15
- * @param {object} dependencies - External dependencies available to helpers
16
- * @param {...any} args - Additional arguments passed to the render function
17
- *
18
- * @returns {string} Rendered string result
19
- *
20
- * @example
21
- * // Render with function helper
22
- * const result = render(data, 'myHelper', helpers, originalData, deps);
7
+ * Renders a helper or template with the provided data and context.
8
+ *
9
+ * @param {any} theData - The data to process.
10
+ * @param {string} name - The name of the helper or template to render.
11
+ * @param {object} helpers - Dictionary of available helpers.
12
+ * @param {any} original - The full original data context.
13
+ * @param {object} dependencies - injected dependencies.
14
+ * @param {...any} args - Additional arguments.
23
15
  *
24
- * @example
25
- * // Render with template
26
- * const result = render(data, 'myTemplate', helpers, originalData, deps);
16
+ * @returns {any} The result of the rendering process.
27
17
  */
28
- function render ( theData, name, helpers, original, dependencies, ...args ) {
29
- // *** Executes rendering and return the results
30
- if ( theData instanceof Object ) { // Make sure all properties are not objects
31
- Object.entries ( theData ).forEach ( ([key, value]) => {
32
- if ( value instanceof Object ) theData[key] = value['text']
33
- if ( value instanceof Array ) theData[key] = value[0]
34
- })
35
- }
36
- /**
37
- * Normalizes render data by wrapping strings in text objects.
38
- *
39
- * @param {any} d - Data to normalize
40
- * @returns {object} Returns { text: d } if d is string, otherwise returns d unchanged
41
- */
42
- function setRenderData ( d={} ) {
43
- if ( typeof d === 'string' ) return { text: d }
44
- else return d
45
- } // setRenderData func.
46
- const isRenderFunction = typeof helpers[name] === 'function'; // Render could be a function or template.
47
- theData = setRenderData ( theData )
48
-
49
- if ( isRenderFunction ) return helpers[name]( { theData, dependencies, full:original}, ...args )
50
- else return _renderHolder ( helpers[name], theData )
18
+ function render ( theData, name, helpers, original, dependencies, ...args) {
19
+ const useHelper = ( targetName, targetData ) => render ( targetData || theData, targetName, helpers, original, dependencies, ...args )
20
+ if (!helpers[name]) return `( Error: Helper '${name}' is not available )`
21
+
22
+ const isRenderFunction = typeof helpers[name] === 'function';
23
+
24
+ if ( isRenderFunction ) return helpers[name]({ data: theData, dependencies, full: original, useHelper }, ...args)
25
+ else {
26
+ let dataForHolder = theData
27
+ if ( typeof theData !== 'object' || theData === null ) dataForHolder = { text: theData }
28
+ return _renderHolder ( helpers[name], dataForHolder )
29
+ }
51
30
  } // render func.
52
31
 
53
32
 
54
33
 
55
34
  export default render
56
-
57
-