@joycostudio/studio 0.1.6 → 0.2.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/dist/client.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { DebugSchema, DebugFolder } from '@joycostudio/xyz/debug';
2
- import { f as StudioTool, T as ToolDefinition, j as ToolState, R as Result, i as ToolReference } from './protocol-DjrMADPm.js';
1
+ import { DebugFolder, DebugHost } from '@joycostudio/xyz/debug';
2
+ import { f as StudioTool, T as ToolDefinition, k as ToolState, h as ToolControls, R as Result, j as ToolReference } from './protocol-BviGBdSG.js';
3
+ import { StudioUi } from './ui.js';
4
+ import '@joycostudio/xyz/debug/dialkit';
3
5
 
4
6
  type Change = {
5
7
  path: string[];
@@ -28,9 +30,9 @@ type ToolHandle<TConfig extends object = any> = {
28
30
  /** Called after every config change, local or remote. */
29
31
  subscribe(listener: (config: TConfig) => void): () => void;
30
32
  /** The tool's Xyz schema bound to the live config. */
31
- controls(): DebugSchema;
33
+ controls(): ToolControls;
32
34
  /** Xyz `Debuggable`: `debugManager.register(handle)` mounts this tool in the app's floating pane. */
33
- debug(): DebugFolder;
35
+ debug(): DebugFolder<DebugHost>;
34
36
  /** The config on disk: the runtime's last reported saved value or, until one answers, the bundled `initial`. */
35
37
  readonly saved: TConfig;
36
38
  /** Dotted paths where the draft differs from `saved`. Tracked locally, so it works without a runtime too. */
@@ -82,6 +84,8 @@ type Studio = {
82
84
  readonly tools: readonly ToolHandle[];
83
85
  tool<TConfig extends object>(definition: ToolReference<TConfig>): ToolHandle<TConfig>;
84
86
  readonly connection: Connection;
87
+ /** The debug UI library tools' controls are drawn with. `<Studio>` and `<StudioDebug>` need one. */
88
+ readonly ui: StudioUi | undefined;
85
89
  /** Bumps on connection or any tool state change. */
86
90
  readonly version: number;
87
91
  subscribe(listener: () => void): () => void;
@@ -94,6 +98,12 @@ type StudioOptions = {
94
98
  * Only browsers connect, so a module-scope `createStudio` is safe to evaluate during SSR.
95
99
  */
96
100
  runtime?: string | false;
101
+ /**
102
+ * The debug UI library to draw controls with, from `@joycostudio/studio/ui`:
103
+ * `tweakpane(() => import('tweakpane'))` or `dialkit(() => import('dialkit/vanilla'))`.
104
+ * Required by `<Studio>` and `<StudioDebug>`; reading configs alone doesn't need one.
105
+ */
106
+ ui?: StudioUi;
97
107
  };
98
108
  /** Make the studio running in `target` (e.g. a preview iframe) compare `tool` as well. */
99
109
  declare function postCompare(target: Window | null | undefined, tool: string, showSaved: boolean): void;
@@ -101,4 +111,4 @@ declare function postCompare(target: Window | null | undefined, tool: string, sh
101
111
  declare function everyFrame(refresh: () => void): () => void;
102
112
  declare function createStudio(config: StudioOptions, options?: Pick<StudioOptions, 'runtime'>): Studio;
103
113
 
104
- export { type Change, type Connection, type Studio, type StudioOptions, type ToolHandle, createStudio, everyFrame, postCompare };
114
+ export { type Change, type Connection, type Studio, type StudioOptions, StudioUi, type ToolHandle, createStudio, everyFrame, postCompare };
package/dist/client.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  createStudio,
3
3
  everyFrame,
4
4
  postCompare
5
- } from "./chunk-6KZJEKOL.js";
6
- import "./chunk-DEJYGBPJ.js";
5
+ } from "./chunk-ZPKMVZ67.js";
6
+ import "./chunk-OEJWPWYJ.js";
7
7
  export {
8
8
  createStudio,
9
9
  everyFrame,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as ToolDefinition, R as Result } from './protocol-DjrMADPm.js';
2
- export { A as AnyTool, C as ConfigOf, D as DEFAULT_PORT, a as DiscoveredToolConfigs, b as DiscoveredToolDefinition, F as Failure, O as Op, c as Operations, P as PreviewToolDefinition, d as Request, S as ServerMessage, e as StudioConfig, f as StudioTool, g as Success, h as ToolIcon, i as ToolReference, j as ToolState, k as ToolSummary, l as defineConfig, m as defineTool, n as error, o as hasConfig, s as success } from './protocol-DjrMADPm.js';
1
+ import { T as ToolDefinition, R as Result } from './protocol-BviGBdSG.js';
2
+ export { A as AnyTool, C as ConfigOf, D as DEFAULT_PORT, a as DiscoveredToolConfigs, b as DiscoveredToolDefinition, F as Failure, O as Op, c as Operations, P as PreviewToolDefinition, d as Request, S as ServerMessage, e as StudioConfig, f as StudioTool, g as Success, h as ToolControls, i as ToolIcon, j as ToolReference, k as ToolState, l as ToolSummary, m as defineConfig, n as defineTool, o as error, p as hasConfig, s as success } from './protocol-BviGBdSG.js';
3
3
  import '@joycostudio/xyz/debug';
4
4
 
5
5
  /**
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  hasConfig,
7
7
  success,
8
8
  validateConfig
9
- } from "./chunk-DEJYGBPJ.js";
9
+ } from "./chunk-OEJWPWYJ.js";
10
10
  export {
11
11
  DEFAULT_PORT,
12
12
  defineConfig,
package/dist/next.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { StudioOptions, Studio } from './client.js';
2
2
  import '@joycostudio/xyz/debug';
3
- import './protocol-DjrMADPm.js';
3
+ import './protocol-BviGBdSG.js';
4
+ import './ui.js';
5
+ import '@joycostudio/xyz/debug/dialkit';
4
6
 
5
7
  /** Next.js replaces this public environment variable in browser bundles. */
6
8
  declare function createStudio(config: StudioOptions, options?: Pick<StudioOptions, 'runtime'>): Studio;
package/dist/next.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createStudio
3
- } from "./chunk-6KZJEKOL.js";
4
- import "./chunk-DEJYGBPJ.js";
3
+ } from "./chunk-ZPKMVZ67.js";
4
+ import "./chunk-OEJWPWYJ.js";
5
5
 
