@picked/svelte 0.0.1-dev.1789541668638 → 0.0.1-dev.1793756239746
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/LICENSE +1 -0
- package/README.md +51 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/_virtual/_vite/preload-helper.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/experience/ExperienceHost.svelte +29 -13
- package/dist/experience/ExperienceSlot.svelte +21 -3
- package/dist/experience/ExperienceWrapper.svelte +23 -0
- package/dist/form/index.js +1 -1
- package/dist/hooks/action.d.ts +47 -18
- package/dist/hooks/action.js +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/step.d.ts +14 -0
- package/dist/hooks/step.js +1 -1
- package/dist/plugins/devtools/DevToolsExperience.svelte +545 -203
- package/dist/plugins/devtools/components/AdaptedToolHost.svelte +2 -2
- package/dist/plugins/devtools/constants.d.ts +5 -0
- package/dist/plugins/devtools/constants.js +1 -0
- package/dist/plugins/devtools/customTools.d.ts +42 -6
- package/dist/plugins/devtools/customTools.js +1 -1
- package/dist/plugins/devtools/derive/answer-display/answer-display.d.ts +112 -0
- package/dist/plugins/devtools/derive/answer-display/answer-display.js +1 -0
- package/dist/plugins/devtools/derive/answer-display/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/answer-display/index.js +1 -0
- package/dist/plugins/devtools/derive/answer-history/answer-history.d.ts +76 -0
- package/dist/plugins/devtools/derive/answer-history/answer-history.js +1 -0
- package/dist/plugins/devtools/derive/answer-history/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/answer-history/index.js +1 -0
- package/dist/plugins/devtools/derive/guide-sections/guide-sections.d.ts +67 -0
- package/dist/plugins/devtools/derive/guide-sections/guide-sections.js +1 -0
- package/dist/plugins/devtools/derive/guide-sections/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/guide-sections/index.js +1 -0
- package/dist/plugins/devtools/derive/index.d.ts +28 -0
- package/dist/plugins/devtools/derive/index.js +1 -0
- package/dist/plugins/devtools/derive/journey-outline/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/journey-outline/index.js +1 -0
- package/dist/plugins/devtools/derive/journey-outline/journey-outline.d.ts +86 -0
- package/dist/plugins/devtools/derive/journey-outline/journey-outline.js +1 -0
- package/dist/plugins/devtools/derive/journey-pick/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/journey-pick/index.js +1 -0
- package/dist/plugins/devtools/derive/journey-pick/journey-pick.d.ts +73 -0
- package/dist/plugins/devtools/derive/journey-pick/journey-pick.js +1 -0
- package/dist/plugins/devtools/derive/journey-timeline/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/journey-timeline/index.js +1 -0
- package/dist/plugins/devtools/derive/journey-timeline/journey-timeline.d.ts +70 -0
- package/dist/plugins/devtools/derive/journey-timeline/journey-timeline.js +1 -0
- package/dist/plugins/devtools/derive/journey-tree/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/journey-tree/index.js +1 -0
- package/dist/plugins/devtools/derive/journey-tree/journey-tree.d.ts +191 -0
- package/dist/plugins/devtools/derive/journey-tree/journey-tree.js +1 -0
- package/dist/plugins/devtools/derive/plain-language/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/plain-language/index.js +1 -0
- package/dist/plugins/devtools/derive/plain-language/plain-language.d.ts +73 -0
- package/dist/plugins/devtools/derive/plain-language/plain-language.js +1 -0
- package/dist/plugins/devtools/derive/plain-logic/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/plain-logic/index.js +1 -0
- package/dist/plugins/devtools/derive/plain-logic/plain-logic.d.ts +48 -0
- package/dist/plugins/devtools/derive/plain-logic/plain-logic.js +1 -0
- package/dist/plugins/devtools/derive/safety-posture/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/safety-posture/index.js +1 -0
- package/dist/plugins/devtools/derive/safety-posture/safety-posture.d.ts +43 -0
- package/dist/plugins/devtools/derive/safety-posture/safety-posture.js +1 -0
- package/dist/plugins/devtools/derive/visited-steps/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/visited-steps/index.js +1 -0
- package/dist/plugins/devtools/derive/visited-steps/visited-steps.d.ts +35 -0
- package/dist/plugins/devtools/derive/visited-steps/visited-steps.js +1 -0
- package/dist/plugins/devtools/derive/walk-route/index.d.ts +3 -0
- package/dist/plugins/devtools/derive/walk-route/index.js +1 -0
- package/dist/plugins/devtools/derive/walk-route/walk-route.d.ts +22 -0
- package/dist/plugins/devtools/derive/walk-route/walk-route.js +1 -0
- package/dist/plugins/devtools/index.d.ts +5 -2
- package/dist/plugins/devtools/index.js +1 -1
- package/dist/plugins/devtools/launcher/Launcher.svelte +150 -0
- package/dist/plugins/devtools/launcher/launcher.d.ts +36 -0
- package/dist/plugins/devtools/launcher/launcher.js +1 -0
- package/dist/plugins/devtools/options.d.ts +106 -0
- package/dist/plugins/devtools/options.js +1 -0
- package/dist/plugins/devtools/plugin.d.ts +8 -8
- package/dist/plugins/devtools/plugin.js +1 -1
- package/dist/plugins/devtools/posture-context.d.ts +15 -0
- package/dist/plugins/devtools/posture-context.js +1 -0
- package/dist/plugins/devtools/review/answers/AnswersPanel.svelte +526 -0
- package/dist/plugins/devtools/review/guide/GuideLine.svelte +20 -0
- package/dist/plugins/devtools/review/guide/GuidePanel.svelte +133 -0
- package/dist/plugins/devtools/review/index.d.ts +6 -0
- package/dist/plugins/devtools/review/index.js +1 -0
- package/dist/plugins/devtools/review/journey/JourneyMap.svelte +1078 -0
- package/dist/plugins/devtools/review/journey/JourneyPanel.svelte +608 -0
- package/dist/plugins/devtools/review/journey/JourneyTimeline.svelte +756 -0
- package/dist/plugins/devtools/review/journey/TimelineMarker.svelte +59 -0
- package/dist/plugins/devtools/review/session/SessionPanel.svelte +214 -0
- package/dist/plugins/devtools/review/variations/VariationsPanel.svelte +279 -0
- package/dist/plugins/devtools/screens/config/ConfigScreen.svelte +6 -0
- package/dist/plugins/devtools/screens/custom-tools/CustomToolsScreen.svelte +3 -3
- package/dist/plugins/devtools/screens/responses/ResponseTableRow.svelte +6 -0
- package/dist/plugins/devtools/session/index.d.ts +3 -0
- package/dist/plugins/devtools/session/index.js +1 -0
- package/dist/plugins/devtools/session/session.d.ts +90 -0
- package/dist/plugins/devtools/session/session.js +1 -0
- package/dist/plugins/devtools/session-access.d.ts +32 -0
- package/dist/plugins/devtools/session-access.js +1 -0
- package/dist/plugins/devtools/sidebar/Sidebar.svelte +105 -0
- package/dist/plugins/devtools/sidebar/SidebarRow.svelte +117 -0
- package/dist/plugins/devtools/sidebar/nav.d.ts +105 -0
- package/dist/plugins/devtools/sidebar/nav.js +1 -0
- package/dist/plugins/devtools/ui/actions/Button.svelte +10 -1
- package/dist/plugins/devtools/ui/actions/CopyButton.svelte +13 -1
- package/dist/plugins/devtools/ui/data/Badge.svelte +3 -2
- package/dist/plugins/devtools/ui/data/EmptyState.svelte +16 -1
- package/dist/plugins/devtools/ui/feedback/Banner.svelte +3 -2
- package/dist/plugins/framework/index.js +1 -1
- package/dist/render/browser.js +1 -1
- package/package.json +23 -12
- package/dist/form/__tests__/CreateFormHarness.svelte +0 -30
- package/dist/hooks/events.d.ts +0 -2
- package/dist/hooks/events.js +0 -1
- package/dist/vite-env.d.js +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/** @file The floating Picked button that opens the devtools panel, in a chosen corner. */
|
|
3
|
+
import PickedIcon from '../PickedIcon.svelte'
|
|
4
|
+
import type { LauncherPosition } from '../options'
|
|
5
|
+
import { launcherEdges } from './launcher'
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
/** The corner the button sits in. */
|
|
9
|
+
position: LauncherPosition
|
|
10
|
+
/** When `true`, the button slides against its side edge until hovered or focused. */
|
|
11
|
+
autoHide: boolean
|
|
12
|
+
/** The tag beside the button: a preview session, a preview whose workspace is gone, or none. */
|
|
13
|
+
preview: 'preview' | 'unavailable' | null
|
|
14
|
+
/** Opens the panel. */
|
|
15
|
+
onOpen: () => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { position, autoHide, preview, onOpen }: Props = $props()
|
|
19
|
+
|
|
20
|
+
const edges = $derived(launcherEdges(position))
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div
|
|
24
|
+
class="launcher {edges.vertical} {edges.side}"
|
|
25
|
+
class:auto-hide={autoHide}
|
|
26
|
+
data-testid="devtools-launcher"
|
|
27
|
+
data-position={position}
|
|
28
|
+
>
|
|
29
|
+
{#if preview === 'unavailable'}
|
|
30
|
+
<span
|
|
31
|
+
class="preview-tag preview-unavailable"
|
|
32
|
+
role="status"
|
|
33
|
+
aria-live="polite"
|
|
34
|
+
title="This preview link's workspace no longer exists. The published site is shown."
|
|
35
|
+
>Preview unavailable — showing published</span>
|
|
36
|
+
{:else if preview === 'preview'}
|
|
37
|
+
<span class="preview-tag" role="status" aria-live="polite">Preview mode</span>
|
|
38
|
+
{/if}
|
|
39
|
+
<button
|
|
40
|
+
class="floating-button"
|
|
41
|
+
class:has-preview-tag={preview !== null}
|
|
42
|
+
onclick={onOpen}
|
|
43
|
+
aria-label="Open Picked Devtools"
|
|
44
|
+
title="Open Picked Devtools"
|
|
45
|
+
>
|
|
46
|
+
<PickedIcon height={25} width={25} />
|
|
47
|
+
</button>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.launcher {
|
|
52
|
+
position: fixed;
|
|
53
|
+
z-index: 999999;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: stretch;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
transition: transform 180ms ease-out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.launcher.top {
|
|
61
|
+
top: calc(1rem + env(safe-area-inset-top, 0px));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.launcher.bottom {
|
|
65
|
+
bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.launcher.right {
|
|
69
|
+
right: env(safe-area-inset-right, 0px);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* The button meets the edge it sits against, so the tag goes on its inner side. */
|
|
73
|
+
.launcher.left {
|
|
74
|
+
left: env(safe-area-inset-left, 0px);
|
|
75
|
+
flex-direction: row-reverse;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.launcher.auto-hide.right {
|
|
79
|
+
transform: translateX(calc(100% - 8px));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.launcher.auto-hide.left {
|
|
83
|
+
transform: translateX(calc(-100% + 8px));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.launcher.auto-hide:hover,
|
|
87
|
+
.launcher.auto-hide:focus-within {
|
|
88
|
+
transform: translateX(0);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@media (prefers-reduced-motion: reduce) {
|
|
92
|
+
.launcher {
|
|
93
|
+
transition: none;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.floating-button {
|
|
98
|
+
border-radius: 6px;
|
|
99
|
+
background-color: #ffffff;
|
|
100
|
+
display: grid;
|
|
101
|
+
place-items: center;
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
border: 0 transparent;
|
|
104
|
+
padding: 6px;
|
|
105
|
+
box-shadow: 2px 2px 4px #00000029;
|
|
106
|
+
|
|
107
|
+
&:hover {
|
|
108
|
+
background-color: #f5f5f5;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&:focus-visible {
|
|
112
|
+
outline: 2px solid #3b82f6;
|
|
113
|
+
outline-offset: 2px;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.right .floating-button.has-preview-tag {
|
|
118
|
+
border-radius: 0 6px 6px 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.left .floating-button.has-preview-tag {
|
|
122
|
+
border-radius: 6px 0 0 6px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.preview-tag {
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
padding: 0 10px;
|
|
129
|
+
background: #2563eb;
|
|
130
|
+
color: #ffffff;
|
|
131
|
+
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
|
132
|
+
'Helvetica Neue', Arial, sans-serif;
|
|
133
|
+
font-size: 12px;
|
|
134
|
+
font-weight: 500;
|
|
135
|
+
line-height: 1.4;
|
|
136
|
+
box-shadow: 2px 2px 4px #00000029;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.right .preview-tag {
|
|
140
|
+
border-radius: 6px 0 0 6px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.left .preview-tag {
|
|
144
|
+
border-radius: 0 6px 6px 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.preview-tag.preview-unavailable {
|
|
148
|
+
background: #b45309;
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** @file The floating devtools button's corner, and the viewer's remembered auto-hide choice. */
|
|
2
|
+
import type { LauncherPosition } from '../options';
|
|
3
|
+
/** `localStorage` key holding the viewer's auto-hide choice, `'true'` or `'false'`. */
|
|
4
|
+
export declare const AUTO_HIDE_STORAGE_KEY = "picked-devtools-launcher-autohide";
|
|
5
|
+
/** Reads the storage to use; may throw where site data is blocked. */
|
|
6
|
+
export type StorageGetter = () => Pick<Storage, 'getItem' | 'setItem'>;
|
|
7
|
+
/** The two edges a corner sits against. */
|
|
8
|
+
export interface LauncherEdges {
|
|
9
|
+
vertical: 'top' | 'bottom';
|
|
10
|
+
side: 'left' | 'right';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reads whether the button auto-hides: the viewer's stored choice, else the host's option.
|
|
14
|
+
*
|
|
15
|
+
* @param {StorageGetter} getStorage - Reads the storage holding the viewer's choice.
|
|
16
|
+
* @param {boolean} fallback - The host's `launcher.autoHide` option.
|
|
17
|
+
* @returns {boolean} `true` when the button tucks away until hovered or focused.
|
|
18
|
+
* @example readAutoHide(() => window.localStorage, true)
|
|
19
|
+
*/
|
|
20
|
+
export declare function readAutoHide(getStorage: StorageGetter, fallback: boolean): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Stores the viewer's auto-hide choice. Does nothing where storage is denied.
|
|
23
|
+
*
|
|
24
|
+
* @param {StorageGetter} getStorage - Reads the storage to write to.
|
|
25
|
+
* @param {boolean} value - The viewer's choice.
|
|
26
|
+
* @example writeAutoHide(() => window.localStorage, false)
|
|
27
|
+
*/
|
|
28
|
+
export declare function writeAutoHide(getStorage: StorageGetter, value: boolean): void;
|
|
29
|
+
/**
|
|
30
|
+
* Names the edges a corner sits against.
|
|
31
|
+
*
|
|
32
|
+
* @param {LauncherPosition} position - The corner.
|
|
33
|
+
* @returns {LauncherEdges} Its vertical and side edge.
|
|
34
|
+
* @example launcherEdges('top-left') // { vertical: 'top', side: 'left' }
|
|
35
|
+
*/
|
|
36
|
+
export declare function launcherEdges(position: LauncherPosition): LauncherEdges;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`picked-devtools-launcher-autohide`;function t(t,n){try{let r=t().getItem(e);return r===`true`||r!==`false`&&n}catch{return n}}function n(t,n){try{t().setItem(e,String(n))}catch{}}function r(e){return{vertical:e.startsWith(`top`)?`top`:`bottom`,side:e.endsWith(`left`)?`left`:`right`}}export{e as AUTO_HIDE_STORAGE_KEY,r as launcherEdges,t as readAutoHide,n as writeAutoHide};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** @file The devtools plugin's options, and how the devtools panel reads them back off the client. */
|
|
2
|
+
import type { Picked } from '@picked/client';
|
|
3
|
+
export { DEVTOOLS_EXPERIENCE_KEY } from './constants';
|
|
4
|
+
/** The corner the floating devtools button sits in. */
|
|
5
|
+
export type LauncherPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
6
|
+
/** Where the floating devtools button sits and whether it tucks away until hovered. */
|
|
7
|
+
export interface LauncherOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The corner the button sits in.
|
|
10
|
+
*
|
|
11
|
+
* @default 'bottom-right'
|
|
12
|
+
*/
|
|
13
|
+
position?: LauncherPosition;
|
|
14
|
+
/**
|
|
15
|
+
* When `true`, the button slides against its side edge until hovered or focused. A viewer's own
|
|
16
|
+
* choice from the panel header takes precedence.
|
|
17
|
+
*
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
autoHide?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** A button the Answers tab shows after an answer is edited. */
|
|
23
|
+
export interface AnswerFollowUp {
|
|
24
|
+
/** The button's text. */
|
|
25
|
+
label: string;
|
|
26
|
+
/** Runs when the button is pressed. */
|
|
27
|
+
run: (client: Picked) => void;
|
|
28
|
+
}
|
|
29
|
+
/** A How to use section supplied by the host, for a feature that is not a devtools tab. */
|
|
30
|
+
export interface DevtoolsGuideSection {
|
|
31
|
+
/** Unique within the guide. */
|
|
32
|
+
id: string;
|
|
33
|
+
/** The section heading. */
|
|
34
|
+
title: string;
|
|
35
|
+
/** Numbered steps, in order. `**text**` marks a control's label. */
|
|
36
|
+
steps: readonly string[];
|
|
37
|
+
/** Short lines after the steps. */
|
|
38
|
+
notes?: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/** A "something is not working" entry in How to use. */
|
|
41
|
+
export interface DevtoolsGuideFix {
|
|
42
|
+
/** What the viewer sees. */
|
|
43
|
+
problem: string;
|
|
44
|
+
/** What to do about it. */
|
|
45
|
+
fix: string;
|
|
46
|
+
}
|
|
47
|
+
/** Host-supplied How to use content, listed before the devtools' own sections. */
|
|
48
|
+
export interface DevtoolsGuide {
|
|
49
|
+
sections?: readonly DevtoolsGuideSection[];
|
|
50
|
+
fixes?: readonly DevtoolsGuideFix[];
|
|
51
|
+
}
|
|
52
|
+
/** The options read by the devtools panel, as passed to `svelteDevtoolsPlugin`. */
|
|
53
|
+
export interface DevtoolsPanelOptions {
|
|
54
|
+
/**
|
|
55
|
+
* When `true`, the panel withholds every write — answer edits, clears and resets, journey jumps —
|
|
56
|
+
* and says why. For a session that may belong to a real visitor, such as a preview link opened
|
|
57
|
+
* on a live site. A preview token alone never makes a session read-only.
|
|
58
|
+
*
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
readOnly?: boolean;
|
|
62
|
+
/** The environment's name, shown as a badge in the panel header. */
|
|
63
|
+
environmentLabel?: string;
|
|
64
|
+
/** Experience keys the journey views never list or follow, such as a host's own internal widgets. */
|
|
65
|
+
hiddenExperienceKeys?: readonly string[];
|
|
66
|
+
/**
|
|
67
|
+
* Experience keys, topmost first. When several experiences are open, the first one listed here
|
|
68
|
+
* is the journey the panel follows. Unlisted ones follow the most recently opened.
|
|
69
|
+
*/
|
|
70
|
+
journeyPrecedence?: readonly string[];
|
|
71
|
+
/** Field keys committed by code rather than answered by the visitor; Answers leaves them out. */
|
|
72
|
+
codeOwnedFields?: readonly string[];
|
|
73
|
+
/** A button the Answers tab offers after an edit, such as re-running a fetch the answers feed. */
|
|
74
|
+
answerFollowUp?: AnswerFollowUp;
|
|
75
|
+
/** How to use content for host features that are not devtools tabs. */
|
|
76
|
+
guide?: DevtoolsGuide;
|
|
77
|
+
/** The floating button's corner and auto-hide. */
|
|
78
|
+
launcher?: LauncherOptions;
|
|
79
|
+
}
|
|
80
|
+
/** The devtools options with every default applied. */
|
|
81
|
+
export interface ResolvedDevtoolsOptions {
|
|
82
|
+
readOnly: boolean;
|
|
83
|
+
environmentLabel: string | undefined;
|
|
84
|
+
/** Always includes the devtools experience itself. */
|
|
85
|
+
hiddenExperienceKeys: ReadonlySet<string>;
|
|
86
|
+
journeyPrecedence: readonly string[];
|
|
87
|
+
codeOwnedFields: ReadonlySet<string>;
|
|
88
|
+
answerFollowUp: AnswerFollowUp | null;
|
|
89
|
+
guide: {
|
|
90
|
+
sections: Required<DevtoolsGuideSection>[];
|
|
91
|
+
fixes: DevtoolsGuideFix[];
|
|
92
|
+
};
|
|
93
|
+
launcher: Required<LauncherOptions>;
|
|
94
|
+
}
|
|
95
|
+
/** Every corner the floating button can sit in. */
|
|
96
|
+
export declare const LAUNCHER_POSITIONS: readonly LauncherPosition[];
|
|
97
|
+
/**
|
|
98
|
+
* Reads the devtools options off the client's plugin config, applying every default. A malformed
|
|
99
|
+
* option falls back to its default, so one bad value never stops the panel rendering.
|
|
100
|
+
*
|
|
101
|
+
* @param {Pick<Picked, 'getPluginConfig'>} client - The client the devtools plugin is registered on.
|
|
102
|
+
* @returns {ResolvedDevtoolsOptions} The options with defaults applied.
|
|
103
|
+
* @example
|
|
104
|
+
* const { readOnly, launcher } = readDevtoolsOptions(getPicked())
|
|
105
|
+
*/
|
|
106
|
+
export declare function readDevtoolsOptions(client: Pick<Picked, 'getPluginConfig'>): ResolvedDevtoolsOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEVTOOLS_EXPERIENCE_KEY as e,DEVTOOLS_PLUGIN_NAME as t}from"./constants.js";var n=[`top-left`,`top-right`,`bottom-left`,`bottom-right`];function r(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function i(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function a(e){return n.some(t=>t===e)}function o(e){if(!r(e))return null;let{id:t,title:n,steps:a,notes:o}=e;return typeof t!=`string`||typeof n!=`string`||!Array.isArray(a)?null:{id:t,title:n,steps:i(a),notes:i(o)}}function s(e){if(!r(e))return null;let{problem:t,fix:n}=e;return typeof t!=`string`||typeof n!=`string`?null:{problem:t,fix:n}}function c(e){if(!r(e))return null;let{label:t,run:n}=e;return typeof t!=`string`||typeof n!=`function`?null:{label:t,run:e=>{Reflect.apply(n,void 0,[e])}}}function l(n){let l=n.getPluginConfig(t).options,u=r(l)?l:{},d=r(u.guide)?u.guide:{},f=r(u.launcher)?u.launcher:{},p=u.environmentLabel;return{readOnly:u.readOnly===!0,environmentLabel:typeof p==`string`&&p.length>0?p:void 0,hiddenExperienceKeys:new Set([e,...i(u.hiddenExperienceKeys)]),journeyPrecedence:i(u.journeyPrecedence),codeOwnedFields:new Set(i(u.codeOwnedFields)),answerFollowUp:c(u.answerFollowUp),guide:{sections:(Array.isArray(d.sections)?d.sections:[]).map(o).filter(e=>e!==null),fixes:(Array.isArray(d.fixes)?d.fixes:[]).map(s).filter(e=>e!==null)},launcher:{position:a(f.position)?f.position:`bottom-right`,autoHide:typeof f.autoHide!=`boolean`||f.autoHide}}}export{e as DEVTOOLS_EXPERIENCE_KEY,n as LAUNCHER_POSITIONS,l as readDevtoolsOptions};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @file Svelte devtools plugin that registers and lazily loads the Picked DevTools experience. */
|
|
2
2
|
import { type Plugin } from '@picked/client';
|
|
3
3
|
import type { CustomTool } from './customTools';
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export interface SvelteDevtoolsPluginOptions {
|
|
4
|
+
import type { DevtoolsPanelOptions } from './options';
|
|
5
|
+
export { DEVTOOLS_PLUGIN_NAME } from './constants';
|
|
6
|
+
export interface SvelteDevtoolsPluginOptions extends DevtoolsPanelOptions {
|
|
7
7
|
/**
|
|
8
8
|
* When `true`, the devtools experience launches automatically on page load.
|
|
9
9
|
* When `false`, devtools can only be opened via the Picked Chrome extension,
|
|
@@ -14,10 +14,10 @@ export interface SvelteDevtoolsPluginOptions {
|
|
|
14
14
|
*/
|
|
15
15
|
enabled?: boolean;
|
|
16
16
|
/**
|
|
17
|
-
* Project-specific custom
|
|
18
|
-
* `
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* Project-specific custom tools. Each tool's `component` is framework-adapted (via
|
|
18
|
+
* `adaptReactComponent` or `adaptSvelteComponent`), so it can be authored in the host app's
|
|
19
|
+
* framework and still receive the live Picked client the way an experience component does. A
|
|
20
|
+
* tool's `placement` decides whether it is a tab of its own or sits under Developer.
|
|
21
21
|
*
|
|
22
22
|
* @default []
|
|
23
23
|
*/
|
|
@@ -32,7 +32,7 @@ export interface SvelteDevtoolsPluginOptions {
|
|
|
32
32
|
* @example
|
|
33
33
|
* ```typescript
|
|
34
34
|
* const client = new Picked({
|
|
35
|
-
* plugins: [...svelteDevtoolsPlugin({ enabled: true })],
|
|
35
|
+
* plugins: [...svelteDevtoolsPlugin({ enabled: true, launcher: { position: 'top-right' } })],
|
|
36
36
|
* })
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{adaptSvelteComponent as e}from"../../component.js";import{
|
|
1
|
+
import{adaptSvelteComponent as e}from"../../component.js";import{DEVTOOLS_EXPERIENCE_KEY as t,DEVTOOLS_PLUGIN_NAME as n}from"./constants.js";import{__vitePreload as r}from"../../_virtual/_vite/preload-helper.js";import{lazyComponent as i}from"@picked/client";import{createExperience as a,createExperiencePlugin as o}from"@picked/client/plugins/create-experience";var s=s=>{let{enabled:c,customTools:l,...u}=s??{},d=a({id:t,key:t,name:`Picked Devtools`,condition:!1,initializeOpen:!1,targets:[{selector:`body`,placement:`append`}],component:e(i(()=>r(()=>import(`./DevToolsExperience.svelte`),[])))});return d.addStep({name:`Tools`}),[{name:n,setup:e=>{let t=!!e.searchParams[`preview-token`]?.[0];return(c||t)&&e.eventBus.watch(t=>{t.type===`ready`&&e.experiences.launch({key:d.key,options:{bypassCondition:!0}})}),{customTools:l??[],options:u}}},o({experiences:[d]})]};export{n as DEVTOOLS_PLUGIN_NAME,s as svelteDevtoolsPlugin};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SafetyPosture } from './derive';
|
|
2
|
+
/**
|
|
3
|
+
* Makes the posture available to every screen the devtools shell renders.
|
|
4
|
+
*
|
|
5
|
+
* @param {SafetyPosture} posture - What this session may do.
|
|
6
|
+
* @example setPostureContext(derivePosture({ readOnly: true }))
|
|
7
|
+
*/
|
|
8
|
+
export declare function setPostureContext(posture: SafetyPosture): void;
|
|
9
|
+
/**
|
|
10
|
+
* Reads the reason writes are withheld, for a screen rendered inside the devtools shell.
|
|
11
|
+
*
|
|
12
|
+
* @returns {string | null} Why this session is read-only, or `null` when it may write.
|
|
13
|
+
* @example const readOnlyReason = readOnlyReasonFromContext()
|
|
14
|
+
*/
|
|
15
|
+
export declare function readOnlyReasonFromContext(): string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getContext as e,setContext as t}from"svelte";var n=Symbol(`picked-devtools-posture`);function r(e){t(n,e)}function i(){let t=e(n);return typeof t!=`object`||!t||!(`readOnly`in t)||t.readOnly!==!0?null:`reason`in t&&typeof t.reason==`string`?t.reason:`Read-only`}export{i as readOnlyReasonFromContext,r as setPostureContext};
|