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

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 (41) hide show
  1. package/.turbo/turbo-build.log +36 -36
  2. package/CHANGELOG.md +15 -0
  3. package/dist/LocalDataIndicator.js +7 -1
  4. package/dist/MarkdownView.js +7 -1
  5. package/dist/SaveToStudioButton.js +7 -1
  6. package/dist/SpecDrivenTemplateShell.js +7 -1
  7. package/dist/SpecEditorPanel.js +7 -1
  8. package/dist/TemplateShell.js +7 -1
  9. package/dist/browser/LocalDataIndicator.js +7 -1
  10. package/dist/browser/MarkdownView.js +7 -1
  11. package/dist/browser/SaveToStudioButton.js +7 -1
  12. package/dist/browser/SpecDrivenTemplateShell.js +7 -1
  13. package/dist/browser/SpecEditorPanel.js +7 -1
  14. package/dist/browser/TemplateShell.js +7 -1
  15. package/dist/browser/hooks/index.js +7 -1
  16. package/dist/browser/hooks/useSpecContent.js +7 -1
  17. package/dist/browser/index.js +14 -2
  18. package/dist/browser/lib/component-registry.js +7 -1
  19. package/dist/browser/lib/runtime-context.js +7 -1
  20. package/dist/hooks/index.js +7 -1
  21. package/dist/hooks/useSpecContent.js +7 -1
  22. package/dist/index.js +14 -2
  23. package/dist/lib/component-registry.js +7 -1
  24. package/dist/lib/runtime-context.d.ts +2 -1
  25. package/dist/lib/runtime-context.js +7 -1
  26. package/dist/lib/singletons.test.d.ts +1 -0
  27. package/dist/node/LocalDataIndicator.js +7 -1
  28. package/dist/node/MarkdownView.js +7 -1
  29. package/dist/node/SaveToStudioButton.js +7 -1
  30. package/dist/node/SpecDrivenTemplateShell.js +7 -1
  31. package/dist/node/SpecEditorPanel.js +7 -1
  32. package/dist/node/TemplateShell.js +7 -1
  33. package/dist/node/hooks/index.js +7 -1
  34. package/dist/node/hooks/useSpecContent.js +7 -1
  35. package/dist/node/index.js +14 -2
  36. package/dist/node/lib/component-registry.js +7 -1
  37. package/dist/node/lib/runtime-context.js +7 -1
  38. package/package.json +9 -9
  39. package/src/lib/component-registry.tsx +15 -1
  40. package/src/lib/runtime-context.tsx +17 -3
  41. package/src/lib/singletons.test.ts +54 -0
@@ -2,99 +2,99 @@ $ contractspec-bun-build prebuild
2
2
  $ bun run build:bundle && bun run build:types
3
3
  $ contractspec-bun-build transpile
4
4
  [contractspec-bun-build] transpile target=bun root=src entries=28 noBundle=false
5
- Bundled 28 modules in 47ms
5
+ Bundled 28 modules in 58ms
6
6
 
7
7
  ./EvolutionDashboard.js 31.40 KB (entry point)
8
- ./index.js 119.50 KB (entry point)
8
+ ./index.js 120.15 KB (entry point)
9
9
  ./overlay-types.js 8 bytes (entry point)
10
10
  utils/index.js 10.1 KB (entry point)
11
11
  utils/fetchPresentationData.js 461 bytes (entry point)
12
- lib/component-registry.js 1.23 KB (entry point)
12
+ lib/component-registry.js 1.56 KB (entry point)
13
13
  lib/types.js 8 bytes (entry point)
14
- ./SpecEditorPanel.js 19.64 KB (entry point)
15
- ./TemplateShell.js 6.84 KB (entry point)
14
+ ./SpecEditorPanel.js 19.95 KB (entry point)
15
+ ./TemplateShell.js 7.16 KB (entry point)
16
16
  bundles/index.js 2.44 KB (entry point)
17
17
  bundles/ExampleTemplateBundle.js 2.44 KB (entry point)
