@picked/svelte 0.0.1-dev.1777594341273 → 0.0.1-dev.1777601813342

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.
@@ -1,25 +1,38 @@
1
- import { Action } from '@picked/client';
2
- import { Store } from 'effector';
1
+ import { ExperienceInstance } from '@picked/client';
3
2
  /**
4
3
  * Returns the reactive evokable action store for the given action key.
5
4
  *
5
+ * When `options.experience` is provided, the wrapped call passes that
6
+ * experience as the action's context, so manually-invoked handlers can
7
+ * behave as if they were triggered by that experience — for example to
8
+ * call `context.experience.close()` after a submit.
9
+ *
6
10
  * @param {string} actionKey - The registered action key.
11
+ * @param {object} [options] - Optional invocation overrides.
12
+ * @param {ExperienceInstance} options.experience - Experience to bind as the action's context.
7
13
  * @returns {Store<() => ReturnType<Action>>} A store containing the callable action function or undefined.
8
14
  * @example
9
15
  * ```ts
10
16
  * const actionStore = getAction('log-event')
17
+ * const bound = getAction('submit-form', { experience: getExperience() })
11
18
  * ```
12
19
  */
13
- export declare function getAction(actionKey: string): Store<() => ReturnType<Action>>;
20
+ export declare function getAction(actionKey: string, options?: {
21
+ experience: ExperienceInstance;
22
+ }): any;
14
23
  /**
15
24
  * Returns a reactive store holding the latest result of invoking the keyed action.
16
25
  * Re-evaluates automatically when the underlying action store updates.
17
26
  *
18
27
  * @param {string} actionKey - The registered action key.
28
+ * @param {object} [options] - Optional invocation overrides.
29
+ * @param {ExperienceInstance} options.experience - Experience to bind as the action's context.
19
30
  * @returns {Store<string | string[] | boolean | void | undefined>} A store containing the latest action return value.
20
31
  * @example
21
32
  * ```ts
22
33
  * const result = getActionResult('is-logged-in')
23
34
  * ```
24
35
  */
