@pioneercompany/app-sdk 0.1.0 → 0.1.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/README.md +36 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +62 -1
- package/dist/client/index.js.map +1 -1
- package/dist-cjs/client/index.d.ts +8 -0
- package/dist-cjs/client/index.d.ts.map +1 -1
- package/dist-cjs/client/index.js +62 -1
- package/dist-cjs/client/index.js.map +1 -1
- package/docs/contract.md +36 -0
- package/docs/errors.md +4 -0
- package/docs/publishing.md +52 -25
- package/package.json +1 -1
- package/src/client/index.ts +66 -1
package/README.md
CHANGED
|
@@ -16,6 +16,10 @@ Consumers do not need a token or a custom registry for this public package.
|
|
|
16
16
|
GitHub Actions publishes through npm Trusted Publishing (OIDC), without a stored
|
|
17
17
|
publish secret. First-time package creation and the exact npm trust settings are
|
|
18
18
|
documented in the publishing guide.
|
|
19
|
+
`SDK PR checks` builds and tests pull requests targeting main.
|
|
20
|
+
`Publish SDK to npm` independently builds and publishes the tagged source for
|
|
21
|
+
version tags such as `v0.1.1`. It does not run tests or require PR results.
|
|
22
|
+
Pushes and merges to main do not start either workflow.
|
|
19
23
|
|
|
20
24
|
```ts
|
|
21
25
|
import { connectApp } from '@pioneercompany/app-sdk/client';
|
|
@@ -31,6 +35,38 @@ unsubscribe();
|
|
|
31
35
|
app.dispose();
|
|
32
36
|
```
|
|
33
37
|
|
|
38
|
+
Inside Pioneer Desktop, move the current application view without reloading it:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
await app.view.setPlacement('fullscreen');
|
|
42
|
+
await app.view.setPlacement('bottom');
|
|
43
|
+
await app.view.setPlacement('right');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`fullscreen` fills Pioneer's application area using the expanded placement; it does not change OS window fullscreen. Opening from the Apps
|
|
47
|
+
page starts in this placement. The method works in installed and direct dev
|
|
48
|
+
views on a Desktop version supporting the presentation bridge. It requires no
|
|
49
|
+
backend credentials. Calls resolve after Desktop applies the placement; an
|
|
50
|
+
unavailable host times out after five seconds (`sdk.view_timeout`). At most 16
|
|
51
|
+
calls may be pending per client (`sdk.view_overloaded`); `dispose()` rejects
|
|
52
|
+
remaining calls with `sdk.closed`. Invalid placement rejects with
|
|
53
|
+
`sdk.invalid_placement`; a synchronous transport failure is `sdk.view_unavailable`.
|
|
54
|
+
|
|
55
|
+
To close this application view:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
app.view.close();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This closes the current presentation. The application stays installed and its
|
|
62
|
+
backend remains managed by Gateway, following the Desktop view
|
|
63
|
+
lifecycle. `close()` sends a request and returns `void`: it cannot acknowledge
|
|
64
|
+
completion to a JavaScript context being destroyed. Save state before calling
|
|
65
|
+
it. It throws `sdk.closed` after disposal or `sdk.view_unavailable` on a
|
|
66
|
+
synchronous transport failure. A browser or older Desktop without the bridge
|
|
67
|
+
may ignore the request. `app.dispose()` only releases the SDK client; it does
|
|
68
|
+
not close the view.
|
|
69
|
+
|
|
34
70
|
`connectApp` installs its listener synchronously before its promise is awaited.
|
|
35
71
|
Call it during browser module initialization, before iframe load or the dev
|
|
36
72
|
page's DOMContentLoaded. SSR imports are safe; connecting requires a browser.
|
package/dist/client/index.d.ts
CHANGED
|
@@ -12,7 +12,15 @@ export interface ConnectAppOptions {
|
|
|
12
12
|
/** Exact grant root, absolute or relative to document URL; must end in /. */
|
|
13
13
|
baseUrl?: string;
|
|
14
14
|
}
|
|
15
|
+
/** Fullscreen fills Pioneer's application area, not the operating system screen. */
|
|
16
|
+
export type AppPlacement = "fullscreen" | "bottom" | "right";
|
|
15
17
|
export interface AppClient {
|
|
18
|
+
readonly view: {
|
|
19
|
+
/** Moves this open view without navigating or restarting the application. */
|
|
20
|
+
setPlacement(placement: AppPlacement): Promise<void>;
|
|
21
|
+
/** Requests closing this application view. No acknowledgement. */
|
|
22
|
+
close(): void;
|
|
23
|
+
};
|
|
16
24
|
readonly theme: {
|
|
17
25
|
readonly current: Readonly<Theme> | null;
|
|
18
26
|
/** Delivers current synchronously if known, then future updates. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC;AACD,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;QACzC,oEAAoE;QACpE,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;KACnE,CAAC;IACF,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,+EAA+E;AAC/E,wBAAsB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3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UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,CA+HpF"}
|
package/dist/client/index.js
CHANGED
|
@@ -23,6 +23,13 @@ export async function connectApp(options = {}) {
|
|
|
23
23
|
let disposed = false;
|
|
24
24
|
let current = null;
|
|
25
25
|
const listeners = new Set();
|
|
26
|
+
const pending = new Map();
|
|
27
|
+
// Available even in opaque sandbox origins (no secure-context requirement).
|
|
28
|
+
const requestId = () => Array.from(crypto.getRandomValues(new Uint8Array(16)), byte => byte.toString(16).padStart(2, "0")).join("");
|
|
29
|
+
const postViewRequest = (message) => {
|
|
30
|
+
const direct = window.parent === window;
|
|
31
|
+
window.parent.postMessage(message, direct ? window.location.origin : "*");
|
|
32
|
+
};
|
|
26
33
|
const receive = (event) => {
|
|
27
34
|
if (disposed)
|
|
28
35
|
return;
|
|
@@ -35,6 +42,15 @@ export async function connectApp(options = {}) {
|
|
|
35
42
|
// Embedded origin may be opaque; direct dev views use self + exact origin.
|
|
36
43
|
// A theme message never authenticates a user or a backend request.
|
|
37
44
|
const data = event.data;
|
|
45
|
+
if (data?.type === "pioneer.view.result" && typeof data.id === "string") {
|
|
46
|
+
const call = pending.get(data.id);
|
|
47
|
+
if (call && data.placement === call.placement) {
|
|
48
|
+
pending.delete(data.id);
|
|
49
|
+
clearTimeout(call.timer);
|
|
50
|
+
call.resolve();
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
38
54
|
if (!data || data.type !== "pioneer.theme" || !data.palette)
|
|
39
55
|
return;
|
|
40
56
|
const value = data.palette;
|
|
@@ -74,6 +90,42 @@ export async function connectApp(options = {}) {
|
|
|
74
90
|
return target.href;
|
|
75
91
|
};
|
|
76
92
|
return Object.freeze({
|
|
93
|
+
view: Object.freeze({
|
|
94
|
+
setPlacement(placement) {
|
|
95
|
+
if (disposed)
|
|
96
|
+
return Promise.reject(failure("sdk.closed"));
|
|
97
|
+
if (!["fullscreen", "bottom", "right"].includes(placement))
|
|
98
|
+
return Promise.reject(failure("sdk.invalid_placement"));
|
|
99
|
+
if (pending.size >= 16)
|
|
100
|
+
return Promise.reject(failure("sdk.view_overloaded"));
|
|
101
|
+
const id = requestId();
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
const timer = setTimeout(() => {
|
|
104
|
+
pending.delete(id);
|
|
105
|
+
reject(failure("sdk.view_timeout"));
|
|
106
|
+
}, 5000);
|
|
107
|
+
pending.set(id, { placement, resolve, reject, timer });
|
|
108
|
+
try {
|
|
109
|
+
postViewRequest({ type: "pioneer.view.setPlacement", id, placement });
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
pending.delete(id);
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
reject(failure("sdk.view_unavailable"));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
close() {
|
|
119
|
+
if (disposed)
|
|
120
|
+
throw failure("sdk.closed");
|
|
121
|
+
try {
|
|
122
|
+
postViewRequest({ type: "pioneer.view.close", id: requestId() });
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
throw failure("sdk.view_unavailable");
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
77
129
|
theme: Object.freeze({
|
|
78
130
|
get current() { return current; },
|
|
79
131
|
subscribe(listener) {
|
|
@@ -95,7 +147,16 @@ export async function connectApp(options = {}) {
|
|
|
95
147
|
target.protocol = target.protocol === "https:" ? "wss:" : "ws:";
|
|
96
148
|
return target.href;
|
|
97
149
|
},
|
|
98
|
-
dispose() {
|
|
150
|
+
dispose() {
|
|
151
|
+
disposed = true;
|
|
152
|
+
listeners.clear();
|
|
153
|
+
window.removeEventListener("message", receive);
|
|
154
|
+
for (const call of pending.values()) {
|
|
155
|
+
clearTimeout(call.timer);
|
|
156
|
+
call.reject(failure("sdk.closed"));
|
|
157
|
+
}
|
|
158
|
+
pending.clear();
|
|
159
|
+
},
|
|
99
160
|
});
|
|
100
161
|
}
|
|
101
162
|
//# sourceMappingURL=index.js.map
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAkC3C,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAA6B,EAAE;IAC9D,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACzE,4EAA4E;IAC5E,+EAA+E;IAC/E,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IACjG,IAAI,CAAC,UAAU;QAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACxD,IAAI,IAAS,CAAC;IACd,IAAI,CAAC;QAAC,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAAC,CAAC;IACzD,MAAM,CAAC;QAAC,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAAC,CAAC;IAC3C,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM;QACpG,IAAI,CAAC,QAAQ,I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,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;YAChE,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QACD,OAAO;YACL,QAAQ,GAAG,IAAI,CAAC;YAChB,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC/C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBACpC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACzB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -12,7 +12,15 @@ export interface ConnectAppOptions {
|
|
|
12
12
|
/** Exact grant root, absolute or relative to document URL; must end in /. */
|
|
13
13
|
baseUrl?: string;
|
|
14
14
|
}
|
|
15
|
+
/** Fullscreen fills Pioneer's application area, not the operating system screen. */
|
|
16
|
+
export type AppPlacement = "fullscreen" | "bottom" | "right";
|
|
15
17
|
export interface AppClient {
|
|
18
|
+
readonly view: {
|
|
19
|
+
/** Moves this open view without navigating or restarting the application. */
|
|
20
|
+
setPlacement(placement: AppPlacement): Promise<void>;
|
|
21
|
+
/** Requests closing this application view. No acknowledgement. */
|
|
22
|
+
close(): void;
|
|
23
|
+
};
|
|
16
24
|
readonly theme: {
|
|
17
25
|
readonly current: Readonly<Theme> | null;
|
|
18
26
|
/** Delivers current synchronously if known, then future updates. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings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IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC;AACD,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,oFAAoF;AACpF,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC7D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE;QACb,6EAA6E;QAC7E,YAAY,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,kEAAkE;QAClE,KAAK,IAAI,IAAI,CAAC;KACf,CAAC;IACF,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;QACzC,oEAAoE;QACpE,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;KACnE,CAAC;IACF,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,+EAA+E;AAC/E,wBAAsB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,CA+HpF"}
|
package/dist-cjs/client/index.js
CHANGED
|
@@ -28,6 +28,13 @@ async function connectApp(options = {}) {
|
|
|
28
28
|
let disposed = false;
|
|
29
29
|
let current = null;
|
|
30
30
|
const listeners = new Set();
|
|
31
|
+
const pending = new Map();
|
|
32
|
+
// Available even in opaque sandbox origins (no secure-context requirement).
|
|
33
|
+
const requestId = () => Array.from(crypto.getRandomValues(new Uint8Array(16)), byte => byte.toString(16).padStart(2, "0")).join("");
|
|
34
|
+
const postViewRequest = (message) => {
|
|
35
|
+
const direct = window.parent === window;
|
|
36
|
+
window.parent.postMessage(message, direct ? window.location.origin : "*");
|
|
37
|
+
};
|
|
31
38
|
const receive = (event) => {
|
|
32
39
|
if (disposed)
|
|
33
40
|
return;
|
|
@@ -40,6 +47,15 @@ async function connectApp(options = {}) {
|
|
|
40
47
|
// Embedded origin may be opaque; direct dev views use self + exact origin.
|
|
41
48
|
// A theme message never authenticates a user or a backend request.
|
|
42
49
|
const data = event.data;
|
|
50
|
+
if (data?.type === "pioneer.view.result" && typeof data.id === "string") {
|
|
51
|
+
const call = pending.get(data.id);
|
|
52
|
+
if (call && data.placement === call.placement) {
|
|
53
|
+
pending.delete(data.id);
|
|
54
|
+
clearTimeout(call.timer);
|
|
55
|
+
call.resolve();
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
43
59
|
if (!data || data.type !== "pioneer.theme" || !data.palette)
|
|
44
60
|
return;
|
|
45
61
|
const value = data.palette;
|
|
@@ -79,6 +95,42 @@ async function connectApp(options = {}) {
|
|
|
79
95
|
return target.href;
|
|
80
96
|
};
|
|
81
97
|
return Object.freeze({
|
|
98
|
+
view: Object.freeze({
|
|
99
|
+
setPlacement(placement) {
|
|
100
|
+
if (disposed)
|
|
101
|
+
return Promise.reject((0, error_js_1.failure)("sdk.closed"));
|
|
102
|
+
if (!["fullscreen", "bottom", "right"].includes(placement))
|
|
103
|
+
return Promise.reject((0, error_js_1.failure)("sdk.invalid_placement"));
|
|
104
|
+
if (pending.size >= 16)
|
|
105
|
+
return Promise.reject((0, error_js_1.failure)("sdk.view_overloaded"));
|
|
106
|
+
const id = requestId();
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
const timer = setTimeout(() => {
|
|
109
|
+
pending.delete(id);
|
|
110
|
+
reject((0, error_js_1.failure)("sdk.view_timeout"));
|
|
111
|
+
}, 5000);
|
|
112
|
+
pending.set(id, { placement, resolve, reject, timer });
|
|
113
|
+
try {
|
|
114
|
+
postViewRequest({ type: "pioneer.view.setPlacement", id, placement });
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
pending.delete(id);
|
|
118
|
+
clearTimeout(timer);
|
|
119
|
+
reject((0, error_js_1.failure)("sdk.view_unavailable"));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
close() {
|
|
124
|
+
if (disposed)
|
|
125
|
+
throw (0, error_js_1.failure)("sdk.closed");
|
|
126
|
+
try {
|
|
127
|
+
postViewRequest({ type: "pioneer.view.close", id: requestId() });
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
throw (0, error_js_1.failure)("sdk.view_unavailable");
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
}),
|
|
82
134
|
theme: Object.freeze({
|
|
83
135
|
get current() { return current; },
|
|
84
136
|
subscribe(listener) {
|
|
@@ -100,7 +152,16 @@ async function connectApp(options = {}) {
|
|
|
100
152
|
target.protocol = target.protocol === "https:" ? "wss:" : "ws:";
|
|
101
153
|
return target.href;
|
|
102
154
|
},
|
|
103
|
-
dispose() {
|
|
155
|
+
dispose() {
|
|
156
|
+
disposed = true;
|
|
157
|
+
listeners.clear();
|
|
158
|
+
window.removeEventListener("message", receive);
|
|
159
|
+
for (const call of pending.values()) {
|
|
160
|
+
clearTimeout(call.timer);
|
|
161
|
+
call.reject((0, error_js_1.failure)("sdk.closed"));
|
|
162
|
+
}
|
|
163
|
+
pending.clear();
|
|
164
|
+
},
|
|
104
165
|
});
|
|
105
166
|
}
|
|
106
167
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;
|
|
1
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ChE,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QACD,OAAO;YACL,QAAQ,GAAG,IAAI,CAAC;YAChB,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC/C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBACpC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACzB,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAO,EAAC,YAAY,CAAC,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/docs/contract.md
CHANGED
|
@@ -52,6 +52,42 @@ state/listeners; disposing one leaves another active. Reconnecting after disposa
|
|
|
52
52
|
starts null. No palette is synthesized outside Pioneer. SDK never mutates DOM,
|
|
53
53
|
styles or hydration markup: the application owns state and rendering.
|
|
54
54
|
|
|
55
|
+
## View presentation
|
|
56
|
+
|
|
57
|
+
Desktop exposes a per-WebView presentation bridge, independent of backend Host
|
|
58
|
+
API authority. `view.setPlacement` sends a window message
|
|
59
|
+
`{type:'pioneer.view.setPlacement', id, placement}` to the parent (installed
|
|
60
|
+
iframe) or the same window with its exact origin (direct dev page). Placement
|
|
61
|
+
is exactly `fullscreen`, `bottom` or `right`. Fullscreen fills Pioneer's app area,
|
|
62
|
+
using its existing expanded placement, not OS fullscreen. Apps page opening
|
|
63
|
+
defaults to fullscreen. Changing placement retains the page and its state.
|
|
64
|
+
|
|
65
|
+
`view.close()` sends `{type:'pioneer.view.close', id}` through the same window
|
|
66
|
+
transport. It closes only the current presentation through the existing Desktop
|
|
67
|
+
view-close lifecycle, without uninstalling, deleting data, quitting Desktop
|
|
68
|
+
or explicitly stopping the backend. It returns void and has no acknowledgement,
|
|
69
|
+
because closing destroys the caller's JavaScript context. State should be saved
|
|
70
|
+
before requesting close. An unsupported host may ignore it; synchronous
|
|
71
|
+
transport errors throw `sdk.view_unavailable`, and disposal throws `sdk.closed`.
|
|
72
|
+
|
|
73
|
+
Desktop accepts messages only from its own App iframe or the direct dev page's
|
|
74
|
+
same-origin window. A private per-WebView 128-bit token authenticates the narrow
|
|
75
|
+
native IPC hop; it is not a backend credential and is not passed to the installed
|
|
76
|
+
App iframe. Only setPlacement and close are admitted. The native queue has 32 slots
|
|
77
|
+
and is drained by the existing view publication refresh; revocation drops the
|
|
78
|
+
queue with its WebView.
|
|
79
|
+
|
|
80
|
+
Desktop acknowledges an applied request with
|
|
81
|
+
`{type:'pioneer.view.result', id, placement}` through the parent/self message
|
|
82
|
+
source. The SDK checks that source and (for dev) origin, then matches both ID
|
|
83
|
+
and placement. IDs contain 128 random bits from getRandomValues, including in
|
|
84
|
+
opaque sandbox origins. Calls time out after five seconds, never implicitly
|
|
85
|
+
retry, and have a limit of 16 pending per connection. A timeout leaves the
|
|
86
|
+
outcome unconfirmed; it does not guarantee that Desktop did not move the view.
|
|
87
|
+
Disposal clears timers and rejects pending calls. Older Desktop versions and
|
|
88
|
+
ordinary browsers have no presentation bridge; their calls time out. This
|
|
89
|
+
addition does not change Gateway JSON-RPC or grant the page execution credentials.
|
|
90
|
+
|
|
55
91
|
## Host transport
|
|
56
92
|
|
|
57
93
|
Backend-only WebSocket at bootstrap host_api.endpoint. Authorization: Bearer
|
package/docs/errors.md
CHANGED
|
@@ -17,6 +17,10 @@ host.operation_failed. Applications must tolerate future codes.
|
|
|
17
17
|
| sdk.unauthorized | Missing/invalid proxy credential |
|
|
18
18
|
| sdk.user_missing | No valid trusted principal after authentication |
|
|
19
19
|
| sdk.capability_unavailable | Host API absent or host.pty not advertised |
|
|
20
|
+
| sdk.invalid_placement | Placement is not fullscreen, bottom or right |
|
|
21
|
+
| sdk.view_overloaded | Too many pending view placement requests |
|
|
22
|
+
| sdk.view_timeout | Host placement acknowledgement did not arrive; outcome unconfirmed |
|
|
23
|
+
| sdk.view_unavailable | View message could not be sent |
|
|
20
24
|
| sdk.closed | Handle/context/transport has closed |
|
|
21
25
|
| sdk.capacity | Bounded queue/window/request capacity exceeded |
|
|
22
26
|
| sdk.limit | Input/request/sequence size limit exceeded |
|
package/docs/publishing.md
CHANGED
|
@@ -4,26 +4,53 @@ Source and CI live at https://github.com/pioneerdotai/pioneer-app-sdk-ts.
|
|
|
4
4
|
The package is `@pioneercompany/app-sdk`, published publicly to
|
|
5
5
|
`https://registry.npmjs.org`. Installing it needs no authentication or custom
|
|
6
6
|
registry configuration. The previous local archive used `@pioneer/app-sdk`;
|
|
7
|
-
update imports when switching a consumer to the registry package.
|
|
8
|
-
does not alter Terminal's already installed local archive.
|
|
7
|
+
update imports when switching a consumer to the registry package.
|
|
9
8
|
|
|
10
9
|
## Workflow
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
There are two independent workflows:
|
|
12
|
+
|
|
13
|
+
- **SDK PR checks** (`.github/workflows/ci.yml`) runs only on pull requests
|
|
14
|
+
targeting main. It builds ESM/CJS and runs source tests and built-package
|
|
15
|
+
acceptance tests.
|
|
16
|
+
- **Publish SDK to npm** (`.github/workflows/package.yml`) runs only when a
|
|
17
|
+
release tag such as `v0.1.1` is pushed. It checks out that tag, validates the
|
|
18
|
+
version, installs dependencies from the lockfile, builds ESM/CJS, packs and
|
|
19
|
+
publishes the SDK. It does not run tests or depend on PR checks or artifacts.
|
|
20
|
+
|
|
21
|
+
Pushes and merges to main do not start either workflow. There is no manual
|
|
22
|
+
workflow trigger. The publishing workflow is independent of the PR workflow.
|
|
23
|
+
|
|
24
|
+
Publication uses npm Trusted Publishing through GitHub Actions OIDC, not a
|
|
25
|
+
stored npm token. Only the publish workflow has id-token:write. npm 11.21.0 is installed
|
|
18
26
|
in that job explicitly, and satisfies the OIDC minimum version. No NODE_AUTH_TOKEN,
|
|
19
27
|
NPM_TOKEN, personal GitHub token or GitHub Packages access is needed.
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
The version comes directly from package.json, and the tag must exactly match
|
|
30
|
+
`v` plus that version. Only stable `vX.Y.Z` tags are supported; malformed or
|
|
31
|
+
mismatched tags fail before installing SDK dependencies. There are no generated main versions,
|
|
32
|
+
automatic version commits or automatic Git tags. Both entry points are in the
|
|
33
|
+
same archive, published publicly under npm's `latest` tag. A published version
|
|
34
|
+
cannot be replaced; use a new version and tag for the next release.
|
|
35
|
+
|
|
36
|
+
## Release a version
|
|
37
|
+
|
|
38
|
+
1. Set package.json's version to the next release, for example `0.1.1`, and
|
|
39
|
+
commit that change. Other changes may be merged before releasing.
|
|
40
|
+
2. Tag the desired main commit and push that tag:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
git fetch origin
|
|
44
|
+
git tag v0.1.1 origin/main
|
|
45
|
+
git push origin v0.1.1
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
3. **Publish SDK to npm** validates the version, builds and packs the tagged
|
|
49
|
+
source, then publishes `0.1.1` without running tests.
|
|
50
|
+
Do not move an existing release tag. Rerunning a failed publish can reuse
|
|
51
|
+
the tag if that version has not reached npm; an already published version
|
|
52
|
+
cannot be published again. A rerun uses the workflow from the original tag;
|
|
53
|
+
changes to main do not update an existing tag's workflow.
|
|
27
54
|
|
|
28
55
|
## One-time maintainer setup
|
|
29
56
|
|
|
@@ -41,12 +68,12 @@ retry gets a new attempt suffix. Both entry points are in the same archive.
|
|
|
41
68
|
bun x npm@11.21.0 publish --ignore-scripts --access public --registry=https://registry.npmjs.org
|
|
42
69
|
```
|
|
43
70
|
|
|
44
|
-
Complete the browser/2FA prompts. This creates the initial source version
|
|
45
|
-
|
|
46
|
-
If using an already packed archive, publish that reviewed archive explicitly
|
|
47
|
-
|
|
71
|
+
Complete the browser/2FA prompts. This creates the initial source version.
|
|
72
|
+
Do not create a reusable publish token or store one in GitHub.
|
|
73
|
+
If using an already packed archive, publish that reviewed archive explicitly.
|
|
74
|
+
The first automated release must use a new version and matching tag.
|
|
48
75
|
Skip this step if you already manage this package on npm.
|
|
49
|
-
3. Put
|
|
76
|
+
3. Put both workflow files and the SDK source in the GitHub repository.
|
|
50
77
|
In npmjs.com → app-sdk → Settings → Trusted publishing, add GitHub Actions:
|
|
51
78
|
|
|
52
79
|
| Field | Value |
|
|
@@ -57,20 +84,20 @@ retry gets a new attempt suffix. Both entry points are in the same archive.
|
|
|
57
84
|
| Environment name | Leave empty; this workflow uses no GitHub environment |
|
|
58
85
|
| Allowed actions | Enable direct `npm publish`, not only staging |
|
|
59
86
|
|
|
60
|
-
4.
|
|
87
|
+
4. Push a new release tag, or rerun a failed tag publication, within two days
|
|
61
88
|
after adding the trusted publisher. npm requires a first successful OIDC
|
|
62
89
|
publication in this period to validate the repository identity; if it expires,
|
|
63
|
-
delete and recreate the connection. Once validated, later
|
|
64
|
-
automatically
|
|
90
|
+
delete and recreate the connection. Once validated, later release tags publish
|
|
91
|
+
automatically from their tagged source; main merges start no workflows.
|
|
92
|
+
Changing the publishing workflow filename requires a matching new npm
|
|
65
93
|
trusted publisher configuration.
|
|
66
94
|
5. After successful OIDC publication, set the package's Publishing access to
|
|
67
95
|
**Require two-factor authentication and disallow tokens**. Trusted publishing
|
|
68
96
|
continues to work. Revoke an automation token or remove an NPM_TOKEN secret
|
|
69
97
|
only if one was previously created for this SDK and is no longer used.
|
|
70
98
|
|
|
71
|
-
No repository secrets need to be added.
|
|
72
|
-
|
|
73
|
-
The npm publish credential is short-lived and obtained through OIDC. For a public
|
|
99
|
+
No repository secrets need to be added. The npm publish credential is short-lived
|
|
100
|
+
and obtained through OIDC. For a public
|
|
74
101
|
package from this public repository, npm also generates provenance automatically.
|
|
75
102
|
|
|
76
103
|
## Install
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneercompany/app-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Pioneer application client and Node.js backend SDK",
|
|
5
5
|
"repository": { "type": "git", "url": "git+https://github.com/pioneerdotai/pioneer-app-sdk-ts.git" },
|
|
6
6
|
"homepage": "https://github.com/pioneerdotai/pioneer-app-sdk-ts#readme",
|
package/src/client/index.ts
CHANGED
|
@@ -14,7 +14,15 @@ export interface ConnectAppOptions {
|
|
|
14
14
|
/** Exact grant root, absolute or relative to document URL; must end in /. */
|
|
15
15
|
baseUrl?: string;
|
|
16
16
|
}
|
|
17
|
+
/** Fullscreen fills Pioneer's application area, not the operating system screen. */
|
|
18
|
+
export type AppPlacement = "fullscreen" | "bottom" | "right";
|
|
17
19
|
export interface AppClient {
|
|
20
|
+
readonly view: {
|
|
21
|
+
/** Moves this open view without navigating or restarting the application. */
|
|
22
|
+
setPlacement(placement: AppPlacement): Promise<void>;
|
|
23
|
+
/** Requests closing this application view. No acknowledgement. */
|
|
24
|
+
close(): void;
|
|
25
|
+
};
|
|
18
26
|
readonly theme: {
|
|
19
27
|
readonly current: Readonly<Theme> | null;
|
|
20
28
|
/** Delivers current synchronously if known, then future updates. */
|
|
@@ -42,6 +50,18 @@ export async function connectApp(options: ConnectAppOptions = {}): Promise<AppCl
|
|
|
42
50
|
let disposed = false;
|
|
43
51
|
let current: Readonly<Theme> | null = null;
|
|
44
52
|
const listeners = new Set<(theme: Readonly<Theme>) => void>();
|
|
53
|
+
const pending = new Map<string, {
|
|
54
|
+
placement: AppPlacement;
|
|
55
|
+
resolve: () => void;
|
|
56
|
+
reject: (error: Error) => void;
|
|
57
|
+
timer: ReturnType<typeof setTimeout>;
|
|
58
|
+
}>();
|
|
59
|
+
// Available even in opaque sandbox origins (no secure-context requirement).
|
|
60
|
+
const requestId = () => Array.from(crypto.getRandomValues(new Uint8Array(16)), byte => byte.toString(16).padStart(2, "0")).join("");
|
|
61
|
+
const postViewRequest = (message: { type: string; id: string; placement?: AppPlacement }) => {
|
|
62
|
+
const direct = window.parent === window;
|
|
63
|
+
window.parent.postMessage(message, direct ? window.location.origin : "*");
|
|
64
|
+
};
|
|
45
65
|
const receive = (event: MessageEvent) => {
|
|
46
66
|
if (disposed) return;
|
|
47
67
|
if (window.parent === window) {
|
|
@@ -50,6 +70,15 @@ export async function connectApp(options: ConnectAppOptions = {}): Promise<AppCl
|
|
|
50
70
|
// Embedded origin may be opaque; direct dev views use self + exact origin.
|
|
51
71
|
// A theme message never authenticates a user or a backend request.
|
|
52
72
|
const data = event.data;
|
|
73
|
+
if (data?.type === "pioneer.view.result" && typeof data.id === "string") {
|
|
74
|
+
const call = pending.get(data.id);
|
|
75
|
+
if (call && data.placement === call.placement) {
|
|
76
|
+
pending.delete(data.id);
|
|
77
|
+
clearTimeout(call.timer);
|
|
78
|
+
call.resolve();
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
53
82
|
if (!data || data.type !== "pioneer.theme" || !data.palette) return;
|
|
54
83
|
const value = data.palette;
|
|
55
84
|
if (value.appearance !== "dark" && value.appearance !== "light") return;
|
|
@@ -77,6 +106,33 @@ export async function connectApp(options: ConnectAppOptions = {}): Promise<AppCl
|
|
|
77
106
|
return target.href;
|
|
78
107
|
};
|
|
79
108
|
return Object.freeze({
|
|
109
|
+
view: Object.freeze({
|
|
110
|
+
setPlacement(placement: AppPlacement): Promise<void> {
|
|
111
|
+
if (disposed) return Promise.reject(failure("sdk.closed"));
|
|
112
|
+
if (!["fullscreen", "bottom", "right"].includes(placement)) return Promise.reject(failure("sdk.invalid_placement"));
|
|
113
|
+
if (pending.size >= 16) return Promise.reject(failure("sdk.view_overloaded"));
|
|
114
|
+
const id = requestId();
|
|
115
|
+
return new Promise<void>((resolve, reject) => {
|
|
116
|
+
const timer = setTimeout(() => {
|
|
117
|
+
pending.delete(id);
|
|
118
|
+
reject(failure("sdk.view_timeout"));
|
|
119
|
+
}, 5000);
|
|
120
|
+
pending.set(id, { placement, resolve, reject, timer });
|
|
121
|
+
try {
|
|
122
|
+
postViewRequest({ type: "pioneer.view.setPlacement", id, placement });
|
|
123
|
+
} catch {
|
|
124
|
+
pending.delete(id);
|
|
125
|
+
clearTimeout(timer);
|
|
126
|
+
reject(failure("sdk.view_unavailable"));
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
close(): void {
|
|
131
|
+
if (disposed) throw failure("sdk.closed");
|
|
132
|
+
try { postViewRequest({ type: "pioneer.view.close", id: requestId() }); }
|
|
133
|
+
catch { throw failure("sdk.view_unavailable"); }
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
80
136
|
theme: Object.freeze({
|
|
81
137
|
get current() { return current; },
|
|
82
138
|
subscribe(listener: (theme: Readonly<Theme>) => void) {
|
|
@@ -94,6 +150,15 @@ export async function connectApp(options: ConnectAppOptions = {}): Promise<AppCl
|
|
|
94
150
|
target.protocol = target.protocol === "https:" ? "wss:" : "ws:";
|
|
95
151
|
return target.href;
|
|
96
152
|
},
|
|
97
|
-
dispose() {
|
|
153
|
+
dispose() {
|
|
154
|
+
disposed = true;
|
|
155
|
+
listeners.clear();
|
|
156
|
+
window.removeEventListener("message", receive);
|
|
157
|
+
for (const call of pending.values()) {
|
|
158
|
+
clearTimeout(call.timer);
|
|
159
|
+
call.reject(failure("sdk.closed"));
|
|
160
|
+
}
|
|
161
|
+
pending.clear();
|
|
162
|
+
},
|
|
98
163
|
});
|
|
99
164
|
}
|