18
- hooks/index.js 44.1 KB (entry point)
18
+ hooks/index.js 44.38 KB (entry point)
19
19
  hooks/useWorkflowComposer.js 13.67 KB (entry point)
20
- hooks/useSpecContent.js 14.30 KB (entry point)
20
+ hooks/useSpecContent.js 14.61 KB (entry point)
21
21
  utils/generateSpecFromTemplate.js 9.65 KB (entry point)
22
22
  hooks/useRegistryTemplates.js 0.94 KB (entry point)
23
23
  ./EvolutionSidebar.js 21.24 KB (entry point)
24
24
  hooks/useEvolution.js 9.50 KB (entry point)
25
- ./MarkdownView.js 7.0 KB (entry point)
25
+ ./MarkdownView.js 7.34 KB (entry point)
26
26
  markdown/formatPresentationName.js 314 bytes (entry point)
27
27
  markdown/useMarkdownPresentation.js 2.1 KB (entry point)
28
28
  ./OverlayContextProvider.js 5.89 KB (entry point)
29
29
  ./PersonalizationInsights.js 17.74 KB (entry point)
30
30
  hooks/useBehaviorTracking.js 5.53 KB (entry point)
31
- ./SpecDrivenTemplateShell.js 6.90 KB (entry point)
32
- ./LocalDataIndicator.js 2.20 KB (entry point)
33
- ./SaveToStudioButton.js 2.33 KB (entry point)
34
- lib/runtime-context.js 430 bytes (entry point)
31
+ ./SpecDrivenTemplateShell.js 7.21 KB (entry point)
32
+ ./LocalDataIndicator.js 2.52 KB (entry point)
33
+ ./SaveToStudioButton.js 2.64 KB (entry point)
34
+ lib/runtime-context.js 0.75 KB (entry point)
35
35
 
36
36
  [contractspec-bun-build] transpile target=node root=src entries=28 noBundle=false
37
- Bundled 28 modules in 55ms
37
+ Bundled 28 modules in 96ms
38
38
 
39
39
  ./EvolutionDashboard.js 31.38 KB (entry point)
40
- ./index.js 119.44 KB (entry point)
40
+ ./index.js 120.1 KB (entry point)
41
41
  ./overlay-types.js 0 KB (entry point)
42
42
  utils/index.js 10.1 KB (entry point)
43
43
  utils/fetchPresentationData.js 453 bytes (entry point)
44
- lib/component-registry.js 1.22 KB (entry point)
44
+ lib/component-registry.js 1.55 KB (entry point)
45
45
  lib/types.js 0 KB (entry point)
46
- ./SpecEditorPanel.js 19.63 KB (entry point)
47
- ./TemplateShell.js 6.83 KB (entry point)
46
+ ./SpecEditorPanel.js 19.95 KB (entry point)
47
+ ./TemplateShell.js 7.14 KB (entry point)
48
48
  bundles/index.js 2.43 KB (entry point)
49
49
  bundles/ExampleTemplateBundle.js 2.43 KB (entry point)
50
- hooks/index.js 44.1 KB (entry point)
50
+ hooks/index.js 44.37 KB (entry point)
51
51
  hooks/useWorkflowComposer.js 13.67 KB (entry point)
52
- hooks/useSpecContent.js 14.29 KB (entry point)
52
+ hooks/useSpecContent.js 14.60 KB (entry point)
53
53
  utils/generateSpecFromTemplate.js 9.64 KB (entry point)
54
54
  hooks/useRegistryTemplates.js 0.93 KB (entry point)
55
55
  ./EvolutionSidebar.js 21.23 KB (entry point)
56
56
  hooks/useEvolution.js 9.50 KB (entry point)
57
- ./MarkdownView.js 7.0 KB (entry point)
57
+ ./MarkdownView.js 7.33 KB (entry point)
58
58
  markdown/formatPresentationName.js 306 bytes (entry point)
59
59
  markdown/useMarkdownPresentation.js 2.0 KB (entry point)
60
60
  ./OverlayContextProvider.js 5.88 KB (entry point)
