@konitif/workbench-runtime 0.284.5 → 0.284.6
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/dist/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export * from "./workbench/workbenchToolRuntimeActions.js";
|
|
|
10
10
|
export * from "./workbench/workspaceHistoryController.js";
|
|
11
11
|
export * from "./workbench/workspaceSyncController.js";
|
|
12
12
|
export type { WorkbenchHostEvents, WorkbenchHostEventHandlers, WorkbenchHostStorageChange } from "./workbench/workbenchHostEvents.js";
|
|
13
|
+
export * from "./workbench/experienceTabLink.js";
|
package/dist/index.js
CHANGED
|
@@ -9,3 +9,4 @@ export * from "./workbench/workbenchShellActions.js";
|
|
|
9
9
|
export * from "./workbench/workbenchToolRuntimeActions.js";
|
|
10
10
|
export * from "./workbench/workspaceHistoryController.js";
|
|
11
11
|
export * from "./workbench/workspaceSyncController.js";
|
|
12
|
+
export * from "./workbench/experienceTabLink.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function experienceTabHref(base: string, id: string, screen?: string): string;
|
|
2
|
+
export declare function requestedExperienceFromUrl(base: string): string | null;
|
|
3
|
+
export declare function requestedExperienceScreenFromUrl(base: string, experienceId: string): string | null;
|
|
4
|
+
export interface ExperienceScreenNavigationPort {
|
|
5
|
+
readHref(): string;
|
|
6
|
+
pushHref(href: string): void;
|
|
7
|
+
activate(screenId: string): boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Bind screen navigation to an experience after its workspace has been restored. */
|
|
10
|
+
export declare function createExperienceScreenNavigation(experienceId: string, primaryScreenId: string, port: ExperienceScreenNavigationPort): {
|
|
11
|
+
href: (screenId: string) => string;
|
|
12
|
+
select(screenId: string): boolean;
|
|
13
|
+
restore(): boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const valid = (id) => /^experience\.[a-zA-Z0-9._-]{1,140}$/.test(id);
|
|
2
|
+
const validScreen = (id) => /^[a-z0-9][a-z0-9-]{0,79}$/.test(id);
|
|
3
|
+
export function experienceTabHref(base, id, screen) {
|
|
4
|
+
if (!valid(id))
|
|
5
|
+
throw Error('Référence d’expérience invalide.');
|
|
6
|
+
if (screen !== undefined && !validScreen(screen))
|
|
7
|
+
throw Error('Référence d’écran invalide.');
|
|
8
|
+
const url = new URL(base);
|
|
9
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password)
|
|
10
|
+
throw Error('Adresse Workbench invalide.');
|
|
11
|
+
url.searchParams.set('experience', id);
|
|
12
|
+
if (screen)
|
|
13
|
+
url.searchParams.set('screen', screen);
|
|
14
|
+
else
|
|
15
|
+
url.searchParams.delete('screen');
|
|
16
|
+
url.hash = '';
|
|
17
|
+
return url.href;
|
|
18
|
+
}
|
|
19
|
+
export function requestedExperienceFromUrl(base) {
|
|
20
|
+
const id = new URL(base).searchParams.get('experience');
|
|
21
|
+
return id && valid(id) ? id : null;
|
|
22
|
+
}
|
|
23
|
+
export function requestedExperienceScreenFromUrl(base, experienceId) {
|
|
24
|
+
const url = new URL(base);
|
|
25
|
+
const screen = url.searchParams.get('screen');
|
|
26
|
+
return url.searchParams.get('experience') === experienceId && screen && validScreen(screen) ? screen : null;
|
|
27
|
+
}
|
|
28
|
+
/** Bind screen navigation to an experience after its workspace has been restored. */
|
|
29
|
+
export function createExperienceScreenNavigation(experienceId, primaryScreenId, port) {
|
|
30
|
+
function href(screenId) {
|
|
31
|
+
return experienceTabHref(port.readHref(), experienceId, screenId);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
href,
|
|
35
|
+
select(screenId) {
|
|
36
|
+
if (!validScreen(screenId))
|
|
37
|
+
return false;
|
|
38
|
+
const destination = href(screenId);
|
|
39
|
+
if (!port.activate(screenId))
|
|
40
|
+
return false;
|
|
41
|
+
if (destination !== port.readHref())
|
|
42
|
+
port.pushHref(destination);
|
|
43
|
+
return true;
|
|
44
|
+
},
|
|
45
|
+
restore() {
|
|
46
|
+
const requested = requestedExperienceScreenFromUrl(port.readHref(), experienceId);
|
|
47
|
+
if (requested && port.activate(requested))
|
|
48
|
+
return true;
|
|
49
|
+
return port.activate(primaryScreenId);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konitif/workbench-runtime",
|
|
3
3
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
4
|
-
"version": "0.284.
|
|
4
|
+
"version": "0.284.6",
|
|
5
5
|
"description": "Reactive Svelte host adapter for KONITIF Workbench contracts with explicit runtime ports.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"verify:package": "node scripts/verify-package.mjs"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@konitif/workbench": "0.285.
|
|
45
|
+
"@konitif/workbench": "0.285.16",
|
|
46
46
|
"svelte": "^4.2.18"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|