6
6
  // src/next.ts
7
7
  function createStudio2(config, options = {}) {
@@ -1,4 +1,4 @@
1
- import { DebugSchema } from '@joycostudio/xyz/debug';
1
+ import { DebugSchema, DebugHost } from '@joycostudio/xyz/debug';
2
2
 
3
3
  type Success<T> = {
4
4
  ok: true;
@@ -14,6 +14,8 @@ type Result<T> = Success<T> | Failure;
14
14
  declare const success: <T>(data: T) => Success<T>;
15
15
  declare const error: (code: string, message?: string) => Failure;
16
16
 
17
+ /** Controls as an Xyz schema. Drawn with whichever UI the app picks (`createStudio({ ui })`), so `extend` gets an unknown folder. */
18
+ type ToolControls = DebugSchema<DebugHost>;
17
19
  /**
18
20
  * An SVG icon as data: `[tag, attributes]` children of a 24×24 stroke icon.
19
21
  * Lucide's core package (`import { Palette } from 'lucide'`) exports exactly this shape.
@@ -42,10 +44,10 @@ type ToolDefinition<TConfig extends object = object> = ToolBase & {
42
44
  /** Config used before the runtime answers (and in production). */
43
45
  initial: TConfig;
44
46
  /**
45
- * What can be tweaked, as an Xyz/Tweakpane schema bound to `config`.
47
+ * What can be tweaked, as an Xyz schema bound to `config`.
46
48
  * Doubles as the runtime validator: every control's bounds are enforced on write.
47
49
  */
48
- controls: (config: TConfig) => DebugSchema;
50
+ controls: (config: TConfig) => ToolControls;
49
51
  };
50
52
  /** A tool with nothing to tune: a sidebar entry for its preview, without an inspector or config file. */
51
53
  type PreviewToolDefinition = ToolBase & {
@@ -66,7 +68,7 @@ interface DiscoveredToolConfigs {
66
68
  type DiscoveredToolDefinition<TConfig extends object = object> = ToolBase & {
67
69
  /** JSON source relative to this tool file, or a tsconfig path alias. Defaults to ./config.json. */
68
70
  config?: string;
69
- controls: (config: TConfig) => DebugSchema;
71
+ controls: (config: TConfig) => ToolControls;
70
72
  file?: never;
71
73
  initial?: never;
72
74
  };
@@ -188,4 +190,4 @@ type ServerMessage = {
188
190
  state: ToolState;
189
191
  };
190
192
 
191
- export { type AnyTool as A, type ConfigOf as C, DEFAULT_PORT as D, type Failure as F, type Op as O, type PreviewToolDefinition as P, type Result as R, type ServerMessage as S, type ToolDefinition as T, type DiscoveredToolConfigs as a, type DiscoveredToolDefinition as b, type Operations as c, type Request as d, type StudioConfig as e, type StudioTool as f, type Success as g, type ToolIcon as h, type ToolReference as i, type ToolState as j, type ToolSummary as k, defineConfig as l, defineTool as m, error as n, hasConfig as o, success as s };
193
+ export { type AnyTool as A, type ConfigOf as C, DEFAULT_PORT as D, type Failure as F, type Op as O, type PreviewToolDefinition as P, type Result as R, type ServerMessage as S, type ToolDefinition as T, type DiscoveredToolConfigs as a, type DiscoveredToolDefinition as b, type Operations as c, type Request as d, type StudioConfig as e, type StudioTool as f, type Success as g, type ToolControls as h, type ToolIcon as i, type ToolReference as j, type ToolState as k, type ToolSummary as l, defineConfig as m, defineTool as n, error as o, hasConfig as p, success as s };
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ComponentPropsWithRef, ReactNode, ComponentPropsWithoutRef, ComponentProps } from 'react';
3
- import { DebugSchema, DebugFolder } from '@joycostudio/xyz/debug';
3
+ import { DebugSchema, DebugHost, DebugAdapter, DebugFolder } from '@joycostudio/xyz/debug';
4
4
  import { Select } from '@base-ui/react/select';
5
5
 
6
6
  type Change = {
@@ -21,6 +21,8 @@ type Failure = {
21
21
  };
22
22
  type Result<T> = Success<T> | Failure;
23
23
 
24
+ /** Controls as an Xyz schema. Drawn with whichever UI the app picks (`createStudio({ ui })`), so `extend` gets an unknown folder. */
25
+ type ToolControls = DebugSchema<DebugHost>;
24
26
  /**
25
27
  * An SVG icon as data: `[tag, attributes]` children of a 24×24 stroke icon.
26
28
  * Lucide's core package (`import { Palette } from 'lucide'`) exports exactly this shape.
@@ -49,10 +51,10 @@ type ToolDefinition<TConfig extends object = object> = ToolBase & {
49
51
  /** Config used before the runtime answers (and in production). */
50
52
  initial: TConfig;
51
53
  /**
52
- * What can be tweaked, as an Xyz/Tweakpane schema bound to `config`.
54
+ * What can be tweaked, as an Xyz schema bound to `config`.
53
55
  * Doubles as the runtime validator: every control's bounds are enforced on write.
54
56
  */
55
- controls: (config: TConfig) => DebugSchema;
57
+ controls: (config: TConfig) => ToolControls;
56
58
  };
57
59
  /** A tool with nothing to tune: a sidebar entry for its preview, without an inspector or config file. */
58
60
  type PreviewToolDefinition = ToolBase & {
@@ -85,6 +87,25 @@ type ToolState<TConfig = unknown> = {
85
87
  conflict: boolean;
86
88
  };
87
89
 
90
+ /**
91
+ * The debug UI library Studio draws tool controls with: Tweakpane or DialKit. Pick one with
92
+ * `createStudio({ ui })`; the library loads lazily through `load`, from the host app, so only
93
+ * the one you pick needs to be installed.
94
+ */
95
+ type StudioUi = {
96
+ readonly kind: string;
97
+ /** The floating pane `StudioDebug` opens on `?debug` / Option+D. */
98
+ floating: DebugAdapter;
99
+ /** Controls drawn inside `container`, as the /studio inspector does. */
100
+ inline(container: HTMLElement, options: {
101
+ title: string;
102
+ }): Promise<DebugHost & {
103
+ dispose(): void;
104
+ }>;
105
+ /** Copy the library's page styles into Studio's shadow root, which page stylesheets don't reach. */
106
+ adoptStyles(root: ShadowRoot): void | Promise<void>;
107
+ };
108
+
88
109
  type Connection = {
89
110
  phase: 'local';
90
111
  } | {
@@ -106,9 +127,9 @@ type ToolHandle<TConfig extends object = any> = {
106
127
  /** Called after every config change, local or remote. */
107
128
  subscribe(listener: (config: TConfig) => void): () => void;
108
129
  /** The tool's Xyz schema bound to the live config. */
109
- controls(): DebugSchema;
130
+ controls(): ToolControls;
110
131
  /** Xyz `Debuggable`: `debugManager.register(handle)` mounts this tool in the app's floating pane. */
111
- debug(): DebugFolder;
132
+ debug(): DebugFolder<DebugHost>;
112
133
  /** The config on disk: the runtime's last reported saved value or, until one answers, the bundled `initial`. */
113
134
  readonly saved: TConfig;
114
135
  /** Dotted paths where the draft differs from `saved`. Tracked locally, so it works without a runtime too. */
@@ -160,6 +181,8 @@ type Studio$1 = {
160
181
  readonly tools: readonly ToolHandle[];
161
182
  tool<TConfig extends object>(definition: ToolReference<TConfig>): ToolHandle<TConfig>;
162
183
  readonly connection: Connection;
184
+ /** The debug UI library tools' controls are drawn with. `<Studio>` and `<StudioDebug>` need one. */
185
+ readonly ui: StudioUi | undefined;
163
186
  /** Bumps on connection or any tool state change. */
164
187
  readonly version: number;
165
188
  subscribe(listener: () => void): () => void;