@konitif/theme 0.284.2
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/LICENSE.md +21 -0
- package/README.md +56 -0
- package/package.json +56 -0
- package/reference/README.md +10 -0
- package/reference/catalog.json +129 -0
- package/reference/diagrams.json +60 -0
- package/src/ambient/SpatialAmbientCanvas.svelte +148 -0
- package/src/ambient/SpatialAmbientParticles.svelte +89 -0
- package/src/ambient/SpatialAmbientRuntime.svelte +306 -0
- package/src/ambient/SpatialProjectionGrid.svelte +252 -0
- package/src/ambient/shaders/noise.glsl +1 -0
- package/src/ambient/shaders/particleField.glsl +1 -0
- package/src/ambient/shaders/spatialAmbient.frag.glsl +1 -0
- package/src/ambient/shaders/spatialAmbient.vert.glsl +1 -0
- package/src/ambient/shaders/volumetricFog.glsl +1 -0
- package/src/ambient/spatialAmbientStore.ts +3 -0
- package/src/ambient/spatialAmbientTypes.ts +11 -0
- package/src/ambient/spatialProjectionGridModel.ts +276 -0
- package/src/ambient/spatialProjectionGridPresets.ts +152 -0
- package/src/ambient/spatialProjectionGridTypes.ts +72 -0
- package/src/ambient/themeToAmbientUniforms.ts +3 -0
- package/src/components/KonitifBadge.svelte +2 -0
- package/src/components/KonitifButton.svelte +2 -0
- package/src/components/KonitifCard.svelte +2 -0
- package/src/components/KonitifGlassSurface.svelte +3 -0
- package/src/components/KonitifIconFrame.svelte +2 -0
- package/src/components/KonitifPanel.svelte +2 -0
- package/src/depth/SpatialDepthLayer.svelte +49 -0
- package/src/depth/SpatialDepthStack.svelte +25 -0
- package/src/depth/spatialDepthTokens.css +82 -0
- package/src/depth/spatialDepthTypes.ts +79 -0
- package/src/focus/FocusPlaneProvider.svelte +43 -0
- package/src/focus/PerceptualSurface.svelte +146 -0
- package/src/focus/focusDepthMap.ts +33 -0
- package/src/focus/perceptualFocusStore.ts +98 -0
- package/src/focus/perceptualFocusTypes.ts +38 -0
- package/src/focus/usePerceptualFocus.ts +18 -0
- package/src/index.ts +22 -0
- package/src/konitifRuntimePhaseTokens.ts +15 -0
- package/src/konitifTheme.ts +2 -0
- package/src/konitifThemeAdapter.ts +13 -0
- package/src/konitifTokens.css +201 -0
- package/src/konitifWorkbenchThemeRuntime.ts +35 -0
- package/src/runtime/RuntimePhaseTintProvider.svelte +28 -0
- package/src/runtime/runtimePhaseIconMap.ts +1 -0
- package/src/runtime/runtimePhaseVisualMap.ts +37 -0
- package/src/runtime/runtimeSpatialReactivity.ts +307 -0
- package/src/runtime/runtimeSpatialStateStore.ts +53 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { KonitifDepthLevel } from '../focus/perceptualFocusTypes';
|
|
2
|
+
|
|
3
|
+
export type SpatialDepthLayerDefinition = {
|
|
4
|
+
depth: KonitifDepthLevel;
|
|
5
|
+
label: string;
|
|
6
|
+
blur: number;
|
|
7
|
+
opacity: number;
|
|
8
|
+
contrast: number;
|
|
9
|
+
shadow: number;
|
|
10
|
+
parallax: number;
|
|
11
|
+
lightResponse: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const spatialDepthLayers: SpatialDepthLayerDefinition[] = [
|
|
15
|
+
{
|
|
16
|
+
depth: 'ambient',
|
|
17
|
+
label: 'Ambient',
|
|
18
|
+
blur: 1.8,
|
|
19
|
+
opacity: 0.64,
|
|
20
|
+
contrast: 0.88,
|
|
21
|
+
shadow: 0.04,
|
|
22
|
+
parallax: 0,
|
|
23
|
+
lightResponse: 0.22
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
depth: 'background',
|
|
27
|
+
label: 'Background',
|
|
28
|
+
blur: 1.1,
|
|
29
|
+
opacity: 0.74,
|
|
30
|
+
contrast: 0.92,
|
|
31
|
+
shadow: 0.08,
|
|
32
|
+
parallax: 0,
|
|
33
|
+
lightResponse: 0.34
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
depth: 'workspace',
|
|
37
|
+
label: 'Workspace',
|
|
38
|
+
blur: 0.36,
|
|
39
|
+
opacity: 0.92,
|
|
40
|
+
contrast: 0.98,
|
|
41
|
+
shadow: 0.14,
|
|
42
|
+
parallax: 0,
|
|
43
|
+
lightResponse: 0.5
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
depth: 'panel',
|
|
47
|
+
label: 'Panel',
|
|
48
|
+
blur: 0.12,
|
|
49
|
+
opacity: 0.98,
|
|
50
|
+
contrast: 1,
|
|
51
|
+
shadow: 0.2,
|
|
52
|
+
parallax: 0,
|
|
53
|
+
lightResponse: 0.64
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
depth: 'active',
|
|
57
|
+
label: 'Active',
|
|
58
|
+
blur: 0,
|
|
59
|
+
opacity: 1,
|
|
60
|
+
contrast: 1.04,
|
|
61
|
+
shadow: 0.32,
|
|
62
|
+
parallax: 0,
|
|
63
|
+
lightResponse: 0.82
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
depth: 'overlay',
|
|
67
|
+
label: 'Overlay',
|
|
68
|
+
blur: 0,
|
|
69
|
+
opacity: 1,
|
|
70
|
+
contrast: 1.02,
|
|
71
|
+
shadow: 0.4,
|
|
72
|
+
parallax: 0,
|
|
73
|
+
lightResponse: 0.92
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
export function getSpatialDepthLayer(depth: KonitifDepthLevel): SpatialDepthLayerDefinition {
|
|
78
|
+
return spatialDepthLayers.find((layer) => layer.depth === depth) ?? spatialDepthLayers[2];
|
|
79
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from 'svelte';
|
|
3
|
+
import { globalPerceptualFocusStore } from './perceptualFocusStore';
|
|
4
|
+
import { setPerceptualFocusContext } from './usePerceptualFocus';
|
|
5
|
+
import type { PerceptualFocusState, PerceptualFocusStore } from './perceptualFocusTypes';
|
|
6
|
+
|
|
7
|
+
export let store: PerceptualFocusStore = globalPerceptualFocusStore;
|
|
8
|
+
export let enabled = true;
|
|
9
|
+
|
|
10
|
+
const dispatch = createEventDispatcher<{ focuschange: PerceptualFocusState }>();
|
|
11
|
+
setPerceptualFocusContext(store);
|
|
12
|
+
|
|
13
|
+
$: focusState = $store;
|
|
14
|
+
$: dispatch('focuschange', focusState);
|
|
15
|
+
$: focusStyle = [
|
|
16
|
+
`--k-focus-x: ${focusState.focusPoint.x}`,
|
|
17
|
+
`--k-focus-y: ${focusState.focusPoint.y}`,
|
|
18
|
+
`--k-focus-strength: ${enabled ? focusState.focusStrength : 0}`
|
|
19
|
+
].join('; ');
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
class="konitif-focus-plane"
|
|
24
|
+
data-workbench-focus-plane
|
|
25
|
+
data-workbench-focus-enabled={enabled}
|
|
26
|
+
data-workbench-active-surface={focusState.activeSurfaceId ?? undefined}
|
|
27
|
+
data-workbench-active-role={focusState.activeRole ?? undefined}
|
|
28
|
+
data-workbench-active-depth={focusState.activeDepth ?? undefined}
|
|
29
|
+
data-konitif-focus-plane
|
|
30
|
+
data-konitif-focus-enabled={enabled}
|
|
31
|
+
data-konitif-active-surface={focusState.activeSurfaceId ?? undefined}
|
|
32
|
+
data-konitif-active-role={focusState.activeRole ?? undefined}
|
|
33
|
+
data-konitif-active-depth={focusState.activeDepth ?? undefined}
|
|
34
|
+
style={focusStyle}
|
|
35
|
+
>
|
|
36
|
+
<slot />
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
.konitif-focus-plane {
|
|
41
|
+
display: contents;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onDestroy, onMount } from 'svelte';
|
|
3
|
+
import { konitifRoleDefaultDepth, resolveKonitifDepthVisual } from './focusDepthMap';
|
|
4
|
+
import { usePerceptualFocus } from './usePerceptualFocus';
|
|
5
|
+
import type { KonitifDepthLevel, KonitifSurfaceRole } from './perceptualFocusTypes';
|
|
6
|
+
|
|
7
|
+
export let id: string;
|
|
8
|
+
export let role: KonitifSurfaceRole = 'panel';
|
|
9
|
+
export let depth: KonitifDepthLevel | null = null;
|
|
10
|
+
export let active = false;
|
|
11
|
+
export let focusStrength = 1;
|
|
12
|
+
export let interactive = true;
|
|
13
|
+
export let as: keyof HTMLElementTagNameMap = 'div';
|
|
14
|
+
export let ariaRole: string | null = 'group';
|
|
15
|
+
let className = '';
|
|
16
|
+
export { className as class };
|
|
17
|
+
|
|
18
|
+
const focus = usePerceptualFocus();
|
|
19
|
+
|
|
20
|
+
$: resolvedDepth = depth ?? konitifRoleDefaultDepth[role];
|
|
21
|
+
$: depthVisual = resolveKonitifDepthVisual(resolvedDepth);
|
|
22
|
+
$: surfaceStyle = [
|
|
23
|
+
`--k-surface-z: ${depthVisual.zIndex}`,
|
|
24
|
+
`--k-surface-blur: ${depthVisual.blur}px`,
|
|
25
|
+
`--k-surface-opacity: ${depthVisual.opacity}`,
|
|
26
|
+
`--k-surface-contrast: ${depthVisual.contrast}`,
|
|
27
|
+
`--k-surface-shadow: ${depthVisual.shadow}`,
|
|
28
|
+
`--k-surface-parallax: ${depthVisual.parallax}`,
|
|
29
|
+
`--k-surface-light-response: ${depthVisual.lightResponse}`
|
|
30
|
+
].join('; ');
|
|
31
|
+
|
|
32
|
+
function getPoint(event?: MouseEvent | PointerEvent | FocusEvent): PerceptualFocusPoint {
|
|
33
|
+
if (!event || !('currentTarget' in event)) {
|
|
34
|
+
return { x: 0.5, y: 0.42 };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const element = event.currentTarget as HTMLElement | null;
|
|
38
|
+
const rect = element?.getBoundingClientRect();
|
|
39
|
+
|
|
40
|
+
if (!rect || rect.width <= 0 || rect.height <= 0) {
|
|
41
|
+
return { x: 0.5, y: 0.42 };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const clientX = 'clientX' in event ? event.clientX : rect.left + rect.width / 2;
|
|
45
|
+
const clientY = 'clientY' in event ? event.clientY : rect.top + rect.height / 2;
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
x: (clientX - rect.left) / rect.width,
|
|
49
|
+
y: (clientY - rect.top) / rect.height
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function activate(event?: MouseEvent | FocusEvent): void {
|
|
54
|
+
if (!interactive) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
focus.setActiveSurface({
|
|
59
|
+
id,
|
|
60
|
+
role,
|
|
61
|
+
depth: resolvedDepth,
|
|
62
|
+
focusPoint: getPoint(event),
|
|
63
|
+
focusStrength
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onMount(() => {
|
|
68
|
+
focus.registerSurface({ id, role, depth: resolvedDepth });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
onDestroy(() => {
|
|
72
|
+
focus.unregisterSurface(id);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
$: if (active) {
|
|
76
|
+
focus.setActiveSurface({ id, role, depth: resolvedDepth, focusStrength });
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<svelte:element
|
|
81
|
+
this={as}
|
|
82
|
+
{...$$restProps}
|
|
83
|
+
class={`konitif-perceptual-surface workbench-perceptual-surface ${className}`.trim()}
|
|
84
|
+
data-workbench-surface-frame={id}
|
|
85
|
+
data-workbench-surface-role={role}
|
|
86
|
+
data-workbench-surface-depth={resolvedDepth}
|
|
87
|
+
data-workbench-surface-active={active || $focus.activeSurfaceId === id ? 'true' : undefined}
|
|
88
|
+
data-workbench-theme-active={active || $focus.activeSurfaceId === id ? 'true' : undefined}
|
|
89
|
+
data-konitif-surface={id}
|
|
90
|
+
data-konitif-surface-role={role}
|
|
91
|
+
data-konitif-surface-depth={resolvedDepth}
|
|
92
|
+
data-konitif-active={active || $focus.activeSurfaceId === id ? 'true' : undefined}
|
|
93
|
+
role={interactive ? (ariaRole ?? undefined) : undefined}
|
|
94
|
+
style={`${surfaceStyle}; ${$$restProps.style ?? ''}`}
|
|
95
|
+
on:mouseenter={activate}
|
|
96
|
+
on:focusin={activate}
|
|
97
|
+
on:click={activate}
|
|
98
|
+
>
|
|
99
|
+
<slot />
|
|
100
|
+
</svelte:element>
|
|
101
|
+
|
|
102
|
+
<style>
|
|
103
|
+
.konitif-perceptual-surface {
|
|
104
|
+
position: relative;
|
|
105
|
+
z-index: var(--k-surface-z);
|
|
106
|
+
opacity: var(--k-surface-opacity);
|
|
107
|
+
filter: blur(var(--k-surface-blur)) contrast(var(--k-surface-contrast));
|
|
108
|
+
transition:
|
|
109
|
+
box-shadow 280ms ease,
|
|
110
|
+
filter 320ms ease,
|
|
111
|
+
opacity 320ms ease;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.konitif-perceptual-surface::after {
|
|
115
|
+
content: '';
|
|
116
|
+
position: absolute;
|
|
117
|
+
inset: -1px;
|
|
118
|
+
border: 1px solid transparent;
|
|
119
|
+
border-radius: inherit;
|
|
120
|
+
pointer-events: none;
|
|
121
|
+
opacity: 0;
|
|
122
|
+
transition:
|
|
123
|
+
opacity 220ms ease,
|
|
124
|
+
box-shadow 260ms ease;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.konitif-perceptual-surface[data-konitif-active='true'] {
|
|
128
|
+
opacity: 1;
|
|
129
|
+
filter: none;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.konitif-perceptual-surface[data-konitif-active='true']::after {
|
|
133
|
+
border-color: var(--k-border-soft);
|
|
134
|
+
box-shadow:
|
|
135
|
+
0 0 calc(1.6rem * var(--k-surface-light-response)) rgba(var(--k-runtime-tint-rgb, 34, 211, 238), 0.2),
|
|
136
|
+
inset 0 0 0 1px rgba(255, 255, 255, 0.04);
|
|
137
|
+
opacity: calc(0.34 + var(--k-focus-strength, 0) * 0.44);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@media (prefers-reduced-motion: reduce) {
|
|
141
|
+
.konitif-perceptual-surface {
|
|
142
|
+
transform: none;
|
|
143
|
+
transition-duration: 1ms;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { KonitifDepthLevel, KonitifSurfaceRole } from './perceptualFocusTypes';
|
|
2
|
+
|
|
3
|
+
export type KonitifDepthVisual = {
|
|
4
|
+
zIndex: number;
|
|
5
|
+
blur: number;
|
|
6
|
+
opacity: number;
|
|
7
|
+
contrast: number;
|
|
8
|
+
shadow: number;
|
|
9
|
+
parallax: number;
|
|
10
|
+
lightResponse: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const konitifDepthVisualMap = {
|
|
14
|
+
ambient: { zIndex: 0, blur: 1.8, opacity: 0.64, contrast: 0.88, shadow: 0.04, parallax: -0.06, lightResponse: 0.22 },
|
|
15
|
+
background: { zIndex: 1, blur: 1.1, opacity: 0.74, contrast: 0.92, shadow: 0.08, parallax: -0.03, lightResponse: 0.34 },
|
|
16
|
+
workspace: { zIndex: 2, blur: 0.36, opacity: 0.92, contrast: 0.98, shadow: 0.14, parallax: 0, lightResponse: 0.5 },
|
|
17
|
+
panel: { zIndex: 3, blur: 0.12, opacity: 0.98, contrast: 1, shadow: 0.2, parallax: 0.035, lightResponse: 0.64 },
|
|
18
|
+
active: { zIndex: 4, blur: 0, opacity: 1, contrast: 1.04, shadow: 0.32, parallax: 0.06, lightResponse: 0.82 },
|
|
19
|
+
overlay: { zIndex: 5, blur: 0, opacity: 1, contrast: 1.02, shadow: 0.4, parallax: 0.08, lightResponse: 0.92 }
|
|
20
|
+
} satisfies Record<KonitifDepthLevel, KonitifDepthVisual>;
|
|
21
|
+
|
|
22
|
+
export const konitifRoleDefaultDepth = {
|
|
23
|
+
shell: 'workspace',
|
|
24
|
+
panel: 'panel',
|
|
25
|
+
tool: 'workspace',
|
|
26
|
+
overlay: 'overlay',
|
|
27
|
+
inspector: 'active',
|
|
28
|
+
modal: 'overlay'
|
|
29
|
+
} satisfies Record<KonitifSurfaceRole, KonitifDepthLevel>;
|
|
30
|
+
|
|
31
|
+
export function resolveKonitifDepthVisual(depth: KonitifDepthLevel): KonitifDepthVisual {
|
|
32
|
+
return konitifDepthVisualMap[depth] ?? konitifDepthVisualMap.workspace;
|
|
33
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { get, writable } from 'svelte/store';
|
|
2
|
+
import type {
|
|
3
|
+
PerceptualFocusPoint,
|
|
4
|
+
PerceptualFocusState,
|
|
5
|
+
PerceptualFocusStore,
|
|
6
|
+
PerceptualFocusUpdate,
|
|
7
|
+
PerceptualSurfaceRegistration
|
|
8
|
+
} from './perceptualFocusTypes';
|
|
9
|
+
|
|
10
|
+
export const DEFAULT_PERCEPTUAL_FOCUS_STATE: PerceptualFocusState = {
|
|
11
|
+
activeSurfaceId: null,
|
|
12
|
+
activeRole: null,
|
|
13
|
+
activeDepth: null,
|
|
14
|
+
focusPoint: { x: 0.5, y: 0.42 },
|
|
15
|
+
focusStrength: 0
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function clamp01(value: number): number {
|
|
19
|
+
return Math.min(1, Math.max(0, Number.isFinite(value) ? value : 0));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function resolveFocusPoint(focusPoint?: Partial<PerceptualFocusPoint>): PerceptualFocusPoint {
|
|
23
|
+
return {
|
|
24
|
+
x: clamp01(focusPoint?.x ?? DEFAULT_PERCEPTUAL_FOCUS_STATE.focusPoint.x),
|
|
25
|
+
y: clamp01(focusPoint?.y ?? DEFAULT_PERCEPTUAL_FOCUS_STATE.focusPoint.y)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createPerceptualFocusStore(
|
|
30
|
+
initialState: Partial<PerceptualFocusState> = {}
|
|
31
|
+
): PerceptualFocusStore {
|
|
32
|
+
const surfaces = new Map<string, PerceptualSurfaceRegistration>();
|
|
33
|
+
const state = writable<PerceptualFocusState>({
|
|
34
|
+
...DEFAULT_PERCEPTUAL_FOCUS_STATE,
|
|
35
|
+
...initialState,
|
|
36
|
+
focusPoint: resolveFocusPoint(initialState.focusPoint),
|
|
37
|
+
focusStrength: clamp01(initialState.focusStrength ?? DEFAULT_PERCEPTUAL_FOCUS_STATE.focusStrength)
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
subscribe: state.subscribe,
|
|
42
|
+
registerSurface(surface) {
|
|
43
|
+
surfaces.set(surface.id, surface);
|
|
44
|
+
},
|
|
45
|
+
unregisterSurface(surfaceId) {
|
|
46
|
+
surfaces.delete(surfaceId);
|
|
47
|
+
state.update((current) =>
|
|
48
|
+
current.activeSurfaceId === surfaceId
|
|
49
|
+
? { ...DEFAULT_PERCEPTUAL_FOCUS_STATE, focusPoint: current.focusPoint }
|
|
50
|
+
: current
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
setActiveSurface(update: PerceptualFocusUpdate) {
|
|
54
|
+
surfaces.set(update.id, {
|
|
55
|
+
id: update.id,
|
|
56
|
+
role: update.role,
|
|
57
|
+
depth: update.depth
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
state.set({
|
|
61
|
+
activeSurfaceId: update.id,
|
|
62
|
+
activeRole: update.role,
|
|
63
|
+
activeDepth: update.depth,
|
|
64
|
+
focusPoint: resolveFocusPoint(update.focusPoint),
|
|
65
|
+
focusStrength: clamp01(update.focusStrength ?? 1)
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
clearActiveSurface(surfaceId) {
|
|
69
|
+
state.update((current) => {
|
|
70
|
+
if (surfaceId && current.activeSurfaceId !== surfaceId) {
|
|
71
|
+
return current;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
...current,
|
|
76
|
+
activeSurfaceId: null,
|
|
77
|
+
activeRole: null,
|
|
78
|
+
activeDepth: null,
|
|
79
|
+
focusStrength: 0
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
setFocusPoint(focusPoint) {
|
|
84
|
+
state.update((current) => ({
|
|
85
|
+
...current,
|
|
86
|
+
focusPoint: resolveFocusPoint({ ...current.focusPoint, ...focusPoint })
|
|
87
|
+
}));
|
|
88
|
+
},
|
|
89
|
+
getState() {
|
|
90
|
+
return get(state);
|
|
91
|
+
},
|
|
92
|
+
getSurface(surfaceId) {
|
|
93
|
+
return surfaces.get(surfaceId) ?? null;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const globalPerceptualFocusStore = createPerceptualFocusStore();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type KonitifSurfaceRole = 'shell' | 'panel' | 'tool' | 'overlay' | 'inspector' | 'modal';
|
|
2
|
+
|
|
3
|
+
export type KonitifDepthLevel = 'ambient' | 'background' | 'workspace' | 'panel' | 'active' | 'overlay';
|
|
4
|
+
|
|
5
|
+
export type PerceptualFocusPoint = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type PerceptualFocusState = {
|
|
11
|
+
activeSurfaceId: string | null;
|
|
12
|
+
activeRole: KonitifSurfaceRole | null;
|
|
13
|
+
activeDepth: KonitifDepthLevel | null;
|
|
14
|
+
focusPoint: PerceptualFocusPoint;
|
|
15
|
+
focusStrength: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type PerceptualSurfaceRegistration = {
|
|
19
|
+
id: string;
|
|
20
|
+
role: KonitifSurfaceRole;
|
|
21
|
+
depth: KonitifDepthLevel;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type PerceptualFocusUpdate = PerceptualSurfaceRegistration & {
|
|
25
|
+
focusPoint?: Partial<PerceptualFocusPoint>;
|
|
26
|
+
focusStrength?: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type PerceptualFocusStore = {
|
|
30
|
+
subscribe: (run: (state: PerceptualFocusState) => void) => () => void;
|
|
31
|
+
registerSurface: (surface: PerceptualSurfaceRegistration) => void;
|
|
32
|
+
unregisterSurface: (surfaceId: string) => void;
|
|
33
|
+
setActiveSurface: (update: PerceptualFocusUpdate) => void;
|
|
34
|
+
clearActiveSurface: (surfaceId?: string) => void;
|
|
35
|
+
setFocusPoint: (focusPoint: Partial<PerceptualFocusPoint>) => void;
|
|
36
|
+
getState: () => PerceptualFocusState;
|
|
37
|
+
getSurface: (surfaceId: string) => PerceptualSurfaceRegistration | null;
|
|
38
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getContext, hasContext, setContext } from 'svelte';
|
|
2
|
+
import { globalPerceptualFocusStore } from './perceptualFocusStore';
|
|
3
|
+
import type { PerceptualFocusStore } from './perceptualFocusTypes';
|
|
4
|
+
|
|
5
|
+
const PERCEPTUAL_FOCUS_CONTEXT = Symbol('konitif.perceptual-focus');
|
|
6
|
+
|
|
7
|
+
export function setPerceptualFocusContext(store: PerceptualFocusStore): PerceptualFocusStore {
|
|
8
|
+
setContext(PERCEPTUAL_FOCUS_CONTEXT, store);
|
|
9
|
+
return store;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function usePerceptualFocus(): PerceptualFocusStore {
|
|
13
|
+
if (hasContext(PERCEPTUAL_FOCUS_CONTEXT)) {
|
|
14
|
+
return getContext<PerceptualFocusStore>(PERCEPTUAL_FOCUS_CONTEXT);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return globalPerceptualFocusStore;
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from './konitifTheme';
|
|
2
|
+
export * from './konitifWorkbenchThemeRuntime';
|
|
3
|
+
export * from './konitifRuntimePhaseTokens';
|
|
4
|
+
export * from './runtime/runtimePhaseVisualMap';
|
|
5
|
+
export * from './runtime/runtimeSpatialReactivity';
|
|
6
|
+
export * from './runtime/runtimeSpatialStateStore';
|
|
7
|
+
export * from './ambient/spatialProjectionGridModel';
|
|
8
|
+
export * from './ambient/spatialProjectionGridPresets';
|
|
9
|
+
export * from './ambient/spatialProjectionGridTypes';
|
|
10
|
+
export * from './ambient/spatialAmbientTypes';
|
|
11
|
+
export * from './ambient/themeToAmbientUniforms';
|
|
12
|
+
export * from './focus/perceptualFocusTypes';
|
|
13
|
+
export * from './focus/perceptualFocusStore';
|
|
14
|
+
export * from './focus/focusDepthMap';
|
|
15
|
+
export * from './depth/spatialDepthTypes';
|
|
16
|
+
export { default as SpatialAmbientRuntime } from './ambient/SpatialAmbientRuntime.svelte';
|
|
17
|
+
export { default as SpatialProjectionGrid } from './ambient/SpatialProjectionGrid.svelte';
|
|
18
|
+
export { default as KonitifGlassSurface } from './components/KonitifGlassSurface.svelte';
|
|
19
|
+
export { default as FocusPlaneProvider } from './focus/FocusPlaneProvider.svelte';
|
|
20
|
+
export { default as PerceptualSurface } from './focus/PerceptualSurface.svelte';
|
|
21
|
+
export { default as SpatialDepthStack } from './depth/SpatialDepthStack.svelte';
|
|
22
|
+
export { default as SpatialDepthLayer } from './depth/SpatialDepthLayer.svelte';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LaunchPhase } from '@konitif/workbench';
|
|
2
|
+
|
|
3
|
+
export type RuntimePhase = LaunchPhase | 'TEARING_DOWN' | 'RECOVERING';
|
|
4
|
+
|
|
5
|
+
export function normalizeKonitifRuntimePhase(phase: RuntimePhase | string | null | undefined): RuntimePhase {
|
|
6
|
+
if (phase === 'TEARING_DOWN') {
|
|
7
|
+
return 'TEARDOWN';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (phase === 'RECOVERING') {
|
|
11
|
+
return 'RECOVERY';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return (phase || 'LAUNCH_GATE') as RuntimePhase;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { KonitifThemeMode } from './konitifTheme';
|
|
2
|
+
|
|
3
|
+
export function applyKonitifTheme(mode: KonitifThemeMode, target?: HTMLElement | null): void {
|
|
4
|
+
const resolvedTarget = target ?? (typeof document === 'undefined' ? null : document.documentElement);
|
|
5
|
+
|
|
6
|
+
if (!resolvedTarget) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
resolvedTarget.dataset.theme = mode;
|
|
11
|
+
resolvedTarget.dataset.workbenchTheme = 'konitif';
|
|
12
|
+
resolvedTarget.dataset.workbenchColorMode = mode === 'konitif-light' ? 'light' : 'dark';
|
|
13
|
+
}
|