@openchamber/sdk 1.23.2-preview.1 → 1.24.1
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.
- package/API.md +73 -27
- package/DOCUMENTATION.md +43 -4
- package/README.md +68 -5
- package/dist/contract.d.ts +36 -3
- package/dist/contract.js +1 -1
- package/dist/host.d.ts +7 -1
- package/dist/host.js +41 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/manifest.d.ts +13 -8
- package/dist/manifest.js +2 -4
- package/dist/parse.d.ts +14 -0
- package/dist/parse.js +27 -8
- package/dist/protocol.d.ts +57 -1
- package/dist/protocol.js +24 -1
- package/dist/scrollbar-style.d.ts +2 -0
- package/dist/scrollbar-style.js +32 -0
- package/dist/ui/menu.js +5 -1
- package/dist/ui/select.js +5 -1
- package/dist/ui/style.js +33 -21
- package/dist/ui/theme.js +10 -0
- package/package.json +2 -2
package/dist/ui/style.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GUEST_SCROLLBAR_CSS } from "../scrollbar-style.js";
|
|
1
2
|
/** Host CSS variable → `--oc-*` alias written by `theme.ts`. */
|
|
2
3
|
const OC_ALIAS = {
|
|
3
4
|
'surface-background': 'bg',
|
|
@@ -5,6 +6,7 @@ const OC_ALIAS = {
|
|
|
5
6
|
'surface-elevated-foreground': 'elevated-fg',
|
|
6
7
|
'surface-foreground': 'fg',
|
|
7
8
|
'surface-muted-foreground': 'muted',
|
|
9
|
+
'surface-muted': 'muted-surface',
|
|
8
10
|
'surface-subtle': 'subtle',
|
|
9
11
|
'interactive-border': 'border',
|
|
10
12
|
'interactive-hover': 'hover',
|
|
@@ -14,6 +16,11 @@ const OC_ALIAS = {
|
|
|
14
16
|
'interactive-focus-ring': 'focus',
|
|
15
17
|
'primary': 'primary',
|
|
16
18
|
'primary-foreground': 'primary-fg',
|
|
19
|
+
'primary-text': 'primary-text',
|
|
20
|
+
'success-text': 'success-text',
|
|
21
|
+
'warning-text': 'warning-text',
|
|
22
|
+
'error-text': 'error-text',
|
|
23
|
+
'info-text': 'info-text',
|
|
17
24
|
'status-success': 'success',
|
|
18
25
|
'status-warning': 'warning',
|
|
19
26
|
'status-error': 'error',
|
|
@@ -28,7 +35,7 @@ const elevated = v('surface-elevated', 'transparent');
|
|
|
28
35
|
const elevatedFg = v('surface-elevated-foreground', 'inherit');
|
|
29
36
|
const fg = v('surface-foreground', 'inherit');
|
|
30
37
|
const muted = v('surface-muted-foreground', 'gray');
|
|
31
|
-
const
|
|
38
|
+
const secondary = v('surface-muted', 'transparent');
|
|
32
39
|
const border = v('interactive-border', 'currentColor');
|
|
33
40
|
const hover = v('interactive-hover', 'transparent');
|
|
34
41
|
const active = v('interactive-active', 'transparent');
|
|
@@ -36,6 +43,8 @@ const selection = v('interactive-selection', 'transparent');
|
|
|
36
43
|
const selectionFg = v('interactive-selection-foreground', 'inherit');
|
|
37
44
|
const focus = v('interactive-focus-ring', 'currentColor');
|
|
38
45
|
const primary = v('primary', 'currentColor');
|
|
46
|
+
const primaryText = v('primary-text', 'inherit');
|
|
47
|
+
const errorText = v('error-text', 'inherit');
|
|
39
48
|
const font = v('font-sans', 'inherit');
|
|
40
49
|
const mono = v('font-mono', 'monospace');
|
|
41
50
|
const radius = v('radius', '9px');
|
|
@@ -44,9 +53,10 @@ const focusRing = `box-shadow: 0 0 0 2px ${focus};`;
|
|
|
44
53
|
const tone = (name) => {
|
|
45
54
|
const color = v(`status-${name}`, 'currentColor');
|
|
46
55
|
return `
|
|
47
|
-
.oc-sdk[data-tone="${name}"], .oc-sdk [data-tone="${name}"] { --oc-sdk-tone: ${color}; }`;
|
|
56
|
+
.oc-sdk[data-tone="${name}"], .oc-sdk [data-tone="${name}"] { --oc-sdk-tone: ${color}; --oc-sdk-tone-text: ${v(`${name}-text`, 'inherit')}; }`;
|
|
48
57
|
};
|
|
49
58
|
export const UI_CSS = `
|
|
59
|
+
${GUEST_SCROLLBAR_CSS}
|
|
50
60
|
.oc-sdk { box-sizing: border-box; color: ${fg}; font-family: ${font}; font-size: 0.875rem; line-height: 1.45; }
|
|
51
61
|
.oc-sdk *, .oc-sdk *::before, .oc-sdk *::after { box-sizing: border-box; }
|
|
52
62
|
/* :where() keeps the reset at zero specificity so every primitive class below overrides it. */
|
|
@@ -57,22 +67,24 @@ export const UI_CSS = `
|
|
|
57
67
|
.oc-sdk-mono { font-family: ${mono}; }
|
|
58
68
|
.oc-sdk-muted { color: ${muted}; }
|
|
59
69
|
${tone('success')}${tone('warning')}${tone('error')}${tone('info')}
|
|
60
|
-
.oc-sdk[data-tone="primary"], .oc-sdk [data-tone="primary"] { --oc-sdk-tone: ${primary}; }
|
|
70
|
+
.oc-sdk[data-tone="primary"], .oc-sdk [data-tone="primary"] { --oc-sdk-tone: ${primary}; --oc-sdk-tone-text: ${primaryText}; }
|
|
61
71
|
|
|
62
72
|
.oc-sdk-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: ${radius}; font-size: 0.875rem; font-weight: 500; line-height: 1; white-space: nowrap; transition: background 150ms ease-out, color 150ms ease-out; }
|
|
63
73
|
.oc-sdk-btn[data-size="sm"] { height: 32px; padding: 0 10px; font-size: 0.8125rem; }
|
|
64
74
|
.oc-sdk-btn[data-size="xs"] { height: 24px; padding: 0 8px; font-size: 0.75rem; border-radius: 6px; }
|
|
65
|
-
.oc-sdk-btn[data-variant="default"] { color: ${
|
|
75
|
+
.oc-sdk-btn[data-variant="default"] { color: ${primaryText}; background: ${mix(primary, 10, bg)}; border-color: ${mix(primary, 12)}; }
|
|
66
76
|
.oc-sdk-btn[data-variant="default"]:hover { background: ${mix(primary, 16, bg)}; }
|
|
67
77
|
.oc-sdk-btn[data-variant="default"]:active { background: ${mix(primary, 22, bg)}; }
|
|
68
|
-
.oc-sdk-btn[data-variant="secondary"] { background: ${
|
|
69
|
-
.oc-sdk-btn[data-variant="secondary"]:hover { background: ${
|
|
70
|
-
.oc-sdk-btn[data-variant="
|
|
71
|
-
.oc-sdk-btn[data-variant="outline"]
|
|
78
|
+
.oc-sdk-btn[data-variant="secondary"] { background: ${secondary}; color: var(--oc-fg); }
|
|
79
|
+
.oc-sdk-btn[data-variant="secondary"]:hover { background-image: linear-gradient(${hover}, ${hover}); }
|
|
80
|
+
.oc-sdk-btn[data-variant="secondary"]:active { background-image: linear-gradient(${active}, ${active}); }
|
|
81
|
+
.oc-sdk-btn[data-variant="outline"] { background: ${elevated}; color: ${elevatedFg}; border-color: ${border}; }
|
|
82
|
+
.oc-sdk-btn[data-variant="outline"]:hover { background-image: linear-gradient(${hover}, ${hover}); }
|
|
83
|
+
.oc-sdk-btn[data-variant="outline"]:active { background-image: linear-gradient(${active}, ${active}); }
|
|
72
84
|
.oc-sdk-btn[data-variant="ghost"] { background: transparent; }
|
|
73
85
|
.oc-sdk-btn[data-variant="ghost"]:hover { background: ${hover}; }
|
|
74
86
|
.oc-sdk-btn[data-variant="ghost"]:active { background: ${active}; }
|
|
75
|
-
.oc-sdk-btn[data-variant="destructive"] { --oc-sdk-tone: ${v('status-error', 'red')}; color:
|
|
87
|
+
.oc-sdk-btn[data-variant="destructive"] { --oc-sdk-tone: ${v('status-error', 'red')}; color: ${errorText}; background: ${mix('var(--oc-sdk-tone)', 7, bg)}; border-color: ${mix('var(--oc-sdk-tone)', 12)}; }
|
|
76
88
|
.oc-sdk-btn[data-variant="destructive"]:hover { background: ${mix('var(--oc-sdk-tone)', 9, bg)}; }
|
|
77
89
|
.oc-sdk-btn[data-variant="destructive"]:active { background: ${mix('var(--oc-sdk-tone)', 11, bg)}; }
|
|
78
90
|
.oc-sdk-btn[data-loading="true"] { opacity: .5; pointer-events: none; }
|
|
@@ -81,11 +93,11 @@ ${tone('success')}${tone('warning')}${tone('error')}${tone('info')}
|
|
|
81
93
|
.oc-sdk-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
|
|
82
94
|
.oc-sdk-field-label { font-size: 0.8125rem; font-weight: 500; }
|
|
83
95
|
.oc-sdk-field-note { font-size: 0.75rem; color: ${muted}; }
|
|
84
|
-
.oc-sdk-field[data-invalid="true"] .oc-sdk-field-note { color: ${
|
|
85
|
-
.oc-sdk-input { display: block; width: 100%; min-width: 0; height: 36px; padding: 0 12px; border: 0; border-radius: ${radius}; background: ${elevated}; color: ${
|
|
96
|
+
.oc-sdk-field[data-invalid="true"] .oc-sdk-field-note { color: ${errorText}; }
|
|
97
|
+
.oc-sdk-input { display: block; width: 100%; min-width: 0; height: 36px; padding: 0 12px; border: 0; border-radius: ${radius}; background: ${elevated}; color: ${elevatedFg}; font-size: 0.875rem; line-height: 1.45; appearance: none; box-shadow: inset 0 0 0 1px ${mix(border, 60)}; transition: background 150ms ease-out, box-shadow 150ms ease-out; }
|
|
86
98
|
textarea.oc-sdk-input { height: auto; padding: 8px 12px; resize: vertical; }
|
|
87
99
|
.oc-sdk-input::placeholder { color: ${muted}; }
|
|
88
|
-
.oc-sdk-input:hover:not(:focus) { background: ${
|
|
100
|
+
.oc-sdk-input:hover:not(:focus) { background-image: linear-gradient(${hover}, ${hover}); }
|
|
89
101
|
.oc-sdk-input:focus, .oc-sdk-input:focus-visible { box-shadow: inset 0 0 0 2px ${focus}; }
|
|
90
102
|
.oc-sdk-field[data-invalid="true"] .oc-sdk-input { box-shadow: inset 0 0 0 1px ${v('status-error', 'red')}; }
|
|
91
103
|
.oc-sdk-field[data-invalid="true"] .oc-sdk-input:focus { box-shadow: inset 0 0 0 2px ${v('status-error', 'red')}; }
|
|
@@ -100,19 +112,19 @@ textarea.oc-sdk-input { height: auto; padding: 8px 12px; resize: vertical; }
|
|
|
100
112
|
.oc-sdk-search-clear:hover { background: ${hover}; color: ${fg}; }
|
|
101
113
|
|
|
102
114
|
.oc-sdk-select { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
|
|
103
|
-
.oc-sdk-trigger { display: inline-flex; align-items: center; gap: 6px; width: 100%; min-width: 0; height: 32px; padding: 0 8px 0 10px; border: 1px solid ${border}; border-radius: 6px; background:
|
|
104
|
-
.oc-sdk-trigger:hover { background: ${hover}; }
|
|
105
|
-
.oc-sdk-trigger[aria-expanded="true"] { background: ${active}; }
|
|
115
|
+
.oc-sdk-trigger { display: inline-flex; align-items: center; gap: 6px; width: 100%; min-width: 0; height: 32px; padding: 0 8px 0 10px; border: 1px solid ${border}; border-radius: 6px; background: ${elevated}; color: ${elevatedFg}; font-size: 0.8125rem; text-align: left; transition: background 150ms ease-out; }
|
|
116
|
+
.oc-sdk-trigger:hover { background-image: linear-gradient(${hover}, ${hover}); }
|
|
117
|
+
.oc-sdk-trigger[aria-expanded="true"] { background-image: linear-gradient(${active}, ${active}); }
|
|
106
118
|
.oc-sdk-trigger-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
107
119
|
.oc-sdk-trigger-value[data-empty="true"] { color: ${muted}; }
|
|
108
120
|
.oc-sdk-trigger-chevron { flex: 0 0 auto; color: ${muted}; }
|
|
109
|
-
.oc-sdk-popup { position: fixed; z-index: 50; display: flex; flex-direction: column; gap: 2px; min-width: 160px; max-width: calc(100vw - 16px); max-height: min(320px, calc(100vh - 16px)); overflow: auto; padding: 4px; border: 1px solid ${mix(border, 60)}; border-radius: 12px; background: ${elevated}; color: ${elevatedFg}; box-shadow: 0 8px 24px ${mix(fg, 12)}; }
|
|
121
|
+
.oc-sdk-popup { --surface-foreground: ${elevatedFg}; position: fixed; z-index: 50; display: flex; flex-direction: column; gap: 2px; min-width: 160px; max-width: calc(100vw - 16px); max-height: min(320px, calc(100vh - 16px)); overflow: auto; padding: 4px; border: 1px solid ${mix(border, 60)}; border-radius: 12px; background: ${elevated}; color: ${elevatedFg}; box-shadow: 0 8px 24px ${mix(fg, 12)}; }
|
|
110
122
|
.oc-sdk-popup-search { flex: 0 0 auto; padding: 2px 2px 4px; }
|
|
111
123
|
.oc-sdk-popup-search .oc-sdk-input { height: 32px; font-size: 0.8125rem; }
|
|
112
124
|
.oc-sdk-option { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 8px; font-size: 0.8125rem; text-align: left; }
|
|
113
125
|
.oc-sdk-option[data-active="true"] { background: ${hover}; }
|
|
114
126
|
.oc-sdk-option[aria-selected="true"] { background: ${selection}; color: ${selectionFg}; }
|
|
115
|
-
.oc-sdk-option[data-destructive="true"] { color: ${
|
|
127
|
+
.oc-sdk-option[data-destructive="true"] { color: ${errorText}; }
|
|
116
128
|
.oc-sdk-option[data-destructive="true"][data-active="true"] { background: ${mix(v('status-error', 'red'), 10)}; }
|
|
117
129
|
.oc-sdk-option-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
118
130
|
.oc-sdk-option-hint { flex: 0 0 auto; font-size: 0.75rem; color: ${muted}; }
|
|
@@ -138,11 +150,11 @@ textarea.oc-sdk-input { height: auto; padding: 8px 12px; resize: vertical; }
|
|
|
138
150
|
.oc-sdk-tabs[data-track="true"] { background: ${mix(fg, 4)}; }
|
|
139
151
|
.oc-sdk-tab { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; font-size: 0.8125rem; font-weight: 500; color: ${muted}; white-space: nowrap; transition: color 150ms ease-out, background 150ms ease-out; }
|
|
140
152
|
.oc-sdk-tab:hover { color: ${fg}; }
|
|
141
|
-
.oc-sdk-tab[aria-selected="true"] { color: ${
|
|
153
|
+
.oc-sdk-tab[aria-selected="true"] { color: ${selectionFg}; background: ${selection}; border-color: ${border}; }
|
|
142
154
|
.oc-sdk-tab-count { font-size: 0.75rem; font-variant-numeric: tabular-nums; color: ${muted}; }
|
|
143
155
|
|
|
144
156
|
.oc-sdk-badge { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 9999px; font-size: 11px; font-weight: 500; line-height: 16px; white-space: nowrap; background: ${hover}; color: ${muted}; }
|
|
145
|
-
.oc-sdk-badge[data-tone] { color: var(--oc-sdk-tone); background: ${mix('var(--oc-sdk-tone)', 15)}; }
|
|
157
|
+
.oc-sdk-badge[data-tone] { color: var(--oc-sdk-tone-text, var(--oc-sdk-tone)); background: ${mix('var(--oc-sdk-tone)', 15)}; }
|
|
146
158
|
|
|
147
159
|
.oc-sdk-list { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
|
|
148
160
|
.oc-sdk-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 6px; text-align: left; transition: background 120ms ease-out; }
|
|
@@ -168,7 +180,7 @@ textarea.oc-sdk-input { height: auto; padding: 8px 12px; resize: vertical; }
|
|
|
168
180
|
|
|
169
181
|
.oc-sdk-banner { display: flex; align-items: flex-start; gap: 12px; padding: 8px 12px; border: 1px solid ${mix('var(--oc-sdk-tone)', 40)}; border-radius: 8px; background: ${mix('var(--oc-sdk-tone)', 10)}; }
|
|
170
182
|
.oc-sdk-banner-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
171
|
-
.oc-sdk-banner-title { font-size: 0.8125rem; font-weight: 500; color: var(--oc-sdk-tone); }
|
|
183
|
+
.oc-sdk-banner-title { font-size: 0.8125rem; font-weight: 500; color: var(--oc-sdk-tone-text, var(--oc-sdk-tone)); }
|
|
172
184
|
.oc-sdk-banner-body { font-size: 0.8125rem; color: ${muted}; }
|
|
173
185
|
.oc-sdk-banner-action { flex: 0 0 auto; }
|
|
174
186
|
|
|
@@ -185,6 +197,6 @@ textarea.oc-sdk-input { height: auto; padding: 8px 12px; resize: vertical; }
|
|
|
185
197
|
.oc-sdk-menu { position: relative; display: inline-flex; }
|
|
186
198
|
|
|
187
199
|
.oc-sdk-text { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
188
|
-
.oc-sdk-text a { color: ${
|
|
200
|
+
.oc-sdk-text a { color: ${primaryText}; text-decoration: underline; text-underline-offset: 2px; }
|
|
189
201
|
.oc-sdk-text img { display: block; max-width: 100%; margin: 8px 0; border-radius: 8px; border: 1px solid ${mix(border, 60)}; }
|
|
190
202
|
`;
|
package/dist/ui/theme.js
CHANGED
|
@@ -14,6 +14,11 @@ const TOKEN_VARS = [
|
|
|
14
14
|
['--oc-active', 'active'],
|
|
15
15
|
['--oc-selection-fg', 'selectionForeground'],
|
|
16
16
|
['--oc-primary-fg', 'primaryForeground'],
|
|
17
|
+
['--oc-primary-text', 'primaryText'],
|
|
18
|
+
['--oc-success-text', 'successText'],
|
|
19
|
+
['--oc-warning-text', 'warningText'],
|
|
20
|
+
['--oc-error-text', 'errorText'],
|
|
21
|
+
['--oc-info-text', 'infoText'],
|
|
17
22
|
['--oc-success', 'success'],
|
|
18
23
|
['--oc-warning', 'warning'],
|
|
19
24
|
['--oc-error', 'error'],
|
|
@@ -36,6 +41,11 @@ const TOKEN_VARS = [
|
|
|
36
41
|
['--interactive-active', 'active'],
|
|
37
42
|
['--interactive-selection-foreground', 'selectionForeground'],
|
|
38
43
|
['--primary-foreground', 'primaryForeground'],
|
|
44
|
+
['--primary-text', 'primaryText'],
|
|
45
|
+
['--success-text', 'successText'],
|
|
46
|
+
['--warning-text', 'warningText'],
|
|
47
|
+
['--error-text', 'errorText'],
|
|
48
|
+
['--info-text', 'infoText'],
|
|
39
49
|
['--status-success', 'success'],
|
|
40
50
|
['--status-warning', 'warning'],
|
|
41
51
|
['--status-error', 'error'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openchamber/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.1",
|
|
4
4
|
"description": "Contract for OpenChamber guests: manifest parse and iframe host bridge.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsc -p tsconfig.build.json",
|
|
37
37
|
"type-check": "tsc --noEmit",
|
|
38
|
-
"lint": "eslint \"./src/**/*.ts\" --config ../../eslint.config.js",
|
|
38
|
+
"lint": "eslint \"./{src,examples}/**/*.ts\" --config ../../eslint.config.js",
|
|
39
39
|
"bundle": "bun scripts/bundle-guest.ts",
|
|
40
40
|
"test": "node ../../scripts/run-isolated-tests.mjs src scripts",
|
|
41
41
|
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\""
|