@skillcdn/console 0.4.5 → 0.4.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/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +23 -12
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +8 -1
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +10 -2
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +17 -5
- package/dist/cli/help.js.map +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/components/plugin-frame.d.ts.map +1 -1
- package/dist/components/plugin-frame.js +25 -12
- package/dist/components/plugin-frame.js.map +1 -1
- package/dist/plugin/bridge.d.ts +4 -3
- package/dist/plugin/bridge.d.ts.map +1 -1
- package/dist/plugin/bridge.js.map +1 -1
- package/dist/plugin/context.d.ts +7 -1
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/web.d.ts +16 -3
- package/dist/plugin/web.d.ts.map +1 -1
- package/dist/plugin/web.js +8 -1
- package/dist/plugin/web.js.map +1 -1
- package/docs/specs/cli.md +2 -2
- package/docs/specs/plugins.md +22 -10
- package/docs/specs/rest.md +3 -3
- package/package.json +1 -1
- package/skills/building-a-plugin/SKILL.md +2 -2
- package/src/cli/cli.ts +34 -14
- package/src/cli/format.ts +14 -2
- package/src/cli/help.ts +17 -5
- package/src/client.ts +4 -0
- package/src/components/plugin-frame.tsx +25 -12
- package/src/plugin/bridge.ts +4 -3
- package/src/plugin/context.ts +7 -1
- package/src/plugin/web.ts +21 -4
package/src/plugin/web.ts
CHANGED
|
@@ -51,6 +51,13 @@ export interface FrameWindow {
|
|
|
51
51
|
};
|
|
52
52
|
addEventListener(type: "message", listener: (event: FrameMessageEvent) => void): void;
|
|
53
53
|
removeEventListener(type: "message", listener: (event: FrameMessageEvent) => void): void;
|
|
54
|
+
/**
|
|
55
|
+
* The browser's own way to open a window, which it holds to a press in the frame (ADR-0078).
|
|
56
|
+
* A frame of a console before 0.4.6 has one too, whose sandbox lets it open nothing.
|
|
57
|
+
*/
|
|
58
|
+
open?(url: string, target: string, features: string): unknown;
|
|
59
|
+
/** The browser's word on whether a person pressed something in this frame a moment ago, where it has one. */
|
|
60
|
+
readonly navigator?: { readonly userActivation?: { readonly isActive: boolean } };
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
/** As much of `document` as the bridge uses. */
|
|
@@ -124,9 +131,11 @@ export interface PluginFrame {
|
|
|
124
131
|
/** The console's page follows a path of the console's in place; a URL is refused. */
|
|
125
132
|
navigate(path: string): void;
|
|
126
133
|
/**
|
|
127
|
-
*
|
|
128
|
-
* person pressed:
|
|
129
|
-
*
|
|
134
|
+
* Opens a web or a mail address in a new tab, with no opener and no referrer, for a link a
|
|
135
|
+
* person pressed (ADR-0067, ADR-0078): the browser opens it for a press in the frame and for
|
|
136
|
+
* nothing else, one window a press, so call it from the press itself; without a recent press
|
|
137
|
+
* it is refused, where the browser can say so. Anything else, a path of the console's included,
|
|
138
|
+
* is refused; `navigate` takes those. Needs a console from 0.4.6, whose frames may open a window.
|
|
130
139
|
*/
|
|
131
140
|
open(url: string): void;
|
|
132
141
|
/** The console's page downloads a file of this plugin. */
|
|
@@ -365,7 +374,15 @@ export function connect(options: ConnectOptions = {}): Promise<PluginFrame> {
|
|
|
365
374
|
"open takes a web or a mail address; navigate takes a path of the console's",
|
|
366
375
|
});
|
|
367
376
|
}
|
|
368
|
-
|
|
377
|
+
// The browser holds the frame to a press in it (ADR-0078), and says so where it can.
|
|
378
|
+
if (win.navigator?.userActivation?.isActive === false) {
|
|
379
|
+
throw new PluginBridgeError({
|
|
380
|
+
code: "plugin.forbidden",
|
|
381
|
+
message:
|
|
382
|
+
"open opens a link right after a person pressed in the frame, and not otherwise",
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
win.open?.(url, "_blank", "noopener,noreferrer");
|
|
369
386
|
},
|
|
370
387
|
download: (id) => post({ v: PLUGIN_BRIDGE_VERSION, t: "download", id }),
|
|
371
388
|
setTitle: (text) => {
|