25
- export declare function getActionResult(actionKey: string): import('effector').StoreWritable<string | boolean | void | string[] | undefined>;
36
+ export declare function getActionResult(actionKey: string, options?: {
37
+ experience: ExperienceInstance;
38
+ }): import('effector').StoreWritable<string | boolean | void | string[] | undefined>;
@@ -1 +1 @@
1
- import{getPicked as e}from"./client.js";import{attach as t,createEffect as n,createEvent as r,createStore as i,sample as a}from"effector";import"@picked/client";function o(t){return e().actions.getEvokableAction(t)}function s(e){let s=o(e),c=i(void 0,{skipVoid:!1}),l=r(),u=t({source:s,mapParams:(e,t)=>t,effect:n(async e=>{if(e)return await e()})});return a({clock:l,target:u}),a({clock:u.doneData,target:c}),l(),a({clock:s,target:l}),c}export{o as getAction,s as getActionResult};
1
+ import{getPicked as e}from"./client.js";import{attach as t,createEffect as n,createEvent as r,createStore as i,sample as a}from"effector";import"@picked/client";function o(t,n){return e().actions.getEvokableAction(t,n)}function s(e,s){let c=o(e,s),l=i(void 0,{skipVoid:!1}),u=r(),d=t({source:c,mapParams:(e,t)=>t,effect:n(async e=>{if(e)return await e()})});return a({clock:u,target:d}),a({clock:d.doneData,target:l}),u(),a({clock:c,target:u}),l}export{o as getAction,s as getActionResult};
@@ -1,2 +1 @@
1
- import { AnalyticsProductList } from '@picked/analytics';
2
- export declare const getTrackRecommendationPresentEvent: () => import('effector').Effect<AnalyticsProductList, void, Error>;
1
+ export declare const getTrackRecommendationPresentEvent: () => import('effector').Effect<AnalyticsProductList, any, Error>;
@@ -1,4 +1,4 @@
1
- export declare function getFeature(featureName: string): import('effector').Store<() => Promise<boolean | string | undefined>>;
1
+ export declare function getFeature(featureName: string): any;
2
2
  export declare function getFeatureResult(featureName: string): import('effector').StoreWritable<{
3
3
  id: string;
4
4
  bucket: string | boolean;
@@ -1,3 +1,2 @@
1
- import { Predicate } from '@picked/client';
2
- export declare function getPredicate(predicateName: string): import('effector').Store<() => ReturnType<Predicate>>;
1
+ export declare function getPredicate(predicateName: string): any;
3
2
  export declare function getPredicateResult(predicateName: string): import('effector').StoreWritable<string | boolean | string[] | undefined>;
@@ -25,6 +25,7 @@
25
25
  const client = getPicked()
26
26
 
27
27
  const dashboardProjectUrl = `${client.dashboardUrl}/p/${client.projectId}`
28
+ const isPreview = Boolean(client.searchParams['preview-token']?.[0])
28
29
 
29
30
  const tabs = [
30
31
  {
@@ -122,14 +123,19 @@
122
123
  </div>
123
124
  </div>
124
125
  {:else}
125
- <button
126
- class="floating-button"
127
- onclick={() => experience.open()}
128
- aria-label="Open Picked Devtools"
129
- title="Open Picked Devtools"
130
- >
131
- <PickedIcon height={25} width={25}/>
132
- </button>
126
+ <div class="launcher">
127
+ {#if isPreview}
128
+ <span class="preview-tag" role="status" aria-live="polite">Preview mode</span>
129
+ {/if}
130
+ <button
131
+ class="floating-button"
132
+ onclick={() => experience.open()}
133
+ aria-label="Open Picked Devtools"
134
+ title="Open Picked Devtools"
135
+ >
136
+ <PickedIcon height={25} width={25}/>
137
+ </button>
138
+ </div>
133
139
  {/if}
134
140
 
135
141
  <style>
@@ -307,16 +313,21 @@
307
313
  padding-right: var(--space-4);
308
314
  }
309
315
 
310
- .floating-button {
316
+ .launcher {
311
317
  position: fixed;
312
318
  bottom: 1rem;
313
319
  right: 1.5rem;
314
- border-radius: 6px;
315
- background-color: var(--color-white);
320
+ z-index: 999999;
321
+ display: flex;
322
+ align-items: stretch;
323
+ }
324
+
325
+ .floating-button {
326
+ border-radius: 0 6px 6px 0;
327
+ background-color: #ffffff;
316
328
  display: grid;
317
329
  place-items: center;
318
330
  cursor: pointer;
319
- z-index: 999999;
320
331
  border: 0 transparent;
321
332
  padding: 6px;
322
333
  box-shadow: 2px 2px 4px #00000029;
@@ -326,6 +337,21 @@
326
337
  }
327
338
  }
328
339
 
340
+ .preview-tag {
341
+ display: flex;
342
+ align-items: center;
343
+ padding: 0 10px;
344
+ background: #2563eb;
345
+ color: #ffffff;
346
+ border-radius: 6px 0 0 6px;
347
+ font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
348
+ 'Helvetica Neue', Arial, sans-serif;
349
+ font-size: 12px;
350
+ font-weight: 500;
351
+ line-height: 1.4;
352
+ box-shadow: 2px 2px 4px #00000029;
353
+ }
354
+
329
355
  /** Compact inline form elements for use within table cells */
330
356
  .devtools :global(.inline-select),
331
357
  .devtools :global(.inline-input) {
@@ -2,7 +2,9 @@ import { Plugin } from '@picked/client';
2
2
  export interface SvelteDevtoolsPluginOptions {
3
3
  /**
4
4
  * When `true`, the devtools experience launches automatically on page load.
5
- * When `false`, devtools can only be opened via the Picked Chrome extension.
5
+ * When `false`, devtools can only be opened via the Picked Chrome extension,
6
+ * **unless** a preview token is present — in which case the launcher always
7
+ * mounts so the previewed site remains inspectable in production builds.
6
8
  *
7
9
  * @default false
8
10
  */
@@ -12,8 +14,8 @@ export interface SvelteDevtoolsPluginOptions {
12
14
  * Registers the devtools experience for on-demand loading via the Chrome DevTools extension.
13
15
  * The devtools component is lazily loaded — it is never included in the initial bundle.
14
16
  *
15
- * @param options - Optional configuration for the devtools plugin.
16
- * @returns An array of plugins to register with the Picked client.
17
+ * @param {SvelteDevtoolsPluginOptions} [options] - Optional configuration for the devtools plugin.
18
+ * @returns {Plugin[]} An array of plugins to register with the Picked client.
17
19
  * @example
18
20
  * ```typescript
19
21
  * const client = new Picked({
@@ -1 +1 @@
1
- import{adaptSvelteComponent as e}from"../../component.js";import{__vitePreload as t}from"../../_virtual/_vite/preload-helper.js";import{lazyComponent as n}from"@picked/client";import{createExperience as r,createExperiencePlugin as i}from"@picked/client/plugins/create-experience";var a=a=>{let o=r({id:`devtools`,key:`devtools`,name:`Picked Devtools`,condition:!1,initializeOpen:!1,targets:[{selector:`body`,placement:`append`}],component:e(n(()=>t(()=>import(`./DevToolsExperience.svelte`),[])))});return o.addStep({name:`Tools`}),[{name:`svelte-devtools`,setup:e=>{a?.enabled&&e.eventBus.watch(t=>{t.type===`ready`&&e.experiences.launch({key:o.key,options:{bypassCondition:!0}})})}},i({experiences:[o]})]};export{a as svelteDevtoolsPlugin};
1
+ import{adaptSvelteComponent as e}from"../../component.js";import{__vitePreload as t}from"../../_virtual/_vite/preload-helper.js";import{lazyComponent as n}from"@picked/client";import{createExperience as r,createExperiencePlugin as i}from"@picked/client/plugins/create-experience";var a=a=>{let o=r({id:`devtools`,key:`devtools`,name:`Picked Devtools`,condition:!1,initializeOpen:!1,targets:[{selector:`body`,placement:`append`}],component:e(n(()=>t(()=>import(`./DevToolsExperience.svelte`),[])))});return o.addStep({name:`Tools`}),[{name:`svelte-devtools`,setup:e=>{let t=!!e.searchParams[`preview-token`]?.[0];!a?.enabled&&!t||e.eventBus.watch(t=>{t.type===`ready`&&e.experiences.launch({key:o.key,options:{bypassCondition:!0}})})}},i({experiences:[o]})]};export{a as svelteDevtoolsPlugin};
@@ -3,4 +3,13 @@ export declare const renderSvelteComponent: (shadowRoot: ShadowRoot, component:
3
3
  stylesheets?: string[];
4
4
  css?: string[];
5
5
  }) => Promise<void>;
6
- export declare const unRenderSvelteComponent: (shadowRoot: ShadowRoot) => void;
6
+ /**
7
+ * Tears down the Svelte component tree previously mounted into `shadowRoot` by
8
+ * {@link renderSvelteComponent}. No-op when no instance was mounted there.
9
+ *
10
+ * @param {ShadowRoot} shadowRoot - The shadow root whose Svelte tree should be unmounted.
11
+ * @returns {Promise<void>} Resolves once Svelte's `unmount` settles.
12
+ * @example
13
+ * await unRenderSvelteComponent(shadowRoot)
14
+ */
15
+ export declare const unRenderSvelteComponent: (shadowRoot: ShadowRoot) => Promise<void>;
@@ -1 +1 @@
1
- import{isValidAdaptedComponent as e}from"../component.js";import{CLIENT_CONTEXT_KEY as t,EXPERIENCE_CONTEXT_KEY as n}from"../context.js";import{mergeArrays as r}from"../utils/array.js";import{mount as i,unmount as a}from"svelte";import{isLazyLoader as o}from"@picked/client";import s from"../utils/ErrorBoundary.svelte";var c=new WeakMap;function l(e,r){return new Map([[t,e],[n,r]])}var u=async(t,n,a,u,d)=>{if(!e(n))throw Error(`The component is invalid.`);let f=r(n.style?.sheets,d.stylesheets),p=r(n.style?.css,d.css);f.length&&f.forEach(e=>{let n=document.createElement(`link`);n.setAttribute(`rel`,`stylesheet`),n.setAttribute(`href`,e),n.setAttribute(`type`,`text/css`),n.setAttribute(`picked-injected`,`true`),t.appendChild(n)}),p.length&&p.forEach(e=>{let n=document.createElement(`style`);n.textContent=e,n.setAttribute(`type`,`text/css`),n.setAttribute(`picked-injected`,`true`),t.appendChild(n)});let m=e=>{let n=i(s,{target:t,props:{component:e,componentProps:{client:a,experience:u}},context:l(a,u)});c.set(t,n)};if(o(n.component)){let{default:e}=await n.component.load();m(e);return}if(n.component instanceof Promise){let{default:e}=await n.component;m(e);return}m(n.component)},d=e=>{let t=c.get(e);t&&(a(t),c.delete(e))};export{u as renderSvelteComponent,d as unRenderSvelteComponent};
1
+ import{isValidAdaptedComponent as e}from"../component.js";import{CLIENT_CONTEXT_KEY as t,EXPERIENCE_CONTEXT_KEY as n}from"../context.js";import{mergeArrays as r}from"../utils/array.js";import{mount as i,unmount as a}from"svelte";import{isLazyLoader as o}from"@picked/client";import s from"../utils/ErrorBoundary.svelte";var c=new WeakMap;function l(e,r){return new Map([[t,e],[n,r]])}var u=async(t,n,u,d,f)=>{if(!e(n))throw Error(`The component is invalid.`);let p=r(n.style?.sheets,f.stylesheets),m=r(n.style?.css,f.css);p.length&&p.forEach(e=>{let n=document.createElement(`link`);n.setAttribute(`rel`,`stylesheet`),n.setAttribute(`href`,e),n.setAttribute(`type`,`text/css`),n.setAttribute(`picked-injected`,`true`),t.appendChild(n)}),m.length&&m.forEach(e=>{let n=document.createElement(`style`);n.textContent=e,n.setAttribute(`type`,`text/css`),n.setAttribute(`picked-injected`,`true`),t.appendChild(n)});let h=async e=>{let n=c.get(t);if(n){try{await a(n)}catch{}c.delete(t)}let r=i(s,{target:t,props:{component:e,componentProps:{client:u,experience:d}},context:l(u,d)});c.set(t,r)};if(o(n.component)){let{default:e}=await n.component.load();await h(e);return}if(n.component instanceof Promise){let{default:e}=await n.component;await h(e);return}await h(n.component)},d=async e=>{let t=c.get(e);t&&(c.delete(e),await a(t))};export{u as renderSvelteComponent,d as unRenderSvelteComponent};
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "@picked/svelte",
3
- "version": "0.0.1-dev.1777594341273",
3
+ "version": "0.0.1-dev.1777601813342",
4
4
  "dependencies": {
5
5
  "d3": "^7.9.0"
6
6
  },
7
7
  "devDependencies": {
8
- "@picked/analytics": "workspace:*",
9
- "@picked/client": "workspace:*",
10
8
  "@repo/eslint-config": "workspace:*",
11
9
  "@repo/typescript-config": "workspace:*",
12
10
  "@size-limit/file": "^12.0.0",
@@ -97,8 +95,6 @@
97
95
  "tsgo"
98
96
  ],
99
97
  "ignoreDependencies": [
100
- "@picked/analytics",
101
- "@picked/client",
102
98
  "@repo/eslint-config",
103
99
  "@repo/typescript-config",
104
100
  "@sveltejs/package",
@@ -107,7 +103,8 @@
107
103
  },
108
104
  "module": "./dist/index.js",
109
105
  "peerDependencies": {
110
- "@picked/client": "0.0.1-dev.1777594341273",
106
+ "@picked/analytics": "workspace:*",
107
+ "@picked/client": "0.0.1-dev.1777601813342",
111
108
  "effector": "^23.3.0",
112
109
  "svelte": "^5.46.4"
113
110
  },