@graphcore/react-kernel 0.0.0 → 0.2.0
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 +202 -0
- package/NOTICE +2 -0
- package/dist/api/agentApi.d.ts +7 -0
- package/dist/api/entityApi.d.ts +37 -0
- package/dist/api/predicate.d.ts +37 -0
- package/dist/auth/oidc.d.ts +39 -0
- package/dist/components/Access/AccessPanel.d.ts +7 -0
- package/dist/components/Access/GroupView.d.ts +1 -0
- package/dist/components/Access/index.d.ts +5 -0
- package/dist/components/Access/useAccess.d.ts +42 -0
- package/dist/components/Admin/AdminPanel.d.ts +22 -0
- package/dist/components/Admin/index.d.ts +3 -0
- package/dist/components/Admin/useIsDeploymentAdmin.d.ts +2 -0
- package/dist/components/AgentMirror/AgentMirror.d.ts +15 -0
- package/dist/components/AgentMirror/index.d.ts +1 -0
- package/dist/components/Auth/AuthPage.d.ts +14 -0
- package/dist/components/Auth/index.d.ts +1 -0
- package/dist/components/Entity/BaseEntity.d.ts +6 -0
- package/dist/components/Entity/EntityRoute.d.ts +14 -0
- package/dist/components/Entity/index.d.ts +2 -0
- package/dist/components/Entity/renderGuard.d.ts +8 -0
- package/dist/components/Entity/types/UIHooks.d.ts +42 -0
- package/dist/components/Entity/types/index.d.ts +6 -0
- package/dist/components/Invite/InviteRoute.d.ts +20 -0
- package/dist/components/Invite/index.d.ts +2 -0
- package/dist/components/Routes/AppRoutes.d.ts +11 -0
- package/dist/components/Routes/GraphCoreApp.d.ts +11 -0
- package/dist/components/Routes/GraphCoreRouter.d.ts +28 -0
- package/dist/components/Routes/pageCollisions.d.ts +12 -0
- package/dist/components/TopBar/TopBar.d.ts +31 -0
- package/dist/components/ViewEntity/CompositeView/CompositeBox.d.ts +5 -0
- package/dist/components/ViewEntity/CompositeView/CompositeHBox.d.ts +2 -0
- package/dist/components/ViewEntity/CompositeView/CompositeTabs.d.ts +2 -0
- package/dist/components/ViewEntity/CompositeView/CompositeVBox.d.ts +2 -0
- package/dist/components/ViewEntity/CompositeView/index.d.ts +8 -0
- package/dist/components/ViewEntity/CompositeView/panels.d.ts +30 -0
- package/dist/components/ViewEntity/EntityAttributes/EntityAttributesView.d.ts +2 -0
- package/dist/components/ViewEntity/EntityAttributes/index.d.ts +2 -0
- package/dist/components/ViewEntity/EntityIDE/EntityExplorer.d.ts +29 -0
- package/dist/components/ViewEntity/EntityIDE/EntityIDE.d.ts +15 -0
- package/dist/components/ViewEntity/EntityIDE/index.d.ts +1 -0
- package/dist/components/ViewEntity/ListEntity/ListView.d.ts +6 -0
- package/dist/components/ViewEntity/ViewGallery/ViewGallery.d.ts +2 -0
- package/dist/components/common/EntityPicker.d.ts +15 -0
- package/dist/components/common/ErrorBoundary.d.ts +15 -0
- package/dist/components/common/ForbiddenGhost.d.ts +9 -0
- package/dist/components/common/Notification.d.ts +9 -0
- package/dist/components/common/ViewTypePicker.d.ts +10 -0
- package/dist/graphcore-react-kernel.cjs.js +3 -0
- package/dist/graphcore-react-kernel.es.js +7946 -0
- package/dist/hooks/useAuth.d.ts +14 -0
- package/dist/hooks/useEntities.d.ts +6 -0
- package/dist/hooks/useServerRoutes.d.ts +8 -0
- package/dist/hooks/useWebSocketConsumer.d.ts +15 -0
- package/dist/index.d.ts +2 -0
- package/dist/lib/GraphCoreProvider.d.ts +43 -0
- package/dist/lib/index.d.ts +57 -0
- package/dist/lib/runtimeConfig.d.ts +22 -0
- package/dist/pages/definePage.d.ts +31 -0
- package/dist/registry/EntityIcon.d.ts +12 -0
- package/dist/registry/baseViews.d.ts +2 -0
- package/dist/registry/entityTypeIds.d.ts +16 -0
- package/dist/registry/registry-context.d.ts +3 -0
- package/dist/registry/viewRegistry.d.ts +25 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/state/accessEvents.d.ts +4 -0
- package/dist/state/authStore.d.ts +14 -0
- package/dist/state/deploymentStore.d.ts +3 -0
- package/dist/state/entityGraph/entityAccessors.d.ts +8 -0
- package/dist/state/entityGraph/entityGraph.d.ts +7 -0
- package/dist/state/entityGraph/hooks.d.ts +5 -0
- package/dist/state/entityGraph/index.d.ts +5 -0
- package/dist/state/entityGraph/store.d.ts +14 -0
- package/dist/state/entityGraph/types.d.ts +47 -0
- package/dist/state/graphCoreBridge/StrategyError.d.ts +11 -0
- package/dist/state/graphCoreBridge/bridge-context.d.ts +4 -0
- package/dist/state/graphCoreBridge/bridge.d.ts +3 -0
- package/dist/state/graphCoreBridge/hooks.d.ts +4 -0
- package/dist/state/graphCoreBridge/statusStore.d.ts +4 -0
- package/dist/state/graphCoreBridge/types.d.ts +29 -0
- package/dist/state/notificationStore.d.ts +15 -0
- package/dist/state/registryDirectoryStore.d.ts +14 -0
- package/dist/state/resyncEvents.d.ts +6 -0
- package/dist/state/useEntityQuery.d.ts +23 -0
- package/dist/state/views/viewScopes.d.ts +11 -0
- package/dist/style.css +2 -0
- package/dist/utils/StrategyRequestBuilder.d.ts +198 -0
- package/dist/utils/dragDropInterface.d.ts +81 -0
- package/dist/utils/entityPath.d.ts +14 -0
- package/dist/views/EntityView.d.ts +15 -0
- package/dist/views/ViewContext.d.ts +13 -0
- package/dist/views/defineView.d.ts +45 -0
- package/dist/views/position.d.ts +24 -0
- package/dist/views/useEntityTypeIds.d.ts +2 -0
- package/dist/views/useViewState.d.ts +22 -0
- package/package.json +71 -5
- package/README.md +0 -3
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
export namespace StrategyRequests {
|
|
2
|
+
/**
|
|
3
|
+
* Create a builder instance
|
|
4
|
+
*/
|
|
5
|
+
function builder(): StrategyRequestBuilder;
|
|
6
|
+
function createGrant(resourceId: any, subjectId: any, roleName: any): {
|
|
7
|
+
strategy_name: string;
|
|
8
|
+
target_entity_id: any;
|
|
9
|
+
param_config: {};
|
|
10
|
+
};
|
|
11
|
+
function changeGrantRole(grantId: any, roleName: any): {
|
|
12
|
+
strategy_name: string;
|
|
13
|
+
target_entity_id: any;
|
|
14
|
+
param_config: {};
|
|
15
|
+
};
|
|
16
|
+
function revokeGrant(grantId: any): {
|
|
17
|
+
strategy_name: string;
|
|
18
|
+
target_entity_id: any;
|
|
19
|
+
param_config: {};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Set attributes on an entity
|
|
23
|
+
* @param {string|number} entityId - Target entity ID
|
|
24
|
+
* @param {Object} attributes - Key-value pairs of attributes to set
|
|
25
|
+
*/
|
|
26
|
+
function setAttributes(entityId: string | number, attributes: any): {
|
|
27
|
+
strategy_name: string;
|
|
28
|
+
target_entity_id: any;
|
|
29
|
+
param_config: {};
|
|
30
|
+
};
|
|
31
|
+
function removeAttribute(entityId: any, attributeName: any): {
|
|
32
|
+
strategy_name: string;
|
|
33
|
+
target_entity_id: any;
|
|
34
|
+
param_config: {};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Request to create a new entity
|
|
38
|
+
* @param {string|number|null} parentId - Parent entity ID (the target), or null for the top level
|
|
39
|
+
* @param {string} entityTypeId - Entity type ID (e.g., 'graphcore.View')
|
|
40
|
+
* @param {Object} initialAttributes - Initial attributes for the new entity
|
|
41
|
+
* @param {string} entityUuid - Optional custom UUID for the entity
|
|
42
|
+
*/
|
|
43
|
+
function createEntity(parentId: string | number | null, entityTypeId: string, initialAttributes?: any, entityUuid?: string): {
|
|
44
|
+
strategy_name: string;
|
|
45
|
+
target_entity_id: any;
|
|
46
|
+
param_config: {};
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Create a group with the caller as its first member: under `parentId`,
|
|
50
|
+
* or at the top level when it is null. `key` and `adminManaged` are for
|
|
51
|
+
* deployment administrators only.
|
|
52
|
+
*/
|
|
53
|
+
function createGroup(name: any, { parentId, key, adminManaged }?: {
|
|
54
|
+
parentId?: any;
|
|
55
|
+
key?: any;
|
|
56
|
+
adminManaged?: boolean;
|
|
57
|
+
}): {
|
|
58
|
+
strategy_name: string;
|
|
59
|
+
target_entity_id: any;
|
|
60
|
+
param_config: {};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Set the groups and deployment roles every new user receives.
|
|
64
|
+
* @param {string} deploymentId - The deployment entity (`useDeploymentEntityId`)
|
|
65
|
+
*/
|
|
66
|
+
function setNewUserDefaults(deploymentId: string, groupIds: any, roles: any): {
|
|
67
|
+
strategy_name: string;
|
|
68
|
+
target_entity_id: any;
|
|
69
|
+
param_config: {};
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Hide an entity
|
|
73
|
+
*/
|
|
74
|
+
function hideEntity(entityId: any, hide?: boolean): {
|
|
75
|
+
strategy_name: string;
|
|
76
|
+
target_entity_id: any;
|
|
77
|
+
param_config: {};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Delete an entity
|
|
81
|
+
*/
|
|
82
|
+
function deleteEntity(entityId: any): {
|
|
83
|
+
strategy_name: string;
|
|
84
|
+
target_entity_id: any;
|
|
85
|
+
param_config: {};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Merge `state` into a view. Targeted at the view when it exists;
|
|
89
|
+
* otherwise `position` (`client`, `address` or `view`, `placement`) names
|
|
90
|
+
* where it sits, and the backend creates it. A null value in `state`
|
|
91
|
+
* removes that key.
|
|
92
|
+
* @param {string|null} viewId - The view, or null to name it by position
|
|
93
|
+
* @param {{position?: Object, state: Object, component?: string|null}} params
|
|
94
|
+
*/
|
|
95
|
+
function setViewState(viewId: string | null, { position, state, component }?: {
|
|
96
|
+
position?: any;
|
|
97
|
+
state: any;
|
|
98
|
+
component?: string | null;
|
|
99
|
+
}): {
|
|
100
|
+
strategy_name: string;
|
|
101
|
+
target_entity_id: any;
|
|
102
|
+
param_config: {};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Create a view in `parentId`, or at the top level with no parent.
|
|
106
|
+
* @param {string|null} parentId
|
|
107
|
+
* @param {{renders?: string|null, component?: string|null, state?: Object}} params
|
|
108
|
+
*/
|
|
109
|
+
function createView(parentId: string | null, { renders, component, state }?: {
|
|
110
|
+
renders?: string | null;
|
|
111
|
+
component?: string | null;
|
|
112
|
+
state?: any;
|
|
113
|
+
}): {
|
|
114
|
+
strategy_name: string;
|
|
115
|
+
target_entity_id: any;
|
|
116
|
+
param_config: {};
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Move an entity to a new parent
|
|
120
|
+
* @param {string|number} childId - Entity to reparent
|
|
121
|
+
* @param {string|number} parentId - New parent entity ID
|
|
122
|
+
*/
|
|
123
|
+
function reparentChild(childId: string | number, parentId: string | number): {
|
|
124
|
+
strategy_name: string;
|
|
125
|
+
target_entity_id: any;
|
|
126
|
+
param_config: {};
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Detach an entity from its parent
|
|
130
|
+
* @param {string|number} childId - Entity to detach
|
|
131
|
+
*/
|
|
132
|
+
function detachChild(childId: string | number): {
|
|
133
|
+
strategy_name: string;
|
|
134
|
+
target_entity_id: any;
|
|
135
|
+
param_config: {};
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Move an existing entity before another sibling under the same parent
|
|
139
|
+
* @param {string} childId - Entity to reposition
|
|
140
|
+
* @param {string} beforeChildId - Anchor sibling that should follow childId
|
|
141
|
+
*/
|
|
142
|
+
function moveChildBefore(childId: string, beforeChildId: string): {
|
|
143
|
+
strategy_name: string;
|
|
144
|
+
target_entity_id: any;
|
|
145
|
+
param_config: {};
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Move an existing entity after another sibling under the same parent
|
|
149
|
+
* @param {string} childId - Entity to reposition
|
|
150
|
+
* @param {string} afterChildId - Anchor sibling that should precede childId
|
|
151
|
+
*/
|
|
152
|
+
function moveChildAfter(childId: string, afterChildId: string): {
|
|
153
|
+
strategy_name: string;
|
|
154
|
+
target_entity_id: any;
|
|
155
|
+
param_config: {};
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export default StrategyRequests;
|
|
159
|
+
/**
|
|
160
|
+
* StrategyRequestBuilder - A utility class for constructing strategy requests
|
|
161
|
+
*
|
|
162
|
+
* This builder provides a fluent interface for creating strategy request objects
|
|
163
|
+
* that can be sent through the WebSocket connection.
|
|
164
|
+
*/
|
|
165
|
+
declare class StrategyRequestBuilder {
|
|
166
|
+
/**
|
|
167
|
+
* Reset the builder to its initial state
|
|
168
|
+
*/
|
|
169
|
+
reset(): this;
|
|
170
|
+
request: {
|
|
171
|
+
strategy_name: string;
|
|
172
|
+
target_entity_id: any;
|
|
173
|
+
param_config: {};
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Set the strategy name
|
|
177
|
+
* @param {string} name - Name of the strategy to execute
|
|
178
|
+
*/
|
|
179
|
+
withStrategyName(name: string): this;
|
|
180
|
+
/**
|
|
181
|
+
* Set the target entity ID
|
|
182
|
+
* @param {string|number} entityId - ID of the entity to target
|
|
183
|
+
*/
|
|
184
|
+
withTargetEntity(entityId: string | number): this;
|
|
185
|
+
/**
|
|
186
|
+
* Add parameters to the param_config object
|
|
187
|
+
* @param {Object} params - Key-value pairs to add to param_config
|
|
188
|
+
*/
|
|
189
|
+
withParams(params: any): this;
|
|
190
|
+
/**
|
|
191
|
+
* Build and return the strategy request object
|
|
192
|
+
*/
|
|
193
|
+
build(): {
|
|
194
|
+
strategy_name: string;
|
|
195
|
+
target_entity_id: any;
|
|
196
|
+
param_config: {};
|
|
197
|
+
};
|
|
198
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export declare const DRAG_TYPES: {
|
|
3
|
+
readonly ENTITY_ID: "application/x-entity-id";
|
|
4
|
+
readonly ENTITY_DATA: "application/x-entity-data";
|
|
5
|
+
readonly SOURCE_CONTEXT: "application/x-source-context";
|
|
6
|
+
};
|
|
7
|
+
export declare const DRAG_EFFECTS: {
|
|
8
|
+
readonly MOVE: "move";
|
|
9
|
+
readonly COPY: "copy";
|
|
10
|
+
readonly LINK: "link";
|
|
11
|
+
};
|
|
12
|
+
export interface EntityDragData {
|
|
13
|
+
entityId: string;
|
|
14
|
+
entityType?: string;
|
|
15
|
+
sourceContext?: string;
|
|
16
|
+
sourceParentId?: string;
|
|
17
|
+
customData?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
export interface DropZoneConfig {
|
|
20
|
+
acceptedTypes?: string[];
|
|
21
|
+
dropEffect?: 'move' | 'copy' | 'link';
|
|
22
|
+
onDrop: (data: EntityDragData) => void;
|
|
23
|
+
onDragOver?: (event: DragEvent) => void;
|
|
24
|
+
onDragEnter?: (event: DragEvent) => void;
|
|
25
|
+
onDragLeave?: (event: DragEvent) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Utility class for standardized drag and drop operations
|
|
29
|
+
*/
|
|
30
|
+
export declare class EntityDragDropUtil {
|
|
31
|
+
/**
|
|
32
|
+
* Start dragging an entity with standardized data
|
|
33
|
+
*/
|
|
34
|
+
static startDrag(event: React.DragEvent, dragData: EntityDragData, options?: {
|
|
35
|
+
dragEffect?: 'move' | 'copy' | 'link';
|
|
36
|
+
dragImage?: HTMLElement;
|
|
37
|
+
dragImageText?: string;
|
|
38
|
+
}): void;
|
|
39
|
+
/**
|
|
40
|
+
* Handle drop with standardized data extraction
|
|
41
|
+
*/
|
|
42
|
+
static handleDrop(event: React.DragEvent, onDrop: (data: EntityDragData) => void): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Setup standard drag over handler
|
|
45
|
+
*/
|
|
46
|
+
static handleDragOver(event: React.DragEvent, options?: {
|
|
47
|
+
dropEffect?: 'move' | 'copy' | 'link';
|
|
48
|
+
acceptedTypes?: string[];
|
|
49
|
+
}): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Create a custom drag image with text
|
|
52
|
+
*/
|
|
53
|
+
private static createDragImage;
|
|
54
|
+
/**
|
|
55
|
+
* Check if drag data contains a valid entity ID
|
|
56
|
+
*/
|
|
57
|
+
static hasValidEntityData(event: React.DragEvent): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Get entity ID from drag data without full parsing
|
|
60
|
+
*/
|
|
61
|
+
static getEntityId(event: React.DragEvent): string | null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* React hook for easy drag and drop setup
|
|
65
|
+
*/
|
|
66
|
+
export declare function useDragDrop(config: DropZoneConfig): {
|
|
67
|
+
onDragOver: (event: React.DragEvent) => void;
|
|
68
|
+
onDrop: (event: React.DragEvent) => void;
|
|
69
|
+
onDragEnter: (event: React.DragEvent) => void;
|
|
70
|
+
onDragLeave: (event: React.DragEvent) => void;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Higher-order component to make any entity draggable
|
|
74
|
+
*/
|
|
75
|
+
export declare function makeDraggable<T extends {
|
|
76
|
+
entityId: string;
|
|
77
|
+
}>(Component: React.ComponentType<T>, options?: {
|
|
78
|
+
getDragData?: (props: T) => EntityDragData;
|
|
79
|
+
dragEffect?: 'move' | 'copy' | 'link';
|
|
80
|
+
dragImageText?: (props: T) => string;
|
|
81
|
+
}): (props: T) => React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-app routes for entities. An identifier `gc://<backend_id>/<local_id>`
|
|
3
|
+
* lives at `/e/<backend_id>/<local_id>`: both segments are lowercase
|
|
4
|
+
* base32, so the path needs no encoding and reads like the identifier.
|
|
5
|
+
* These are the only places the frontend translates between the two.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ENTITY_ROUTE = "e/:backend_id/:local_id";
|
|
8
|
+
export declare function entityPath(entityId: string): string;
|
|
9
|
+
export declare function entityIdFromParams(params: {
|
|
10
|
+
backend_id?: string;
|
|
11
|
+
local_id?: string;
|
|
12
|
+
}): string | null;
|
|
13
|
+
/** The identifier embedded in a pasted path or string, if any. */
|
|
14
|
+
export declare function findEntityId(text: string): string | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface EntityViewProps {
|
|
3
|
+
entityId: string | null | undefined;
|
|
4
|
+
/** Tells apart two placements of the same entity at the same position. */
|
|
5
|
+
slot?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Renders an entity with the view chosen for this placement: the component
|
|
10
|
+
* stored in its view, else its type's `defaultFor` view, else `BaseEntity`.
|
|
11
|
+
* A view renders as itself: its component over the entity it shows, with
|
|
12
|
+
* everything inside it stored in it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function EntityView({ entityId, slot, className }: EntityViewProps): React.JSX.Element;
|
|
15
|
+
export default EntityView;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Entity } from '../state/entityGraph/types';
|
|
2
|
+
import { ViewPosition } from './position';
|
|
3
|
+
export interface ViewContextValue {
|
|
4
|
+
/** Where the enclosing view sits; null when nothing can be stored (signed out). */
|
|
5
|
+
position: ViewPosition | null;
|
|
6
|
+
/** The stored view: undefined while looking it up, null when none exists yet. */
|
|
7
|
+
view: Entity | null | undefined;
|
|
8
|
+
/** Set by `RouteScope`: the next placement is this view itself instead of a step below it. */
|
|
9
|
+
route?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const ViewContext: import('react').Context<ViewContextValue>;
|
|
12
|
+
/** The enclosing placement's context; with none, the current page's. */
|
|
13
|
+
export declare function useViewContext(): ViewContextValue | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ViewPosition } from './position';
|
|
3
|
+
export interface ViewProps {
|
|
4
|
+
/** The entity this placement shows, if any. */
|
|
5
|
+
entityId?: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface PlacementProps extends ViewProps {
|
|
8
|
+
/** Tells apart two placements of this view showing the same entity at the same position. */
|
|
9
|
+
slot?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ViewOptions {
|
|
12
|
+
/** Entity types this view renders when nothing else is chosen. */
|
|
13
|
+
defaultFor?: string[];
|
|
14
|
+
/** The view is an app's entry point. */
|
|
15
|
+
entry?: boolean;
|
|
16
|
+
/** Name shown to people; defaults to the view name without its app prefix, in words. */
|
|
17
|
+
label?: string;
|
|
18
|
+
}
|
|
19
|
+
export type DefinedView<P extends object = {}> = React.FC<P & PlacementProps> & {
|
|
20
|
+
readonly viewName: string;
|
|
21
|
+
readonly defaultFor: readonly string[];
|
|
22
|
+
readonly entry: boolean;
|
|
23
|
+
readonly label: string;
|
|
24
|
+
/** The undecorated component, rendered by `EntityView` at its own step. */
|
|
25
|
+
readonly Component: React.ComponentType<P & ViewProps>;
|
|
26
|
+
};
|
|
27
|
+
/** Where a placement of `name` sits inside the enclosing `ViewContext`; null with none. */
|
|
28
|
+
export declare function usePlacement(name: string, entityId?: string | null): ViewPosition | null;
|
|
29
|
+
/** Provides the `ViewContext` of the view at `position` to `children`. */
|
|
30
|
+
export declare function PositionScope({ position, children }: {
|
|
31
|
+
position: ViewPosition | null;
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
}): React.JSX.Element;
|
|
34
|
+
/** Makes a route's one main view the page's view itself rather than a step below it. */
|
|
35
|
+
export declare function RouteScope({ address, children }: {
|
|
36
|
+
address: string;
|
|
37
|
+
children: React.ReactNode;
|
|
38
|
+
}): React.JSX.Element;
|
|
39
|
+
/**
|
|
40
|
+
* Declare a view component. The result renders as ordinary JSX, stores its
|
|
41
|
+
* state in its own view one step below the enclosing one (slot `slot ?? name`,
|
|
42
|
+
* showing `entityId`), and is registered by name when an app's entry exports it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function defineView<P extends object = {}>(name: string, Component: React.ComponentType<P & ViewProps>, options?: ViewOptions): DefinedView<P>;
|
|
45
|
+
export declare function isDefinedView(value: unknown): value is DefinedView<any>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a view sits: a client, a start (a page's address or a view's id),
|
|
3
|
+
* and the placement below it, sent to `SetViewState` as plain
|
|
4
|
+
* parameters (docs/VIEW_ENTITY_TDD.md).
|
|
5
|
+
*/
|
|
6
|
+
export declare const WEB_CLIENT = "web";
|
|
7
|
+
export declare const MAX_STEPS = 64;
|
|
8
|
+
export interface Step {
|
|
9
|
+
slot: string;
|
|
10
|
+
renders: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface ViewPosition {
|
|
13
|
+
client: string;
|
|
14
|
+
/** Exactly one of `address` and `view` is set. */
|
|
15
|
+
address?: string;
|
|
16
|
+
view?: string;
|
|
17
|
+
placement: Step[];
|
|
18
|
+
}
|
|
19
|
+
/** `pathname` in the form the server stores, or null when it is not an address. */
|
|
20
|
+
export declare function normalizeAddress(pathname: string): string | null;
|
|
21
|
+
export declare function pagePosition(address: string, client?: string): ViewPosition | null;
|
|
22
|
+
export declare function viewPosition(viewId: string, client?: string): ViewPosition;
|
|
23
|
+
export declare function childPosition(position: ViewPosition, slot: string, renders?: string | null): ViewPosition;
|
|
24
|
+
export declare function toParams(position: ViewPosition): Record<string, unknown>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type CreateView = (params?: {
|
|
2
|
+
renders?: string | null;
|
|
3
|
+
component?: string | null;
|
|
4
|
+
state?: Record<string, any>;
|
|
5
|
+
}) => Promise<string | null>;
|
|
6
|
+
export type ViewStateUpdate<S> = (patch: Partial<{
|
|
7
|
+
[K in keyof S]: S[K] | null;
|
|
8
|
+
}>, component?: string | null) => Promise<{
|
|
9
|
+
view_entity_id?: string;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* The enclosing view's state over `defaults`, and an `update` that stores a
|
|
13
|
+
* shallow patch (a null value removes the key). State changes only when the
|
|
14
|
+
* stored view does; a refused update shows the error toast and leaves it as
|
|
15
|
+
* it was.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useViewState<S extends Record<string, any>>(defaults: S): [S, ViewStateUpdate<S>];
|
|
18
|
+
/**
|
|
19
|
+
* Creates a top-level view owned by the user and resolves to its id, or
|
|
20
|
+
* null when refused (the error toast is already shown).
|
|
21
|
+
*/
|
|
22
|
+
export declare function useCreateView(): CreateView;
|
package/package.json
CHANGED
|
@@ -1,9 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcore/react-kernel",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "GraphCore React frontend \u2014 EntityView, WebSocket plumbing, and view registry for building GraphCore-powered applications.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"repository": {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/graphcore-org/graphcore.git",
|
|
9
|
+
"directory": "kernel/react_frontend"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/graphcore-react-kernel.cjs.js",
|
|
12
|
+
"module": "./dist/graphcore-react-kernel.es.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/graphcore-react-kernel.es.js",
|
|
18
|
+
"require": "./dist/graphcore-react-kernel.cjs.js"
|
|
19
|
+
},
|
|
20
|
+
"./style.css": "./dist/style.css"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/graphcore-react-kernel.es.js",
|
|
24
|
+
"dist/graphcore-react-kernel.cjs.js",
|
|
25
|
+
"dist/style.css",
|
|
26
|
+
"dist/**/*.d.ts",
|
|
27
|
+
"NOTICE"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": [
|
|
30
|
+
"**/*.css"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "rm -rf dist && vite build",
|
|
34
|
+
"build:watch": "vite build --watch --emptyOutDir=false",
|
|
35
|
+
"test": "jest",
|
|
36
|
+
"typecheck": "tsc --noEmit"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": ">=19.0.0",
|
|
40
|
+
"react-dom": ">=19.0.0",
|
|
41
|
+
"react-router-dom": ">=7.0.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"oidc-client-ts": "^3.5.0",
|
|
45
|
+
"react-icons": "^5.5.0",
|
|
46
|
+
"zustand": "^5.0.13"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@babel/core": "^7.28.0",
|
|
50
|
+
"@babel/preset-env": "^7.28.0",
|
|
51
|
+
"@babel/preset-react": "^7.27.1",
|
|
52
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
53
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
54
|
+
"@testing-library/react": "^16.3.0",
|
|
55
|
+
"@types/jest": "^30.0.0",
|
|
56
|
+
"@types/node": "^22.15.29",
|
|
57
|
+
"@types/react": "^19.2.14",
|
|
58
|
+
"@types/react-dom": "^19.2.3",
|
|
59
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
60
|
+
"babel-jest": "^29.7.0",
|
|
61
|
+
"identity-obj-proxy": "^3.0.0",
|
|
62
|
+
"jest": "^29.7.0",
|
|
63
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
64
|
+
"react": "^19.2.5",
|
|
65
|
+
"react-dom": "^19.2.5",
|
|
66
|
+
"react-router-dom": "^7.7.1",
|
|
67
|
+
"tailwindcss": "^4.3.3",
|
|
68
|
+
"typescript": "^5.9.3",
|
|
69
|
+
"vite": "^8.3.4",
|
|
70
|
+
"vite-plugin-dts": "^4.5.4"
|
|
71
|
+
},
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public"
|
|
74
|
+
}
|
|
9
75
|
}
|
package/README.md
DELETED