@contractspec/lib.example-shared-ui 6.0.17 → 6.0.19

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 (84) hide show
  1. package/.turbo/turbo-build.log +81 -81
  2. package/CHANGELOG.md +28 -0
  3. package/dist/EvolutionDashboard.js +1 -803
  4. package/dist/EvolutionSidebar.js +1 -531
  5. package/dist/LocalDataIndicator.js +1 -68
  6. package/dist/MarkdownView.js +1 -213
  7. package/dist/OverlayContextProvider.js +1 -202
  8. package/dist/PersonalizationInsights.js +1 -455
  9. package/dist/SaveToStudioButton.js +1 -79
  10. package/dist/SpecDrivenTemplateShell.js +1 -203
  11. package/dist/SpecEditorPanel.js +17 -364
  12. package/dist/TemplateShell.js +1 -195
  13. package/dist/browser/EvolutionDashboard.js +1 -803
  14. package/dist/browser/EvolutionSidebar.js +1 -531
  15. package/dist/browser/LocalDataIndicator.js +1 -68
  16. package/dist/browser/MarkdownView.js +1 -213
  17. package/dist/browser/OverlayContextProvider.js +1 -202
  18. package/dist/browser/PersonalizationInsights.js +1 -455
  19. package/dist/browser/SaveToStudioButton.js +1 -79
  20. package/dist/browser/SpecDrivenTemplateShell.js +1 -203
  21. package/dist/browser/SpecEditorPanel.js +17 -364
  22. package/dist/browser/TemplateShell.js +1 -195
  23. package/dist/browser/bundles/ExampleTemplateBundle.js +1 -85
  24. package/dist/browser/bundles/index.js +1 -85
  25. package/dist/browser/hooks/index.js +40 -1151
  26. package/dist/browser/hooks/useBehaviorTracking.js +1 -157
  27. package/dist/browser/hooks/useEvolution.js +1 -260
  28. package/dist/browser/hooks/useRegistryTemplates.js +1 -31
  29. package/dist/browser/hooks/useSpecContent.js +17 -224
  30. package/dist/browser/hooks/useWorkflowComposer.js +24 -483
  31. package/dist/browser/index.js +40 -3122
  32. package/dist/browser/lib/component-registry.js +1 -48
  33. package/dist/browser/lib/runtime-context.js +1 -21
  34. package/dist/browser/markdown/formatPresentationName.js +1 -9
  35. package/dist/browser/markdown/useMarkdownPresentation.js +1 -65
  36. package/dist/browser/utils/fetchPresentationData.js +1 -15
  37. package/dist/browser/utils/generateSpecFromTemplate.js +16 -62
  38. package/dist/browser/utils/index.js +16 -76
  39. package/dist/bundles/ExampleTemplateBundle.js +1 -85
  40. package/dist/bundles/index.js +1 -85
  41. package/dist/hooks/index.js +40 -1151
  42. package/dist/hooks/useBehaviorTracking.js +1 -157
  43. package/dist/hooks/useEvolution.js +1 -260
  44. package/dist/hooks/useRegistryTemplates.js +1 -31
  45. package/dist/hooks/useSpecContent.js +17 -224
  46. package/dist/hooks/useWorkflowComposer.js +24 -483
  47. package/dist/index.js +40 -3122
  48. package/dist/lib/component-registry.js +1 -48
  49. package/dist/lib/runtime-context.js +1 -21
  50. package/dist/markdown/formatPresentationName.js +1 -9
  51. package/dist/markdown/useMarkdownPresentation.js +1 -65
  52. package/dist/node/EvolutionDashboard.js +1 -803
  53. package/dist/node/EvolutionSidebar.js +1 -531
  54. package/dist/node/LocalDataIndicator.js +1 -68
  55. package/dist/node/MarkdownView.js +1 -213
  56. package/dist/node/OverlayContextProvider.js +1 -202
  57. package/dist/node/PersonalizationInsights.js +1 -455
  58. package/dist/node/SaveToStudioButton.js +1 -79
  59. package/dist/node/SpecDrivenTemplateShell.js +1 -203
  60. package/dist/node/SpecEditorPanel.js +17 -364
  61. package/dist/node/TemplateShell.js +1 -195
  62. package/dist/node/bundles/ExampleTemplateBundle.js +1 -85
  63. package/dist/node/bundles/index.js +1 -85
  64. package/dist/node/hooks/index.js +40 -1151
  65. package/dist/node/hooks/useBehaviorTracking.js +1 -157
  66. package/dist/node/hooks/useEvolution.js +1 -260
  67. package/dist/node/hooks/useRegistryTemplates.js +1 -31
  68. package/dist/node/hooks/useSpecContent.js +17 -224
  69. package/dist/node/hooks/useWorkflowComposer.js +24 -483
  70. package/dist/node/index.js +40 -3122
  71. package/dist/node/lib/component-registry.js +1 -48
  72. package/dist/node/lib/runtime-context.js +1 -21
  73. package/dist/node/markdown/formatPresentationName.js +1 -9
  74. package/dist/node/markdown/useMarkdownPresentation.js +1 -65
  75. package/dist/node/utils/fetchPresentationData.js +1 -15
  76. package/dist/node/utils/generateSpecFromTemplate.js +16 -62
  77. package/dist/node/utils/index.js +16 -76
  78. package/dist/utils/fetchPresentationData.js +1 -15
  79. package/dist/utils/generateSpecFromTemplate.js +16 -62
  80. package/dist/utils/index.js +16 -76
  81. package/package.json +13 -13
  82. package/src/lib/component-registry.tsx +2 -1
  83. package/src/lib/runtime-context.tsx +1 -1
  84. package/src/lib/singletons.test.ts +19 -22
