@flowdrop/flowdrop 2.15.1 → 2.16.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/CHANGELOG.md +69 -0
- package/README.md +4 -0
- package/dist/components/App.svelte +7 -0
- package/dist/components/App.svelte.d.ts +6 -0
- package/dist/components/Input.svelte +2 -2
- package/dist/components/Navbar.svelte +6 -0
- package/dist/components/SchemaForm.svelte +2 -1
- package/dist/components/SchemaForm.svelte.d.ts +2 -1
- package/dist/components/form/FormAutocomplete.svelte +76 -12
- package/dist/components/form/FormFieldset.svelte +5 -3
- package/dist/components/form/FormFieldset.svelte.d.ts +1 -1
- package/dist/components/primitives/Button.svelte +1 -1
- package/dist/components/primitives/Button.svelte.d.ts +1 -1
- package/dist/components/primitives/Card.svelte +1 -1
- package/dist/components/primitives/Card.svelte.d.ts +1 -1
- package/dist/components/primitives/Checkbox.svelte +1 -1
- package/dist/components/primitives/Checkbox.svelte.d.ts +1 -1
- package/dist/components/primitives/Chip.svelte +1 -1
- package/dist/components/primitives/Chip.svelte.d.ts +1 -1
- package/dist/components/primitives/Combobox.svelte +1 -1
- package/dist/components/primitives/Combobox.svelte.d.ts +1 -1
- package/dist/components/primitives/Composer.svelte +1 -1
- package/dist/components/primitives/Composer.svelte.d.ts +1 -1
- package/dist/components/primitives/EmptyState.svelte +1 -1
- package/dist/components/primitives/EmptyState.svelte.d.ts +1 -1
- package/dist/components/primitives/Field.svelte +1 -1
- package/dist/components/primitives/Field.svelte.d.ts +1 -1
- package/dist/components/primitives/IconButton.svelte +1 -1
- package/dist/components/primitives/IconButton.svelte.d.ts +1 -1
- package/dist/components/primitives/Menu.svelte +1 -1
- package/dist/components/primitives/Menu.svelte.d.ts +1 -1
- package/dist/components/primitives/Notice.svelte +1 -1
- package/dist/components/primitives/Notice.svelte.d.ts +1 -1
- package/dist/components/primitives/PanelHeader.svelte +1 -1
- package/dist/components/primitives/PanelHeader.svelte.d.ts +1 -1
- package/dist/components/primitives/Segmented.svelte +2 -2
- package/dist/components/primitives/Segmented.svelte.d.ts +2 -2
- package/dist/components/primitives/Select.svelte +1 -1
- package/dist/components/primitives/Select.svelte.d.ts +1 -1
- package/dist/components/primitives/StatusPill.svelte +1 -1
- package/dist/components/primitives/StatusPill.svelte.d.ts +1 -1
- package/dist/components/primitives/Switch.svelte +1 -1
- package/dist/components/primitives/Switch.svelte.d.ts +1 -1
- package/dist/components/primitives/Tabs.svelte +2 -2
- package/dist/components/primitives/Tabs.svelte.d.ts +2 -2
- package/dist/components/primitives/Toolbar.svelte +1 -1
- package/dist/components/primitives/Toolbar.svelte.d.ts +1 -1
- package/dist/components/primitives/ToolbarSeparator.svelte +1 -1
- package/dist/components/primitives/ToolbarSeparator.svelte.d.ts +1 -1
- package/dist/messages/defaults.d.ts +1 -0
- package/dist/messages/defaults.js +1 -0
- package/dist/openapi/v1/openapi.yaml +10 -2
- package/dist/schemas/v1/workflow.schema.json +1 -1
- package/dist/svelte-app.d.ts +21 -0
- package/dist/svelte-app.js +41 -2
- package/dist/themes/scopedSkinCss.d.ts +22 -0
- package/dist/themes/scopedSkinCss.js +27 -1
- package/dist/types/index.d.ts +11 -1
- package/dist/ui/index.d.ts +76 -0
- package/dist/ui/index.js +81 -0
- package/dist/utils/apiUrl.d.ts +55 -0
- package/dist/utils/apiUrl.js +117 -0
- package/dist/utils/portal.js +45 -3
- package/dist/webmcp/index.d.ts +5 -0
- package/dist/webmcp/index.js +5 -0
- package/package.json +6 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const HAS_SCHEME = /^[a-z][a-z\d+.-]*:/i;
|
|
2
|
+
/**
|
|
3
|
+
* Text the URL parser does not read as written: tab or newline anywhere (it
|
|
4
|
+
* drops them), a control character or space at either end (it trims them), or
|
|
5
|
+
* a backslash in the path (it reads `\` as `/`). With them, ` //host`, `/\host`
|
|
6
|
+
* and `/\t/host` are other hosts and `a\..\x` climbs out of the base.
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line no-control-regex -- matching control characters is the point
|
|
9
|
+
const PARSER_REWRITES = /[\t\n\r]|^[\u0000-\u0020]|[\u0000-\u0020]$/;
|
|
10
|
+
/** A path segment the URL parser treats as `..`, including `%2e` spellings. */
|
|
11
|
+
function isDoubleDot(segment) {
|
|
12
|
+
return segment.replace(/%2e/gi, '.') === '..';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Whether a URL is refused in any form: its text is not what the parser reads
|
|
16
|
+
* (see PARSER_REWRITES).
|
|
17
|
+
*/
|
|
18
|
+
function isAmbiguous(url) {
|
|
19
|
+
return PARSER_REWRITES.test(url) || url.split(/[?#]/, 1)[0].includes('\\');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Whether a no-slash URL is refused: empty, starting with `?` or `#`, or with
|
|
23
|
+
* a `..` path segment (the part before any `?` or `#`; `%2e%2e` counts). `./x`,
|
|
24
|
+
* `a/b` and `a..b` are fine.
|
|
25
|
+
*/
|
|
26
|
+
function isMalformedBaseRelative(url) {
|
|
27
|
+
if (url === '' || url.startsWith('?') || url.startsWith('#'))
|
|
28
|
+
return true;
|
|
29
|
+
const path = url.split(/[?#]/, 1)[0];
|
|
30
|
+
return path.split('/').some(isDoubleDot);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve an autocomplete callback URL from node metadata.
|
|
34
|
+
*
|
|
35
|
+
* The URL's own form says what it is relative to:
|
|
36
|
+
*
|
|
37
|
+
* - `https://host/…` or `//host/…` names its own origin and is used as given.
|
|
38
|
+
* - `/path` is relative to the site and is used as given. A `prefix` (the
|
|
39
|
+
* `baseUrl` prop of `SchemaForm`) is put in front of it, as it always was.
|
|
40
|
+
* - `path` (no leading slash, optionally `./path`) is relative to the API
|
|
41
|
+
* base, so a backend can name its own endpoints without knowing where the
|
|
42
|
+
* editor reaches it, e.g. behind a hub's proxy mount
|
|
43
|
+
* (`secrets/options` under `/api/flowdrop/remotes/r1` →
|
|
44
|
+
* `/api/flowdrop/remotes/r1/secrets/options`). A `prefix` (a `SchemaForm`
|
|
45
|
+
* given a `baseUrl` prop) takes precedence: what the form was given beats
|
|
46
|
+
* the editor's base. With neither it is used as given.
|
|
47
|
+
*
|
|
48
|
+
* The base is treated as a folder: its last segment is kept, so
|
|
49
|
+
* `secrets/options` under `https://site/api/flowdrop` is
|
|
50
|
+
* `https://site/api/flowdrop/secrets/options`. This differs on purpose from
|
|
51
|
+
* `new URL()` and HTML resolution, which would drop `flowdrop`.
|
|
52
|
+
*
|
|
53
|
+
* Refused, the result is `null`: any URL with a tab or newline, a control
|
|
54
|
+
* character or space at either end, or a backslash in its path (the browser
|
|
55
|
+
* would fetch something other than its text says), and a no-slash URL that is
|
|
56
|
+
* empty, starts with `?` or `#`, or contains a `..` path segment (`%2e%2e`
|
|
57
|
+
* included).
|
|
58
|
+
*
|
|
59
|
+
* @param url - The URL from the schema's `autocomplete.url`
|
|
60
|
+
* @param base - The API base (`endpointConfig.baseUrl`), relative or absolute
|
|
61
|
+
* @param prefix - SchemaForm's `baseUrl` prop: goes in front of `/path` URLs,
|
|
62
|
+
* and, when set, is the base for no-slash URLs instead of `base`
|
|
63
|
+
* @returns The URL to fetch, or `null` when the URL is refused
|
|
64
|
+
*/
|
|
65
|
+
export function resolveAutocompleteUrl(url, base, prefix = '') {
|
|
66
|
+
if (isAmbiguous(url))
|
|
67
|
+
return null;
|
|
68
|
+
if (isAbsoluteUrl(url))
|
|
69
|
+
return url;
|
|
70
|
+
if (url.startsWith('/'))
|
|
71
|
+
return `${prefix}${url}`;
|
|
72
|
+
if (isMalformedBaseRelative(url))
|
|
73
|
+
return null;
|
|
74
|
+
const root = (prefix || base || '').replace(/\/+$/, '');
|
|
75
|
+
if (!root)
|
|
76
|
+
return url;
|
|
77
|
+
return `${root}/${url.replace(/^\.\//, '')}`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Whether `url` is written relative to the API base: no scheme, no `//host`,
|
|
81
|
+
* no leading slash (`secrets/options`, `./secrets/options`).
|
|
82
|
+
*/
|
|
83
|
+
export function isBaseRelative(url) {
|
|
84
|
+
return !HAS_SCHEME.test(url) && !url.startsWith('/');
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Whether `url` names its own origin: it has a scheme (`https://…`) or is
|
|
88
|
+
* `//host/…`.
|
|
89
|
+
*/
|
|
90
|
+
export function isAbsoluteUrl(url) {
|
|
91
|
+
return HAS_SCHEME.test(url) || url.startsWith('//');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Whether a request may carry the instance's auth: it goes to the page's own
|
|
95
|
+
* origin, or to the API base's origin under the base path. Decided on the URL
|
|
96
|
+
* the browser actually fetches, not on its text.
|
|
97
|
+
*
|
|
98
|
+
* @param requestUrl - The URL that is fetched
|
|
99
|
+
* @param apiBase - The API base (`endpointConfig.baseUrl`), relative or absolute
|
|
100
|
+
* @param pageUrl - The page's URL (`location.href`); without one (SSR) only an
|
|
101
|
+
* absolute URL under an absolute API base qualifies
|
|
102
|
+
*/
|
|
103
|
+
export function mayCarryInstanceAuth(requestUrl, apiBase, pageUrl) {
|
|
104
|
+
try {
|
|
105
|
+
const target = new URL(requestUrl, pageUrl);
|
|
106
|
+
if (pageUrl && target.origin === new URL(pageUrl).origin)
|
|
107
|
+
return true;
|
|
108
|
+
if (!apiBase)
|
|
109
|
+
return false;
|
|
110
|
+
const root = new URL(`${apiBase.replace(/\/+$/, '')}/`, pageUrl);
|
|
111
|
+
return target.origin === root.origin && target.pathname.startsWith(root.pathname);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// Not parseable against the page (or no page at all): no instance auth.
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
package/dist/utils/portal.js
CHANGED
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
* resolved colour scheme, via the `themeScope` action), since that no longer
|
|
17
17
|
* sits on <html>.
|
|
18
18
|
*
|
|
19
|
+
* Outside an editor, inside a `.flowdrop-scope` element (a host page's wrapper
|
|
20
|
+
* around the `ui` components, or a library component such as SettingsPanel),
|
|
21
|
+
* the node gets the `flowdrop-scope` class, so skin rules keyed on that class
|
|
22
|
+
* still match it. If the nearest such element that sets `data-theme` exists, the
|
|
23
|
+
* node follows its `data-theme`; otherwise it follows the store.
|
|
24
|
+
*
|
|
19
25
|
* Usage: `<div use:portal>…</div>` or `<div use:portal={targetElement}>…</div>`.
|
|
20
26
|
* No-op during SSR (no `document`).
|
|
21
27
|
*/
|
|
@@ -23,10 +29,44 @@ import { themeScope } from './themeScope.svelte.js';
|
|
|
23
29
|
/** Attribute that scopes one editor's skin (on `.flowdrop-root`, copied onto overlays). */
|
|
24
30
|
export const SCOPE_ATTR = 'data-fd-scope';
|
|
25
31
|
export const PORTAL_CLASS = 'flowdrop-portal';
|
|
32
|
+
/** The wrapper a host page puts around `ui` components (carries the skin and `data-theme`). */
|
|
33
|
+
const HOST_SCOPE_CLASS = 'flowdrop-scope';
|
|
26
34
|
export function portal(node, target = undefined) {
|
|
35
|
+
// Read before the move, while the node still sits inside its ancestors.
|
|
36
|
+
const editorScope = node.closest(`[${SCOPE_ATTR}]`);
|
|
37
|
+
// Any `.flowdrop-scope` ancestor gives the overlay the class (and so the
|
|
38
|
+
// host's skin). Only one that sets `data-theme` decides the colour scheme:
|
|
39
|
+
// the library's own standalone components (SettingsPanel, SchemaForm,
|
|
40
|
+
// PlaygroundSurface, …) carry the class without one and follow the store.
|
|
41
|
+
const inHostScope = editorScope === null && node.closest(`.${HOST_SCOPE_CLASS}`) !== null;
|
|
42
|
+
const hostScope = inHostScope
|
|
43
|
+
? node.closest(`.${HOST_SCOPE_CLASS}[data-theme]`)
|
|
44
|
+
: null;
|
|
27
45
|
// The colour scheme is `data-theme` on the editor scope, not on <html>, so
|
|
28
|
-
// an overlay on <body> gets its own (kept in step with the store).
|
|
29
|
-
|
|
46
|
+
// an overlay on <body> gets its own (kept in step with the store). In a host
|
|
47
|
+
// wrapper it is copied from the wrapper instead, and follows its changes.
|
|
48
|
+
let theme;
|
|
49
|
+
if (hostScope) {
|
|
50
|
+
const copy = () => {
|
|
51
|
+
const value = hostScope.getAttribute('data-theme');
|
|
52
|
+
if (value === null)
|
|
53
|
+
node.removeAttribute('data-theme');
|
|
54
|
+
else
|
|
55
|
+
node.setAttribute('data-theme', value);
|
|
56
|
+
};
|
|
57
|
+
copy();
|
|
58
|
+
const observer = new MutationObserver(copy);
|
|
59
|
+
observer.observe(hostScope, { attributes: true, attributeFilter: ['data-theme'] });
|
|
60
|
+
theme = {
|
|
61
|
+
destroy() {
|
|
62
|
+
observer.disconnect();
|
|
63
|
+
node.removeAttribute('data-theme');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
theme = themeScope(node);
|
|
69
|
+
}
|
|
30
70
|
let host = null;
|
|
31
71
|
// Remembered across updates: after the first move the node no longer has the
|
|
32
72
|
// editor as an ancestor to look the scope up on.
|
|
@@ -34,12 +74,14 @@ export function portal(node, target = undefined) {
|
|
|
34
74
|
function mount(to) {
|
|
35
75
|
if (typeof document === 'undefined')
|
|
36
76
|
return;
|
|
37
|
-
scope ??=
|
|
77
|
+
scope ??= editorScope?.getAttribute(SCOPE_ATTR) ?? null;
|
|
38
78
|
host = to ?? document.body;
|
|
39
79
|
host.appendChild(node);
|
|
40
80
|
node.classList.add(PORTAL_CLASS);
|
|
41
81
|
if (scope !== null)
|
|
42
82
|
node.setAttribute(SCOPE_ATTR, scope);
|
|
83
|
+
if (inHostScope)
|
|
84
|
+
node.classList.add(HOST_SCOPE_CLASS);
|
|
43
85
|
}
|
|
44
86
|
mount(target);
|
|
45
87
|
return {
|
package/dist/webmcp/index.d.ts
CHANGED
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
* These are tools for *editing* a workflow in the browser. They are unrelated
|
|
11
11
|
* to the tools a running workflow hands to an LLM node.
|
|
12
12
|
*
|
|
13
|
+
* Experimental in 2.x: names, options and tool shapes may still change in a
|
|
14
|
+
* minor release while WebMCP itself settles (it is behind a browser origin
|
|
15
|
+
* trial). This covers the `webmcp` option of `mountFlowDropApp` too. Pin a
|
|
16
|
+
* minor version (`~2.16.0`) if you depend on it.
|
|
17
|
+
*
|
|
13
18
|
* @module webmcp
|
|
14
19
|
*
|
|
15
20
|
* @example Svelte host
|
package/dist/webmcp/index.js
CHANGED
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
* These are tools for *editing* a workflow in the browser. They are unrelated
|
|
11
11
|
* to the tools a running workflow hands to an LLM node.
|
|
12
12
|
*
|
|
13
|
+
* Experimental in 2.x: names, options and tool shapes may still change in a
|
|
14
|
+
* minor release while WebMCP itself settles (it is behind a browser origin
|
|
15
|
+
* trial). This covers the `webmcp` option of `mountFlowDropApp` too. Pin a
|
|
16
|
+
* minor version (`~2.16.0`) if you depend on it.
|
|
17
|
+
*
|
|
13
18
|
* @module webmcp
|
|
14
19
|
*
|
|
15
20
|
* @example Svelte host
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.16.0",
|
|
7
7
|
"author": "Shibin Das (D34dMan)",
|
|
8
8
|
"bugs": {
|
|
9
9
|
"url": "https://github.com/flowdrop-io/flowdrop/issues"
|
|
@@ -106,6 +106,11 @@
|
|
|
106
106
|
"svelte": "./dist/display/index.js",
|
|
107
107
|
"default": "./dist/display/index.js"
|
|
108
108
|
},
|
|
109
|
+
"./ui": {
|
|
110
|
+
"types": "./dist/ui/index.d.ts",
|
|
111
|
+
"svelte": "./dist/ui/index.js",
|
|
112
|
+
"default": "./dist/ui/index.js"
|
|
113
|
+
},
|
|
109
114
|
"./playground": {
|
|
110
115
|
"types": "./dist/playground/index.d.ts",
|
|
111
116
|
"svelte": "./dist/playground/index.js",
|