61
61
  ./PersonalizationInsights.js 17.71 KB (entry point)
62
62
  hooks/useBehaviorTracking.js 5.52 KB (entry point)
63
- ./SpecDrivenTemplateShell.js 6.88 KB (entry point)
64
- ./LocalDataIndicator.js 2.19 KB (entry point)
65
- ./SaveToStudioButton.js 2.32 KB (entry point)
66
- lib/runtime-context.js 422 bytes (entry point)
63
+ ./SpecDrivenTemplateShell.js 7.20 KB (entry point)
64
+ ./LocalDataIndicator.js 2.51 KB (entry point)
65
+ ./SaveToStudioButton.js 2.63 KB (entry point)
66
+ lib/runtime-context.js 0.74 KB (entry point)
67
67
 
68
68
  [contractspec-bun-build] transpile target=browser root=src entries=28 noBundle=false
69
- Bundled 28 modules in 63ms
69
+ Bundled 28 modules in 81ms
70
70
 
71
71
  ./EvolutionDashboard.js 31.38 KB (entry point)
72
- ./index.js 119.44 KB (entry point)
72
+ ./index.js 120.1 KB (entry point)
73
73
  ./overlay-types.js 0 KB (entry point)
74
74
  utils/index.js 10.1 KB (entry point)
75
75
  utils/fetchPresentationData.js 453 bytes (entry point)
76
- lib/component-registry.js 1.22 KB (entry point)
76
+ lib/component-registry.js 1.55 KB (entry point)
77
77
  lib/types.js 0 KB (entry point)
78
- ./SpecEditorPanel.js 19.63 KB (entry point)
79
- ./TemplateShell.js 6.83 KB (entry point)
78
+ ./SpecEditorPanel.js 19.95 KB (entry point)
79
+ ./TemplateShell.js 7.14 KB (entry point)
80
80
  bundles/index.js 2.43 KB (entry point)
81
81
  bundles/ExampleTemplateBundle.js 2.43 KB (entry point)
82
- hooks/index.js 44.1 KB (entry point)
82
+ hooks/index.js 44.37 KB (entry point)
83
83
  hooks/useWorkflowComposer.js 13.67 KB (entry point)
84
- hooks/useSpecContent.js 14.29 KB (entry point)
84
+ hooks/useSpecContent.js 14.60 KB (entry point)
85
85
  utils/generateSpecFromTemplate.js 9.64 KB (entry point)
86
86
  hooks/useRegistryTemplates.js 0.93 KB (entry point)
87
87
  ./EvolutionSidebar.js 21.23 KB (entry point)
88
88
  hooks/useEvolution.js 9.50 KB (entry point)
89
- ./MarkdownView.js 7.0 KB (entry point)
89
+ ./MarkdownView.js 7.33 KB (entry point)
90
90
  markdown/formatPresentationName.js 306 bytes (entry point)
91
91
  markdown/useMarkdownPresentation.js 2.0 KB (entry point)
92
92
  ./OverlayContextProvider.js 5.88 KB (entry point)
93
93
  ./PersonalizationInsights.js 17.71 KB (entry point)
94
94
  hooks/useBehaviorTracking.js 5.52 KB (entry point)
95
- ./SpecDrivenTemplateShell.js 6.88 KB (entry point)
96
- ./LocalDataIndicator.js 2.19 KB (entry point)
97
- ./SaveToStudioButton.js 2.32 KB (entry point)
98
- lib/runtime-context.js 422 bytes (entry point)
95
+ ./SpecDrivenTemplateShell.js 7.20 KB (entry point)
96
+ ./LocalDataIndicator.js 2.51 KB (entry point)
97
+ ./SaveToStudioButton.js 2.63 KB (entry point)
98
+ lib/runtime-context.js 0.74 KB (entry point)
99
99
 
100
100
  $ contractspec-bun-build types
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @contractspec/lib.example-shared-ui
2
2
 