@@ -1,49 +1,2 @@
1
1
  // @bun
2
- // src/lib/component-registry.tsx
3
- import { useEffect, useState } from "react";
4
- "use client";
5
-
6
- class TemplateComponentRegistry {
7
- components = new Map;
8
- listeners = new Set;
9
- register(templateId, registration) {
10
- this.components.set(templateId, registration);
11
- this.listeners.forEach((l) => l(templateId));
12
- }
13
- get(templateId) {
14
- return this.components.get(templateId);
15
- }
16
- subscribe(listener) {
17
- this.listeners.add(listener);
18
- return () => {
19
- this.listeners.delete(listener);
20
- };
21
- }
22
- }
23
- var TEMPLATE_COMPONENT_REGISTRY_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-component-registry");
24
- function getTemplateComponentRegistrySingleton() {
25
- const store = globalThis;
26
- store[TEMPLATE_COMPONENT_REGISTRY_KEY] ??= new TemplateComponentRegistry;
27
- return store[TEMPLATE_COMPONENT_REGISTRY_KEY];
28
- }
29
- var templateComponentRegistry = getTemplateComponentRegistrySingleton();
30
- function registerTemplateComponents(templateId, components) {
31
- templateComponentRegistry.register(templateId, components);
32
- }
33
- function useTemplateComponents(templateId) {
34
- const [components, setComponents] = useState(() => templateComponentRegistry.get(templateId));
35
- useEffect(() => {
36
- return templateComponentRegistry.subscribe((updatedId) => {
37
- if (updatedId === templateId) {
38
- setComponents(templateComponentRegistry.get(templateId));
39
- }
40
- });
41
- }, [templateId]);
42
- return components;
43
- }
44
- export {
45
- useTemplateComponents,
46
- templateComponentRegistry,
47
- registerTemplateComponents,
48
- TemplateComponentRegistry
49
- };
2
+ import{useEffect as w,useState as x}from"react";class q{components=new Map;listeners=new Set;register(b,f){this.components.set(b,f),this.listeners.forEach((j)=>j(b))}get(b){return this.components.get(b)}subscribe(b){return this.listeners.add(b),()=>{this.listeners.delete(b)}}}var k=Symbol.for("@contractspec/lib.example-shared-ui/template-component-registry");function z(){let b=globalThis;return b[k]??=new q,b[k]}var h=z();function F(b,f){h.register(b,f)}function H(b){let[f,j]=x(()=>h.get(b));return w(()=>{return h.subscribe((v)=>{if(v===b)j(h.get(b))})},[b]),f}export{H as useTemplateComponents,h as templateComponentRegistry,F as registerTemplateComponents,q as TemplateComponentRegistry};
@@ -1,22 +1,2 @@
1
1
  // @bun
