@forgeax/app-shell 0.10.0 → 0.11.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/dist/window.d.ts +31 -0
- package/dist/window.js +57 -0
- package/package.json +6 -2
package/dist/window.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type SurfacePane = 'left' | 'center';
|
|
2
|
+
type SurfaceKind = 'plugin' | 'panel';
|
|
3
|
+
/** Structural identity shared by in-window and detached surface carriers. */
|
|
4
|
+
interface SurfaceDescriptor {
|
|
5
|
+
readonly kind: SurfaceKind;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly pane?: SurfacePane;
|
|
8
|
+
readonly instance?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Complete carrier-neutral declaration for opening one detached surface. */
|
|
11
|
+
interface DetachedWindowTarget {
|
|
12
|
+
readonly surface: SurfaceDescriptor;
|
|
13
|
+
readonly title: string;
|
|
14
|
+
readonly width: number;
|
|
15
|
+
readonly height: number;
|
|
16
|
+
readonly dockBehavior: 'close' | 'keep-anchor';
|
|
17
|
+
}
|
|
18
|
+
/** Presence of this factory declares that a surface may be detached. */
|
|
19
|
+
interface DetachedWindowCapability<Context = void> {
|
|
20
|
+
createTarget(context: Context): DetachedWindowTarget;
|
|
21
|
+
}
|
|
22
|
+
/** Stable identity shared by keep-alive registries and physical carriers. */
|
|
23
|
+
declare function surfaceKey(surface: SurfaceDescriptor): string;
|
|
24
|
+
/** Deterministic, injective and carrier-safe label for the complete identity. */
|
|
25
|
+
declare function surfaceWindowLabel(surface: SurfaceDescriptor): string;
|
|
26
|
+
/** Encode only structural surface identity; product carrier policy stays outside. */
|
|
27
|
+
declare function encodeSurfaceQuery(surface: SurfaceDescriptor): string;
|
|
28
|
+
/** Decode structural identity, or null for a normal shell/invalid entry. */
|
|
29
|
+
declare function decodeSurfaceFromLocation(search?: string): SurfaceDescriptor | null;
|
|
30
|
+
|
|
31
|
+
export { type DetachedWindowCapability, type DetachedWindowTarget, type SurfaceDescriptor, type SurfaceKind, type SurfacePane, decodeSurfaceFromLocation, encodeSurfaceQuery, surfaceKey, surfaceWindowLabel };
|
package/dist/window.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/window.ts
|
|
2
|
+
function surfaceKey(surface) {
|
|
3
|
+
return JSON.stringify([
|
|
4
|
+
surface.kind,
|
|
5
|
+
surface.id,
|
|
6
|
+
surface.pane ?? null,
|
|
7
|
+
surface.instance ?? null
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
var BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
11
|
+
function utf8ToBase64Url(value) {
|
|
12
|
+
const bytes = new TextEncoder().encode(value);
|
|
13
|
+
let encoded = "";
|
|
14
|
+
for (let index = 0; index < bytes.length; index += 3) {
|
|
15
|
+
const first = bytes[index];
|
|
16
|
+
const second = bytes[index + 1];
|
|
17
|
+
const third = bytes[index + 2];
|
|
18
|
+
encoded += BASE64URL_ALPHABET[first >> 2];
|
|
19
|
+
encoded += BASE64URL_ALPHABET[(first & 3) << 4 | (second ?? 0) >> 4];
|
|
20
|
+
if (second !== void 0) {
|
|
21
|
+
encoded += BASE64URL_ALPHABET[(second & 15) << 2 | (third ?? 0) >> 6];
|
|
22
|
+
}
|
|
23
|
+
if (third !== void 0) encoded += BASE64URL_ALPHABET[third & 63];
|
|
24
|
+
}
|
|
25
|
+
return encoded;
|
|
26
|
+
}
|
|
27
|
+
function surfaceWindowLabel(surface) {
|
|
28
|
+
return `fx-surface-${utf8ToBase64Url(surfaceKey(surface))}`;
|
|
29
|
+
}
|
|
30
|
+
function encodeSurfaceQuery(surface) {
|
|
31
|
+
const params = new URLSearchParams();
|
|
32
|
+
params.set("surface", surface.kind);
|
|
33
|
+
params.set("id", surface.id);
|
|
34
|
+
if (surface.pane) params.set("pane", surface.pane);
|
|
35
|
+
if (surface.instance !== void 0) params.set("instance", surface.instance);
|
|
36
|
+
return params.toString();
|
|
37
|
+
}
|
|
38
|
+
function decodeSurfaceFromLocation(search = typeof window !== "undefined" ? window.location.search : "") {
|
|
39
|
+
const params = new URLSearchParams(search);
|
|
40
|
+
const kind = params.get("surface");
|
|
41
|
+
const id = params.get("id");
|
|
42
|
+
if (!id || kind !== "plugin" && kind !== "panel") return null;
|
|
43
|
+
const pane = params.get("pane");
|
|
44
|
+
const instance = params.get("instance");
|
|
45
|
+
return {
|
|
46
|
+
kind,
|
|
47
|
+
id,
|
|
48
|
+
pane: pane === "left" || pane === "center" ? pane : void 0,
|
|
49
|
+
instance: instance ?? void 0
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
decodeSurfaceFromLocation,
|
|
54
|
+
encodeSurfaceQuery,
|
|
55
|
+
surfaceKey,
|
|
56
|
+
surfaceWindowLabel
|
|
57
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeax/app-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Generic Dock, Panel, Window, and Slot composition primitives",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"types": "./dist/dock.d.ts",
|
|
18
18
|
"import": "./dist/dock.js"
|
|
19
19
|
},
|
|
20
|
+
"./window": {
|
|
21
|
+
"types": "./dist/window.d.ts",
|
|
22
|
+
"import": "./dist/window.js"
|
|
23
|
+
},
|
|
20
24
|
"./react": {
|
|
21
25
|
"types": "./dist/react.d.ts",
|
|
22
26
|
"import": "./dist/react.js"
|
|
@@ -27,7 +31,7 @@
|
|
|
27
31
|
"scripts": {
|
|
28
32
|
"typecheck": "tsc --noEmit",
|
|
29
33
|
"test": "bun test test",
|
|
30
|
-
"build": "tsup src/index.ts src/dock.ts src/react.tsx --format esm --dts --outDir dist && bun run scripts/copy-resize-css.ts && bun run scripts/copy-panel-css.ts",
|
|
34
|
+
"build": "tsup src/index.ts src/dock.ts src/window.ts src/react.tsx --format esm --dts --outDir dist && bun run scripts/copy-resize-css.ts && bun run scripts/copy-panel-css.ts",
|
|
31
35
|
"check": "bun run typecheck && bun run test && bun run build",
|
|
32
36
|
"release:preflight": "bun run scripts/release-preflight.ts"
|
|
33
37
|
},
|