3
+ ## 6.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix workflow runtime imports for sandboxed workflow execution and keep workflow authoring on safe subpaths.
8
+ - Migration: Keep Node-only workflow runner code out of "use workflow" entrypoints.
9
+ - Deprecations: Importing the broad `@contractspec/lib.contracts-spec/workflow` barrel from sandboxed workflow entrypoints is discouraged.
10
+ - Updated dependencies because of Fix workflow runtime imports for sandboxed workflow execution and keep workflow authoring on safe subpaths.
11
+ - Updated dependencies because of Add versioning-backed release capsules, generated patch notes, and guided upgrade flows.
12
+ - @contractspec/lib.presentation-runtime-core@3.9.5
13
+ - @contractspec/lib.surface-runtime@0.5.17
14
+ - @contractspec/lib.contracts-spec@5.1.0
15
+ - @contractspec/lib.design-system@3.8.10
16
+ - @contractspec/lib.ui-kit-web@3.9.9
17
+
3
18
  ## 6.0.16
4
19
 
5
20
  ### Patch Changes
@@ -2,7 +2,13 @@
2
2
  // src/lib/runtime-context.tsx
3
3
  import { createContext, useContext } from "react";
4
4
  "use client";
5
- var TemplateRuntimeContext = createContext(null);
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();
6
12
  function useTemplateRuntime() {
7
13
  const context = useContext(TemplateRuntimeContext);
8
14
  if (!context) {
@@ -2,7 +2,13 @@
2
2
  // src/lib/runtime-context.tsx
3
3
  import { createContext, useContext } from "react";
4
4
  "use client";
5
- var TemplateRuntimeContext = createContext(null);
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();
6
12
  function useTemplateRuntime() {
7
13
  const context = useContext(TemplateRuntimeContext);
8
14
  if (!context) {
@@ -2,7 +2,13 @@
2
2
  // src/lib/runtime-context.tsx
3
3
  import { createContext, useContext } from "react";
4
4
  "use client";
5
- var TemplateRuntimeContext = createContext(null);
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();
6
12
  function useTemplateRuntime() {
7
13
  const context = useContext(TemplateRuntimeContext);
8
14
  if (!context) {
@@ -2,7 +2,13 @@
2
2
  // src/lib/runtime-context.tsx
3
3
  import { createContext, useContext } from "react";
4
4
  "use client";
5
- var TemplateRuntimeContext = createContext(null);
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();
6
12
  function useTemplateRuntime() {
7
13
  const context = useContext(TemplateRuntimeContext);
8
14
  if (!context) {
@@ -2,7 +2,13 @@
2
2
  // src/lib/runtime-context.tsx
3
3
  import { createContext, useContext } from "react";
4
4
  "use client";
5
- var TemplateRuntimeContext = createContext(null);
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();
6
12
  function useTemplateRuntime() {
7
13
  const context = useContext(TemplateRuntimeContext);
8
14
  if (!context) {
@@ -2,7 +2,13 @@
2
2
  // src/lib/runtime-context.tsx
3
3
  import { createContext, useContext } from "react";
4
4
  "use client";
5
- var TemplateRuntimeContext = createContext(null);
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();
6
12
  function useTemplateRuntime() {
7
13
  const context = useContext(TemplateRuntimeContext);
8
14
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -259,7 +259,13 @@ function generateRecommendedActions(anomaly) {
259
259
  // src/lib/runtime-context.tsx
260
260
  import { createContext, useContext } from "react";
261
261
  "use client";
262
- var TemplateRuntimeContext = createContext(null);
262
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
263
+ function getTemplateRuntimeContextSingleton() {
264
+ const store = globalThis;
265
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
266
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
267
+ }
268
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
263
269
  function useTemplateRuntime() {
264
270
  const context = useContext(TemplateRuntimeContext);
265
271
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1073,7 +1073,13 @@ function CompactSuggestionCard({
1073
1073
  // src/lib/runtime-context.tsx
1074
1074
  import { createContext, useContext } from "react";
1075
1075
  "use client";
1076
- var TemplateRuntimeContext = createContext(null);
1076
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
1077
+ function getTemplateRuntimeContextSingleton() {
1078
+ const store = globalThis;
1079
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
1080
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
1081
+ }
1082
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
1077
1083
  function useTemplateRuntime() {
1078
1084
  const context = useContext(TemplateRuntimeContext);
1079
1085
  if (!context) {
@@ -3422,7 +3428,13 @@ class TemplateComponentRegistry {
3422
3428
  };
3423
3429
  }
3424
3430
  }
3425
- var templateComponentRegistry = new TemplateComponentRegistry;
3431
+ var TEMPLATE_COMPONENT_REGISTRY_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-component-registry");
3432
+ function getTemplateComponentRegistrySingleton() {
3433
+ const store = globalThis;
3434
+ store[TEMPLATE_COMPONENT_REGISTRY_KEY] ??= new TemplateComponentRegistry;
3435
+ return store[TEMPLATE_COMPONENT_REGISTRY_KEY];
3436
+ }
3437
+ var templateComponentRegistry = getTemplateComponentRegistrySingleton();
3426
3438
  function registerTemplateComponents(templateId, components) {
3427
3439
  templateComponentRegistry.register(templateId, components);
3428
3440
  }
@@ -19,7 +19,13 @@ class TemplateComponentRegistry {
19
19
  };
20
20
  }
21
21
  }
22
- var templateComponentRegistry = new TemplateComponentRegistry;
22
+ var TEMPLATE_COMPONENT_REGISTRY_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-component-registry");
23
+ function getTemplateComponentRegistrySingleton() {
24
+ const store = globalThis;
25
+ store[TEMPLATE_COMPONENT_REGISTRY_KEY] ??= new TemplateComponentRegistry;
26
+ return store[TEMPLATE_COMPONENT_REGISTRY_KEY];
27
+ }
28
+ var templateComponentRegistry = getTemplateComponentRegistrySingleton();
23
29
  function registerTemplateComponents(templateId, components) {
24
30
  templateComponentRegistry.register(templateId, components);
25
31
  }
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -260,7 +260,13 @@ function generateRecommendedActions(anomaly) {
260
260
  // src/lib/runtime-context.tsx
261
261
  import { createContext, useContext } from "react";
262
262
  "use client";
263
- var TemplateRuntimeContext = createContext(null);
263
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
264
+ function getTemplateRuntimeContextSingleton() {
265
+ const store = globalThis;
266
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
267
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
268
+ }
269
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
264
270
  function useTemplateRuntime() {
265
271
  const context = useContext(TemplateRuntimeContext);
266
272
  if (!context) {
@@ -2,7 +2,13 @@
2
2
  // src/lib/runtime-context.tsx
3
3
  import { createContext, useContext } from "react";
4
4
  "use client";
5
- var TemplateRuntimeContext = createContext(null);
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();
6
12
  function useTemplateRuntime() {
7
13
  const context = useContext(TemplateRuntimeContext);
8
14
  if (!context) {
package/dist/index.js CHANGED
@@ -1074,7 +1074,13 @@ function CompactSuggestionCard({
1074
1074
  // src/lib/runtime-context.tsx
1075
1075
  import { createContext, useContext } from "react";
1076
1076
  "use client";
1077
- var TemplateRuntimeContext = createContext(null);
1077
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
1078
+ function getTemplateRuntimeContextSingleton() {
1079
+ const store = globalThis;
1080
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
1081
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
1082
+ }
1083
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
1078
1084
  function useTemplateRuntime() {
1079
1085
  const context = useContext(TemplateRuntimeContext);
1080
1086
  if (!context) {
@@ -3423,7 +3429,13 @@ class TemplateComponentRegistry {
3423
3429
  };
3424
3430
  }
3425
3431
  }
3426
- var templateComponentRegistry = new TemplateComponentRegistry;
3432
+ var TEMPLATE_COMPONENT_REGISTRY_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-component-registry");
3433
+ function getTemplateComponentRegistrySingleton() {
3434
+ const store = globalThis;
3435
+ store[TEMPLATE_COMPONENT_REGISTRY_KEY] ??= new TemplateComponentRegistry;
3436
+ return store[TEMPLATE_COMPONENT_REGISTRY_KEY];
3437
+ }
3438
+ var templateComponentRegistry = getTemplateComponentRegistrySingleton();
3427
3439
  function registerTemplateComponents(templateId, components) {
3428
3440
  templateComponentRegistry.register(templateId, components);
3429
3441
  }
@@ -20,7 +20,13 @@ class TemplateComponentRegistry {
20
20
  };
21
21
  }
22
22
  }
23
- var templateComponentRegistry = new TemplateComponentRegistry;
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();
24
30
  function registerTemplateComponents(templateId, components) {
25
31
  templateComponentRegistry.register(templateId, components);
26
32
  }
@@ -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;
@@ -2,7 +2,13 @@
2
2
  // src/lib/runtime-context.tsx
3
3
  import { createContext, useContext } from "react";
4
4
  "use client";
5
- var TemplateRuntimeContext = createContext(null);
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();
6
12
  function useTemplateRuntime() {
7
13
  const context = useContext(TemplateRuntimeContext);
8
14
  if (!context) {
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -259,7 +259,13 @@ function generateRecommendedActions(anomaly) {
259
259
  // src/lib/runtime-context.tsx
260
260
  import { createContext, useContext } from "react";
261
261
  "use client";
262
- var TemplateRuntimeContext = createContext(null);
262
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
263
+ function getTemplateRuntimeContextSingleton() {
264
+ const store = globalThis;
265
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
266
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
267
+ }
268
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
263
269
  function useTemplateRuntime() {
264
270
  const context = useContext(TemplateRuntimeContext);
265
271
  if (!context) {
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
@@ -1073,7 +1073,13 @@ function CompactSuggestionCard({
1073
1073
  // src/lib/runtime-context.tsx
1074
1074
  import { createContext, useContext } from "react";
1075
1075
  "use client";
1076
- var TemplateRuntimeContext = createContext(null);
1076
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
1077
+ function getTemplateRuntimeContextSingleton() {
1078
+ const store = globalThis;
1079
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
1080
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
1081
+ }
1082
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
1077
1083
  function useTemplateRuntime() {
1078
1084
  const context = useContext(TemplateRuntimeContext);
1079
1085
  if (!context) {
@@ -3422,7 +3428,13 @@ class TemplateComponentRegistry {
3422
3428
  };
3423
3429
  }
3424
3430
  }
3425
- var templateComponentRegistry = new TemplateComponentRegistry;
3431
+ var TEMPLATE_COMPONENT_REGISTRY_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-component-registry");
3432
+ function getTemplateComponentRegistrySingleton() {
3433
+ const store = globalThis;
3434
+ store[TEMPLATE_COMPONENT_REGISTRY_KEY] ??= new TemplateComponentRegistry;
3435
+ return store[TEMPLATE_COMPONENT_REGISTRY_KEY];
3436
+ }
3437
+ var templateComponentRegistry = getTemplateComponentRegistrySingleton();
3426
3438
  function registerTemplateComponents(templateId, components) {
3427
3439
  templateComponentRegistry.register(templateId, components);
3428
3440
  }
@@ -19,7 +19,13 @@ class TemplateComponentRegistry {
19
19
  };
20
20
  }
21
21
  }
22
- var templateComponentRegistry = new TemplateComponentRegistry;
22
+ var TEMPLATE_COMPONENT_REGISTRY_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-component-registry");
23
+ function getTemplateComponentRegistrySingleton() {
24
+ const store = globalThis;
25
+ store[TEMPLATE_COMPONENT_REGISTRY_KEY] ??= new TemplateComponentRegistry;
26
+ return store[TEMPLATE_COMPONENT_REGISTRY_KEY];
27
+ }
28
+ var templateComponentRegistry = getTemplateComponentRegistrySingleton();
23
29
  function registerTemplateComponents(templateId, components) {
24
30
  templateComponentRegistry.register(templateId, components);
25
31
  }
@@ -1,7 +1,13 @@
1
1
  // src/lib/runtime-context.tsx
2
2
  import { createContext, useContext } from "react";
3
3
  "use client";
4
- var TemplateRuntimeContext = createContext(null);
4
+ var TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for("@contractspec/lib.example-shared-ui/template-runtime-context");
5
+ function getTemplateRuntimeContextSingleton() {
6
+ const store = globalThis;
7
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??= createContext(null);
8
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
9
+ }
10
+ var TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
5
11
  function useTemplateRuntime() {
6
12
  const context = useContext(TemplateRuntimeContext);
7
13
  if (!context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/lib.example-shared-ui",
3
- "version": "6.0.16",
3
+ "version": "6.0.17",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -423,7 +423,7 @@
423
423
  }
424
424
  },
425
425
  "peerDependencies": {
426
- "@contractspec/lib.surface-runtime": "0.5.16"
426
+ "@contractspec/lib.surface-runtime": "0.5.17"
427
427
  },
428
428
  "peerDependenciesMeta": {
429
429
  "@contractspec/lib.surface-runtime": {
@@ -432,25 +432,25 @@
432
432
  },
433
433
  "dependencies": {
434
434
  "@apollo/client": "^4.1.6",
435
- "@contractspec/lib.contracts-spec": "5.0.4",
436
- "@contractspec/lib.design-system": "3.8.9",
437
- "@contractspec/lib.ui-kit-web": "3.9.8",
435
+ "@contractspec/lib.contracts-spec": "5.1.0",
436
+ "@contractspec/lib.design-system": "3.8.10",
437
+ "@contractspec/lib.ui-kit-web": "3.9.9",
438
438
  "@tanstack/react-query": "^5.95.2",
439
439
  "framer-motion": "^12.38.0",
440
440
  "lucide-react": "^1.6.0",
441
441
  "react": "19.2.0",
442
442
  "react-dom": "19.2.0",
443
- "@contractspec/lib.presentation-runtime-core": "3.9.4"
443
+ "@contractspec/lib.presentation-runtime-core": "3.9.5"
444
444
  },
445
445
  "optionalDependencies": {
446
- "@contractspec/lib.surface-runtime": "0.5.16"
446
+ "@contractspec/lib.surface-runtime": "0.5.17"
447
447
  },
448
448
  "devDependencies": {
449
- "@contractspec/tool.typescript": "3.7.12",
449
+ "@contractspec/tool.typescript": "3.7.13",
450
450
  "@types/react": "^19.2.14",
451
451
  "@types/react-dom": "^19.2.2",
452
452
  "typescript": "^5.9.3",
453
- "@contractspec/tool.bun": "3.7.12"
453
+ "@contractspec/tool.bun": "3.7.13"
454
454
  },
455
455
  "types": "./dist/index.d.ts"
456
456
  }
@@ -36,7 +36,21 @@ export class TemplateComponentRegistry {
36
36
  }
37
37
  }
38
38
 
39
- export const templateComponentRegistry = new TemplateComponentRegistry();
39
+ const TEMPLATE_COMPONENT_REGISTRY_KEY = Symbol.for(
40
+ '@contractspec/lib.example-shared-ui/template-component-registry'
41
+ );
42
+
43
+ type TemplateComponentRegistryStore = typeof globalThis & {
44
+ [TEMPLATE_COMPONENT_REGISTRY_KEY]?: TemplateComponentRegistry;
45
+ };
46
+
47
+ function getTemplateComponentRegistrySingleton() {
48
+ const store = globalThis as TemplateComponentRegistryStore;
49
+ store[TEMPLATE_COMPONENT_REGISTRY_KEY] ??= new TemplateComponentRegistry();
50
+ return store[TEMPLATE_COMPONENT_REGISTRY_KEY];
51
+ }
52
+
53
+ export const templateComponentRegistry = getTemplateComponentRegistrySingleton();
40
54
 
41
55
  export function registerTemplateComponents(
42
56
  templateId: TemplateId,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type { ApolloClient } from '@apollo/client';
4
4
  import type { TransformEngine } from '@contractspec/lib.presentation-runtime-core/transform-engine';
5
- import { createContext, useContext } from 'react';
5
+ import { createContext, useContext, type Context } from 'react';
6
6
  import type {
7
7
  TemplateDefinition,
8
8
  TemplateId,
@@ -32,8 +32,22 @@ export interface TemplateRuntimeContextValue<
32
32
  resolvePresentation?: (presentationName: string) => unknown;
33
33
  }
34
34
 
35
- export const TemplateRuntimeContext =
36
- createContext<TemplateRuntimeContextValue | null>(null);
35
+ const TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for(
36
+ '@contractspec/lib.example-shared-ui/template-runtime-context'
37
+ );
38
+
39
+ type TemplateRuntimeContextStore = typeof globalThis & {
40
+ [TEMPLATE_RUNTIME_CONTEXT_KEY]?: Context<TemplateRuntimeContextValue | null>;
41
+ };
42
+
43
+ function getTemplateRuntimeContextSingleton() {
44
+ const store = globalThis as TemplateRuntimeContextStore;
45
+ store[TEMPLATE_RUNTIME_CONTEXT_KEY] ??=
46
+ createContext<TemplateRuntimeContextValue | null>(null);
47
+ return store[TEMPLATE_RUNTIME_CONTEXT_KEY];
48
+ }
49
+
50
+ export const TemplateRuntimeContext = getTemplateRuntimeContextSingleton();
37
51
 
38
52
  export function useTemplateRuntime<
39
53
  THandlers = GenericTemplateHandlers,
@@ -0,0 +1,54 @@
1
+ import { describe, expect, test } from 'bun:test';
2
+ import {
3
+ registerTemplateComponents,
4
+ templateComponentRegistry,
5
+ } from './component-registry';
6
+ import { TemplateRuntimeContext } from './runtime-context';
7
+
8
+ const TEMPLATE_RUNTIME_CONTEXT_KEY = Symbol.for(
9
+ '@contractspec/lib.example-shared-ui/template-runtime-context'
10
+ );
11
+ const TEMPLATE_COMPONENT_REGISTRY_KEY = Symbol.for(
12
+ '@contractspec/lib.example-shared-ui/template-component-registry'
13
+ );
14
+
15
+ const DummyComponent = () => null;
16
+
17
+ describe('@contractspec/lib.example-shared-ui singletons', () => {
18
+ test('stores TemplateRuntimeContext on globalThis and reuses it', async () => {
19
+ const runtimeContextStore = globalThis as Record<PropertyKey, unknown>;
20
+ const runtimeContextModule = await import('./runtime-context');
21
+
22
+ expect(runtimeContextStore[TEMPLATE_RUNTIME_CONTEXT_KEY]).toBe(
23
+ TemplateRuntimeContext
24
+ );
25
+ expect(runtimeContextModule.TemplateRuntimeContext).toBe(
26
+ TemplateRuntimeContext
27
+ );
28
+ });
29
+
30
+ test(
31
+ 'stores TemplateComponentRegistry on globalThis and reuses registrations',
32
+ async () => {
33
+ const registryStore = globalThis as Record<PropertyKey, unknown>;
34
+ const registryModule = await import('./component-registry');
35
+ const templateId = `singleton-test-${Date.now()}`;
36
+ const registration = {
37
+ list: DummyComponent,
38
+ detail: DummyComponent,
39
+ };
40
+
41
+ registerTemplateComponents(templateId, registration);
42
+
43
+ expect(registryStore[TEMPLATE_COMPONENT_REGISTRY_KEY]).toBe(
44
+ templateComponentRegistry
45
+ );
46
+ expect(registryModule.templateComponentRegistry).toBe(
47
+ templateComponentRegistry
48
+ );
49
+ expect(registryModule.templateComponentRegistry.get(templateId)).toBe(
50
+ registration
51
+ );
52
+ }
53
+ );
54
+ });