@contractspec/lib.example-shared-ui 6.0.16 → 6.0.18

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 (86) hide show
  1. package/.turbo/turbo-build.log +81 -81
  2. package/CHANGELOG.md +32 -0
  3. package/dist/EvolutionDashboard.js +1 -803
  4. package/dist/EvolutionSidebar.js +1 -531
  5. package/dist/LocalDataIndicator.js +1 -62
  6. package/dist/MarkdownView.js +1 -207
  7. package/dist/OverlayContextProvider.js +1 -202
  8. package/dist/PersonalizationInsights.js +1 -455
  9. package/dist/SaveToStudioButton.js +1 -73
  10. package/dist/SpecDrivenTemplateShell.js +1 -197
  11. package/dist/SpecEditorPanel.js +17 -358
  12. package/dist/TemplateShell.js +1 -189
  13. package/dist/browser/EvolutionDashboard.js +1 -803
  14. package/dist/browser/EvolutionSidebar.js +1 -531
  15. package/dist/browser/LocalDataIndicator.js +1 -62
  16. package/dist/browser/MarkdownView.js +1 -207
  17. package/dist/browser/OverlayContextProvider.js +1 -202
  18. package/dist/browser/PersonalizationInsights.js +1 -455
  19. package/dist/browser/SaveToStudioButton.js +1 -73
  20. package/dist/browser/SpecDrivenTemplateShell.js +1 -197
  21. package/dist/browser/SpecEditorPanel.js +17 -358
  22. package/dist/browser/TemplateShell.js +1 -189
  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 -1145
  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 -218
  30. package/dist/browser/hooks/useWorkflowComposer.js +24 -483
  31. package/dist/browser/index.js +40 -3110
  32. package/dist/browser/lib/component-registry.js +1 -42
  33. package/dist/browser/lib/runtime-context.js +1 -15
  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 -1145
  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 -218
  46. package/dist/hooks/useWorkflowComposer.js +24 -483
  47. package/dist/index.js +40 -3110
  48. package/dist/lib/component-registry.js +1 -42
  49. package/dist/lib/runtime-context.d.ts +2 -1
  50. package/dist/lib/runtime-context.js +1 -15
  51. package/dist/lib/singletons.test.d.ts +1 -0
  52. package/dist/markdown/formatPresentationName.js +1 -9
  53. package/dist/markdown/useMarkdownPresentation.js +1 -65
  54. package/dist/node/EvolutionDashboard.js +1 -803
  55. package/dist/node/EvolutionSidebar.js +1 -531
  56. package/dist/node/LocalDataIndicator.js +1 -62
  57. package/dist/node/MarkdownView.js +1 -207
  58. package/dist/node/OverlayContextProvider.js +1 -202
  59. package/dist/node/PersonalizationInsights.js +1 -455
  60. package/dist/node/SaveToStudioButton.js +1 -73
  61. package/dist/node/SpecDrivenTemplateShell.js +1 -197
  62. package/dist/node/SpecEditorPanel.js +17 -358
  63. package/dist/node/TemplateShell.js +1 -189
  64. package/dist/node/bundles/ExampleTemplateBundle.js +1 -85
  65. package/dist/node/bundles/index.js +1 -85
  66. package/dist/node/hooks/index.js +40 -1145
  67. package/dist/node/hooks/useBehaviorTracking.js +1 -157
  68. package/dist/node/hooks/useEvolution.js +1 -260
  69. package/dist/node/hooks/useRegistryTemplates.js +1 -31
  70. package/dist/node/hooks/useSpecContent.js +17 -218
  71. package/dist/node/hooks/useWorkflowComposer.js +24 -483
  72. package/dist/node/index.js +40 -3110
  73. package/dist/node/lib/component-registry.js +1 -42
  74. package/dist/node/lib/runtime-context.js +1 -15
  75. package/dist/node/markdown/formatPresentationName.js +1 -9
  76. package/dist/node/markdown/useMarkdownPresentation.js +1 -65
  77. package/dist/node/utils/fetchPresentationData.js +1 -15
  78. package/dist/node/utils/generateSpecFromTemplate.js +16 -62
  79. package/dist/node/utils/index.js +16 -76
  80. package/dist/utils/fetchPresentationData.js +1 -15
  81. package/dist/utils/generateSpecFromTemplate.js +16 -62
  82. package/dist/utils/index.js +16 -76
  83. package/package.json +14 -14
  84. package/src/lib/component-registry.tsx +16 -1
  85. package/src/lib/runtime-context.tsx +17 -3
  86. package/src/lib/singletons.test.ts +51 -0
@@ -1,43 +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 templateComponentRegistry = new TemplateComponentRegistry;
24
- function registerTemplateComponents(templateId, components) {
25
- templateComponentRegistry.register(templateId, components);
26
- }
27
- function useTemplateComponents(templateId) {
28
- const [components, setComponents] = useState(() => templateComponentRegistry.get(templateId));
29
- useEffect(() => {
30
- return templateComponentRegistry.subscribe((updatedId) => {
31
- if (updatedId === templateId) {
32
- setComponents(templateComponentRegistry.get(templateId));
33
- }
34
- });
35
- }, [templateId]);
36
- return components;
37
- }
38
- export {
39
- useTemplateComponents,
40
- templateComponentRegistry,
41
- registerTemplateComponents,
42
- TemplateComponentRegistry
43
- };
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,5 +1,6 @@
1
1
  import type { ApolloClient } from '@apollo/client';
2
2
  import type { TransformEngine } from '@contractspec/lib.presentation-runtime-core/transform-engine';
3
+ import { type Context } from 'react';
3
4
  import type { TemplateDefinition, TemplateId, TemplateInstaller } from './types';
4
5
  export type GenericTemplateHandlers = unknown;
5
6
  export interface TemplateRuntimeContextValue<THandlers = GenericTemplateHandlers> {
@@ -19,7 +20,7 @@ export interface TemplateRuntimeContextValue<THandlers = GenericTemplateHandlers
19
20
  handlers: THandlers;
20
21
  resolvePresentation?: (presentationName: string) => unknown;
21
22
  }
22
- export declare const TemplateRuntimeContext: import("react").Context<TemplateRuntimeContextValue<unknown> | null>;
23
+ export declare const TemplateRuntimeContext: Context<TemplateRuntimeContextValue<unknown> | null>;
23
24
  export declare function useTemplateRuntime<THandlers = GenericTemplateHandlers>(): TemplateRuntimeContextValue<THandlers>;
24
25
  export interface TemplateRuntimeProviderProps {
25
26
  templateId: TemplateId;
@@ -1,16 +1,2 @@
1
1
  // @bun
2
- // src/lib/runtime-context.tsx
3
- import { createContext, useContext } from "react";
4
- "use client";
5
- var TemplateRuntimeContext = createContext(null);
6
- function useTemplateRuntime() {
7
- const context = useContext(TemplateRuntimeContext);
8
- if (!context) {
9
- throw new Error("useTemplateRuntime must be used within a TemplateRuntimeProvider");
10
- }
11
- return context;
12
- }
13
- export {
14
- useTemplateRuntime,
15
- TemplateRuntimeContext
16
- };
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};
@@ -0,0 +1 @@
1
+ export {};
@@ -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};