2
- // src/lib/runtime-context.tsx
3
- import { createContext, useContext } from "react";
4
- "use client";
5
- var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
6
- function getTemplateRuntimeContextSingleton() {
7
- const store = globalThis;
8
- store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
9
- return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
10
- }
11
- var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
12
- function useTemplateRuntime() {
13
- const context = useContext(TemplateRuntimeContext);
14
- if (!context) {
15
- throw new Error("useTemplateRuntime must be used within a TemplateRuntimeProvider");
16
- }
17
- return context;
18
- }
19
- export {
20
- useTemplateRuntime,
21
- TemplateRuntimeContext
22
- };
2
+ import{createContext as f,useContext as h}from"react";var d=Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");function j(){let b=globalThis;return b[d]??=f(null),b[d]}var k=j();function v(){let b=h(k);if(!b)throw Error("useTemplateRuntime must be used within a TemplateRuntimeProvider");return b}export{v as useTemplateRuntime,k as TemplateRuntimeContext};
@@ -1,10 +1,2 @@
1
1
  // @bun
2
- // src/markdown/formatPresentationName.ts
3
- function formatPresentationName(name) {
4
- const parts = name.split(".");
5
- const lastPart = parts[parts.length - 1] ?? name;
6
- return lastPart.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
7
- }
8
- export {
9
- formatPresentationName
10
- };
2
+ function n(t){let s=t.split(".");return(s[s.length-1]??t).split("-").map((r)=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}export{n as formatPresentationName};
@@ -1,66 +1,2 @@
1
1
  // @bun
2
- // src/markdown/useMarkdownPresentation.ts
3
- import { useCallback, useEffect, useState } from "react";
4
- "use client";
5
- function useMarkdownPresentation({
6
- engine,
7
- fetchData,
8
- presentationId,
9
- presentations,
10
- resolvePresentation,
11
- templateId
12
- }) {
13
- const [selectedPresentation, setSelectedPresentation] = useState("");
14
- const [markdownContent, setMarkdownContent] = useState("");
15
- const [loading, setLoading] = useState(false);
16
- const [error, setError] = useState(null);
17
- useEffect(() => {
18
- if (presentationId && presentations.includes(presentationId)) {
19
- setSelectedPresentation(presentationId);
20
- return;
21
- }
22
- if (presentations.length === 0) {
23
- setSelectedPresentation("");
24
- return;
25
- }
26
- if (!presentations.includes(selectedPresentation)) {
27
- setSelectedPresentation(presentations[0] ?? "");
28
- }
29
- }, [presentationId, presentations, selectedPresentation, templateId]);
30
- const renderMarkdown = useCallback(async () => {
31
- if (!selectedPresentation || !engine)
32
- return;
33
- setLoading(true);
34
- setError(null);
35
- try {
36
- if (!resolvePresentation) {
37
- throw new Error("resolvePresentation not available in runtime context");
38
- }
39
- const descriptor = resolvePresentation(selectedPresentation);
40
- if (!descriptor) {
41
- throw new Error(`Presentation descriptor not found: ${selectedPresentation}`);
42
- }
43
- const dataResult = await fetchData(selectedPresentation);
44
- const result = await engine.render("markdown", descriptor, { data: dataResult.data });
45
- setMarkdownContent(result.body);
46
- } catch (err) {
47
- setError(err instanceof Error ? err : new Error("Failed to render markdown"));
48
- } finally {
49
- setLoading(false);
50
- }
51
- }, [engine, fetchData, resolvePresentation, selectedPresentation]);
52
- useEffect(() => {
53
- renderMarkdown();
54
- }, [renderMarkdown]);
55
- return {
56
- error,
57
- loading,
58
- markdownContent,
59
- renderMarkdown,
60
- selectedPresentation,
61
- setSelectedPresentation
62
- };
63
- }
64
- export {
65
- useMarkdownPresentation
66
- };
2
+ import{useCallback as M,useEffect as f,useState as s}from"react";function b({engine:a,fetchData:c,presentationId:t,presentations:r,resolvePresentation:i,templateId:w}){let[n,o]=s(""),[m,g]=s(""),[k,l]=s(!1),[p,u]=s(null);f(()=>{if(t&&r.includes(t)){o(t);return}if(r.length===0){o("");return}if(!r.includes(n))o(r[0]??"")},[t,r,n,w]);let d=M(async()=>{if(!n||!a)return;l(!0),u(null);try{if(!i)throw Error("resolvePresentation not available in runtime context");let e=i(n);if(!e)throw Error(`Presentation descriptor not found: ${n}`);let P=await c(n),E=await a.render("markdown",e,{data:P.data});g(E.body)}catch(e){u(e instanceof Error?e:Error("Failed to render markdown"))}finally{l(!1)}},[a,c,i,n]);return f(()=>{d()},[d]),{error:p,loading:k,markdownContent:m,renderMarkdown:d,selectedPresentation:n,setSelectedPresentation:o}}export{b as useMarkdownPresentation};