@typespec/playground 0.14.0-dev.2 → 0.14.0-dev.4
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/index.js +17 -19
- package/dist/react/index.js +2604 -2866
- package/dist/react/viewers/index.js +23 -17
- package/dist/react-wrapper-B-poU4Lv.js +18 -0
- package/dist/services-CELCHECS.js +723 -0
- package/dist/src/editor-command-bar/editor-command-bar.d.ts +4 -3
- package/dist/src/editor-command-bar/editor-command-bar.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +1 -0
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/playground.d.ts +3 -8
- package/dist/src/react/playground.d.ts.map +1 -1
- package/dist/src/react/responsive-command-bar/index.d.ts +3 -0
- package/dist/src/react/responsive-command-bar/index.d.ts.map +1 -0
- package/dist/src/react/responsive-command-bar/responsive-command-bar.d.ts +36 -0
- package/dist/src/react/responsive-command-bar/responsive-command-bar.d.ts.map +1 -0
- package/dist/src/react/samples-drawer/index.d.ts +1 -1
- package/dist/src/react/samples-drawer/index.d.ts.map +1 -1
- package/dist/src/react/samples-drawer/samples-drawer-trigger.d.ts +7 -0
- package/dist/src/react/samples-drawer/samples-drawer-trigger.d.ts.map +1 -1
- package/dist/src/react/use-mobile.d.ts +6 -0
- package/dist/src/react/use-mobile.d.ts.map +1 -0
- package/dist/src/react/view-toggle.d.ts +10 -0
- package/dist/src/react/view-toggle.d.ts.map +1 -0
- package/dist/src/vite/types.d.ts +0 -2
- package/dist/src/vite/types.d.ts.map +1 -1
- package/dist/state-storage.js +65 -79
- package/dist/style.css +34 -13
- package/dist/tooling/index.js +24 -23
- package/dist/vite/index.js +54 -78
- package/package.json +15 -11
- package/dist/react-wrapper-BE4armyk.js +0 -20
- package/dist/services-Z619RuQS.js +0 -760
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { FunctionComponent
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { CommandBarItem } from '../react/responsive-command-bar/index.js';
|
|
2
3
|
import { BrowserHost, PlaygroundSample } from '../types.js';
|
|
3
4
|
export interface EditorCommandBarProps {
|
|
4
|
-
documentationUrl?: string;
|
|
5
5
|
saveCode: () => Promise<void> | void;
|
|
6
6
|
formatCode: () => Promise<void> | void;
|
|
7
7
|
fileBug?: () => Promise<void> | void;
|
|
8
|
-
|
|
8
|
+
/** Additional items provided by the consumer. */
|
|
9
|
+
commandBarItems?: readonly CommandBarItem[];
|
|
9
10
|
host: BrowserHost;
|
|
10
11
|
selectedEmitter: string;
|
|
11
12
|
onSelectedEmitterChange: (emitter: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-command-bar.d.ts","sourceRoot":"","sources":["../../../src/editor-command-bar/editor-command-bar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editor-command-bar.d.ts","sourceRoot":"","sources":["../../../src/editor-command-bar/editor-command-bar.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAkC,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAI/E,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrC,iDAAiD;IACjD,eAAe,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAEnD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CAwHrE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type { CommandBarItem } from '../react/responsive-command-bar/index.js';
|
|
1
2
|
export { usePlaygroundContext } from './context/index.js';
|
|
2
3
|
export { DiagnosticList } from './diagnostic-list/diagnostic-list.js';
|
|
3
4
|
export type { DiagnosticListProps } from './diagnostic-list/diagnostic-list.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,YAAY,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,sCAAsC,EACtC,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,YAAY,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,sCAAsC,EACtC,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent, ReactNode } from 'react';
|
|
2
2
|
import { BrowserHost, PlaygroundSample } from '../types.js';
|
|
3
|
+
import { CommandBarItem } from './responsive-command-bar/index.js';
|
|
3
4
|
import { FileOutputViewer, ProgramViewer } from './types.js';
|
|
4
5
|
import { PlaygroundState } from './use-playground-state.js';
|
|
5
6
|
export type { PlaygroundState };
|
|
@@ -23,10 +24,8 @@ export interface PlaygroundProps {
|
|
|
23
24
|
*/
|
|
24
25
|
defaultEmitter?: string;
|
|
25
26
|
onFileBug?: () => void;
|
|
26
|
-
/** Additional
|
|
27
|
-
|
|
28
|
-
/** Playground links */
|
|
29
|
-
links?: PlaygroundLinks;
|
|
27
|
+
/** Additional items to show in the command bar. */
|
|
28
|
+
commandBarItems?: CommandBarItem[];
|
|
30
29
|
/** Custom viewers to view the typespec program */
|
|
31
30
|
viewers?: ProgramViewer[];
|
|
32
31
|
/** Custom file viewers that enabled for certain emitters. Key of the map is emitter name */
|
|
@@ -47,10 +46,6 @@ export interface PlaygroundSaveData extends PlaygroundState {
|
|
|
47
46
|
/** Emitter name. */
|
|
48
47
|
emitter: string;
|
|
49
48
|
}
|
|
50
|
-
export interface PlaygroundLinks {
|
|
51
|
-
/** Link to documentation */
|
|
52
|
-
documentationUrl?: string;
|
|
53
|
-
}
|
|
54
49
|
/**
|
|
55
50
|
* Playground component for TypeSpec with consolidated state management.
|
|
56
51
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/react/playground.tsx"],"names":[],"mappings":"AAGA,OAAO,sCAAsC,CAAC;AAG9C,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASjE,OAAO,KAAK,EAAoB,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/react/playground.tsx"],"names":[],"mappings":"AAGA,OAAO,sCAAsC,CAAC;AAG9C,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAoB,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEpF,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAIrF,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAElB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,kCAAkC;IAClC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAEtC,wBAAwB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAE3C,oCAAoC;IACpC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,yDAAyD;IACzD,sBAAsB,CAAC,EAAE,eAAe,CAAC;IACzC,6CAA6C;IAC7C,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAE3D;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IAEvB,mDAAmD;IACnD,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IAEnC,kDAAkD;IAClD,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAE1B,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAEpD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAE7C,aAAa,CAAC,EAAE,wBAAwB,CAAC;IAEzC;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAEhB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAmRzD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/responsive-command-bar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
/** Defines a single item in a responsive command bar. */
|
|
3
|
+
export interface CommandBarItem {
|
|
4
|
+
/** Unique identifier for the item. */
|
|
5
|
+
readonly id: string;
|
|
6
|
+
/** Display label used for tooltip (desktop) and menu text (mobile). */
|
|
7
|
+
readonly label: string;
|
|
8
|
+
/** Icon element. */
|
|
9
|
+
readonly icon?: ReactNode;
|
|
10
|
+
/** Click handler for simple items. */
|
|
11
|
+
readonly onClick?: () => void;
|
|
12
|
+
/** If true, always visible as an icon button. If false (default), goes to overflow menu on mobile. */
|
|
13
|
+
readonly pinned?: boolean;
|
|
14
|
+
/** Sub-items rendered as a dropdown (desktop) or nested submenu (mobile). */
|
|
15
|
+
readonly children?: readonly CommandBarItem[];
|
|
16
|
+
/** Additional content rendered alongside the command bar (e.g., dialogs triggered by children). */
|
|
17
|
+
readonly content?: ReactNode;
|
|
18
|
+
/** Custom toolbar element for desktop rendering. Overrides default and children-based rendering. */
|
|
19
|
+
readonly toolbarItem?: ReactNode;
|
|
20
|
+
/** Custom menu element for mobile overflow menu. Overrides default and children-based rendering. */
|
|
21
|
+
readonly menuItem?: ReactNode;
|
|
22
|
+
/** Alignment group on the desktop toolbar. Defaults to "left". */
|
|
23
|
+
readonly align?: "left" | "right";
|
|
24
|
+
}
|
|
25
|
+
export interface ResponsiveCommandBarProps {
|
|
26
|
+
/** The items to render in the command bar. */
|
|
27
|
+
readonly items: readonly CommandBarItem[];
|
|
28
|
+
/** Whether to render in mobile (compact) mode. */
|
|
29
|
+
readonly isMobile: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A generic responsive command bar that renders items as a toolbar on desktop
|
|
33
|
+
* and collapses non-pinned items into a hamburger overflow menu on mobile.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ResponsiveCommandBar: FunctionComponent<ResponsiveCommandBarProps>;
|
|
36
|
+
//# sourceMappingURL=responsive-command-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive-command-bar.d.ts","sourceRoot":"","sources":["../../../../src/react/responsive-command-bar/responsive-command-bar.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAY,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzE,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oBAAoB;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAC1B,sCAAsC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,sGAAsG;IACtG,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC9C,mGAAmG;IACnG,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,oGAAoG;IACpG,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC;IACjC,oGAAoG;IACpG,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,yBAAyB;IACxC,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IAC1C,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,yBAAyB,CA8D7E,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { SamplesDrawerTrigger, type SamplesDrawerProps } from './samples-drawer-trigger.js';
|
|
1
|
+
export { SamplesDrawerOverlay, SamplesDrawerTrigger, type SamplesDrawerOverlayProps, type SamplesDrawerProps, } from './samples-drawer-trigger.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,GACxB,MAAM,6BAA6B,CAAC"}
|
|
@@ -4,5 +4,12 @@ export interface SamplesDrawerProps {
|
|
|
4
4
|
samples: Record<string, PlaygroundSample>;
|
|
5
5
|
onSelectedSampleNameChange: (sampleName: string) => void;
|
|
6
6
|
}
|
|
7
|
+
export interface SamplesDrawerOverlayProps extends SamplesDrawerProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
onOpenChange: (open: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
/** The overlay drawer showing the sample gallery. Controlled via open/onOpenChange. */
|
|
12
|
+
export declare const SamplesDrawerOverlay: FunctionComponent<SamplesDrawerOverlayProps>;
|
|
13
|
+
/** Toolbar button trigger + overlay drawer for samples. */
|
|
7
14
|
export declare const SamplesDrawerTrigger: FunctionComponent<SamplesDrawerProps>;
|
|
8
15
|
//# sourceMappingURL=samples-drawer-trigger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"samples-drawer-trigger.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/samples-drawer-trigger.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"samples-drawer-trigger.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/samples-drawer-trigger.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AAED,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAED,uFAAuF;AACvF,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,yBAAyB,CA4C7E,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,kBAAkB,CA0BtE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-mobile.d.ts","sourceRoot":"","sources":["../../../src/react/use-mobile.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAkBrC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
export type ViewMode = "editor" | "output" | "both";
|
|
3
|
+
export interface ViewToggleProps {
|
|
4
|
+
viewMode: ViewMode;
|
|
5
|
+
onViewModeChange: (mode: ViewMode) => void;
|
|
6
|
+
/** Additional toolbar actions rendered on the right side of the bar. */
|
|
7
|
+
actions?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const ViewToggle: FunctionComponent<ViewToggleProps>;
|
|
10
|
+
//# sourceMappingURL=view-toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-toggle.d.ts","sourceRoot":"","sources":["../../../src/react/view-toggle.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG5E,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,gBAAgB,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC3C,wEAAwE;IACxE,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAiCzD,CAAC"}
|
package/dist/src/vite/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PlaygroundLinks } from '../react/playground.js';
|
|
2
1
|
import { PlaygroundSampleConfig } from '../tooling/types.js';
|
|
3
2
|
import { PlaygroundSample } from '../types.js';
|
|
4
3
|
export interface PlaygroundUserConfig extends Omit<PlaygroundConfig, "samples"> {
|
|
@@ -12,6 +11,5 @@ export interface PlaygroundConfig {
|
|
|
12
11
|
readonly defaultEmitter: string;
|
|
13
12
|
readonly libraries: readonly string[];
|
|
14
13
|
readonly samples: Record<string, PlaygroundSample>;
|
|
15
|
-
readonly links?: PlaygroundLinks;
|
|
16
14
|
}
|
|
17
15
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vite/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vite/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC;IAC7E;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CACpD"}
|
package/dist/state-storage.js
CHANGED
|
@@ -1,82 +1,68 @@
|
|
|
1
|
-
import lzutf8 from
|
|
2
|
-
|
|
1
|
+
import lzutf8 from "lzutf8";
|
|
2
|
+
//#region src/state-storage.ts
|
|
3
|
+
/**
|
|
4
|
+
* Generic storage mechanism for data in the playground.
|
|
5
|
+
* @param schema Schema of the data to be serialized in the query
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
3
8
|
function createUrlStateStorage(schema) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
params.delete(item.queryParam);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return params;
|
|
65
|
-
}
|
|
66
|
-
function compress(item, value) {
|
|
67
|
-
if (item.compress) {
|
|
68
|
-
return lzutf8.compress(value, { outputEncoding: "Base64" });
|
|
69
|
-
} else {
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function serialize(item, value) {
|
|
74
|
-
if (item.type === "object") {
|
|
75
|
-
return JSON.stringify(value);
|
|
76
|
-
} else {
|
|
77
|
-
return value;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
9
|
+
return {
|
|
10
|
+
load,
|
|
11
|
+
save,
|
|
12
|
+
resolveSearchParams
|
|
13
|
+
};
|
|
14
|
+
function load() {
|
|
15
|
+
const result = {};
|
|
16
|
+
const parsed = new URLSearchParams(window.location.search);
|
|
17
|
+
for (const [key, item] of Object.entries(schema)) {
|
|
18
|
+
const value = parsed.get(item.queryParam);
|
|
19
|
+
const decompressed = value && decompress(item, value);
|
|
20
|
+
const deserialized = decompressed && deserialize(item, decompressed);
|
|
21
|
+
if (deserialized) result[key] = deserialized;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
function decompress(item, value) {
|
|
26
|
+
if (item.compress) try {
|
|
27
|
+
return lzutf8.decompress(value, { inputEncoding: "Base64" });
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.error(`Error decompressing query parameter ${item.queryParam} with content:`, value);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
else return value;
|
|
33
|
+
}
|
|
34
|
+
function deserialize(item, value) {
|
|
35
|
+
if (item.type === "object") try {
|
|
36
|
+
return JSON.parse(value);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error(`Error decompressing query parameter ${item.queryParam} with content:`, value);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
else return value;
|
|
42
|
+
}
|
|
43
|
+
function save(data) {
|
|
44
|
+
const params = resolveSearchParams(data, true);
|
|
45
|
+
history.pushState(null, "", window.location.pathname + "?" + params.toString());
|
|
46
|
+
}
|
|
47
|
+
function resolveSearchParams(data, mergeWithExisting = false) {
|
|
48
|
+
const params = new URLSearchParams(mergeWithExisting ? location.search : void 0);
|
|
49
|
+
for (const [key, item] of Object.entries(schema)) {
|
|
50
|
+
const value = data[key];
|
|
51
|
+
if (value) {
|
|
52
|
+
const compressed = compress(item, serialize(item, value));
|
|
53
|
+
params.set(item.queryParam, compressed);
|
|
54
|
+
} else params.delete(item.queryParam);
|
|
55
|
+
}
|
|
56
|
+
return params;
|
|
57
|
+
}
|
|
58
|
+
function compress(item, value) {
|
|
59
|
+
if (item.compress) return lzutf8.compress(value, { outputEncoding: "Base64" });
|
|
60
|
+
else return value;
|
|
61
|
+
}
|
|
62
|
+
function serialize(item, value) {
|
|
63
|
+
if (item.type === "object") return JSON.stringify(value);
|
|
64
|
+
else return value;
|
|
65
|
+
}
|
|
80
66
|
}
|
|
81
|
-
|
|
67
|
+
//#endregion
|
|
82
68
|
export { createUrlStateStorage };
|
package/dist/style.css
CHANGED
|
@@ -175,6 +175,13 @@
|
|
|
175
175
|
._tree-row_16t0l_4 ._column_16t0l_44:last-child {
|
|
176
176
|
margin-right: 5px;
|
|
177
177
|
}
|
|
178
|
+
/*$vite$:1*/._bar_1gurd_1 {
|
|
179
|
+
border-bottom: 1px solid var(--colorNeutralStroke1);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
._divider_1gurd_5 {
|
|
183
|
+
flex: 1;
|
|
184
|
+
}
|
|
178
185
|
._samples-grid_1dkte_1 {
|
|
179
186
|
display: grid;
|
|
180
187
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
@@ -251,17 +258,6 @@
|
|
|
251
258
|
margin: 0;
|
|
252
259
|
line-height: 1.4;
|
|
253
260
|
}
|
|
254
|
-
._bar_15c2c_1 {
|
|
255
|
-
border-bottom: 1px solid var(--colorNeutralStroke1);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
._divider_15c2c_5 {
|
|
259
|
-
flex: 1;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
._spacer_15c2c_9 {
|
|
263
|
-
width: 10px;
|
|
264
|
-
}
|
|
265
261
|
._settings_1yvpj_1 {
|
|
266
262
|
display: flex;
|
|
267
263
|
flex-direction: column;
|
|
@@ -464,7 +460,7 @@
|
|
|
464
460
|
._viewer-error_eeqi3_41 {
|
|
465
461
|
padding: 20px;
|
|
466
462
|
}
|
|
467
|
-
.
|
|
463
|
+
._layout_63onh_1 {
|
|
468
464
|
display: flex;
|
|
469
465
|
flex-direction: column;
|
|
470
466
|
width: 100%;
|
|
@@ -472,9 +468,16 @@
|
|
|
472
468
|
overflow: hidden;
|
|
473
469
|
}
|
|
474
470
|
|
|
475
|
-
._edit-
|
|
471
|
+
._edit-pane_63onh_9 {
|
|
472
|
+
display: flex;
|
|
473
|
+
flex-direction: column;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
._single-pane_63onh_14 {
|
|
476
477
|
display: flex;
|
|
477
478
|
flex-direction: column;
|
|
479
|
+
height: 100%;
|
|
480
|
+
width: 100%;
|
|
478
481
|
}
|
|
479
482
|
._header_1qhql_1 {
|
|
480
483
|
padding: 5px;
|
|
@@ -535,8 +538,26 @@
|
|
|
535
538
|
._internal-compiler-error_kxgwp_16 {
|
|
536
539
|
padding: 10px;
|
|
537
540
|
}
|
|
541
|
+
._view-toggle-bar_1yl8k_1 {
|
|
542
|
+
display: flex;
|
|
543
|
+
align-items: center;
|
|
544
|
+
padding: 0 4px;
|
|
545
|
+
border-bottom: 1px solid var(--colorNeutralStroke1);
|
|
546
|
+
background-color: var(--colorNeutralBackground1);
|
|
547
|
+
flex-shrink: 0;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
._view-toggle-tabs_1yl8k_10 {
|
|
551
|
+
min-height: auto;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
._view-toggle-actions_1yl8k_14 {
|
|
555
|
+
margin-left: auto;
|
|
556
|
+
overflow: hidden;
|
|
557
|
+
}
|
|
538
558
|
._swagger-ui-container_1c81n_1 {
|
|
539
559
|
width: 100%;
|
|
540
560
|
height: 100%;
|
|
541
561
|
overflow: auto;
|
|
542
562
|
}
|
|
563
|
+
/*$vite$:1*/
|
package/dist/tooling/index.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { getDirectoryPath } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { getDirectoryPath } from "@typespec/compiler";
|
|
2
|
+
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
3
|
+
//#region src/tooling/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* @experimental This API is experimental
|
|
6
|
+
*/
|
|
4
7
|
async function buildSamples_experimental(rootDir, output, samples) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
].join("\n");
|
|
23
|
-
await writeFile(output, dts);
|
|
8
|
+
const resolvedSamples = {};
|
|
9
|
+
for (const [name, config] of Object.entries(samples)) {
|
|
10
|
+
const content = await readFile(`${rootDir}/${config.filename}`, "utf-8");
|
|
11
|
+
resolvedSamples[name] = {
|
|
12
|
+
filename: config.filename,
|
|
13
|
+
content,
|
|
14
|
+
preferredEmitter: config.preferredEmitter,
|
|
15
|
+
description: config.description,
|
|
16
|
+
compilerOptions: config.compilerOptions
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
await mkdir(getDirectoryPath(output), { recursive: true });
|
|
20
|
+
await writeFile(output, [
|
|
21
|
+
`import type { PlaygroundSample } from "@typespec/playground";`,
|
|
22
|
+
`const samples: Record<string, PlaygroundSample> = ${JSON.stringify(resolvedSamples, null, 2)};`,
|
|
23
|
+
`export default samples;`
|
|
24
|
+
].join("\n"));
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
//#endregion
|
|
26
27
|
export { buildSamples_experimental };
|
package/dist/vite/index.js
CHANGED
|
@@ -1,91 +1,67 @@
|
|
|
1
|
-
import { typespecBundlePlugin } from
|
|
2
|
-
import react from
|
|
3
|
-
|
|
1
|
+
import { typespecBundlePlugin } from "@typespec/bundler/vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
//#region src/vite/index.ts
|
|
4
4
|
function definePlaygroundViteConfig(config) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
plugins: [
|
|
29
|
-
react({}),
|
|
30
|
-
playgroundManifestPlugin(config),
|
|
31
|
-
!config.skipBundleLibraries ? typespecBundlePlugin({
|
|
32
|
-
folderName: "libs",
|
|
33
|
-
libraries: config.libraries
|
|
34
|
-
}) : void 0
|
|
35
|
-
],
|
|
36
|
-
server: {
|
|
37
|
-
fs: {
|
|
38
|
-
strict: false
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
5
|
+
return {
|
|
6
|
+
base: "./",
|
|
7
|
+
build: {
|
|
8
|
+
target: "esnext",
|
|
9
|
+
chunkSizeWarningLimit: 5e3,
|
|
10
|
+
rollupOptions: { output: { manualChunks(id) {
|
|
11
|
+
if (id.includes("/node_modules/monaco-editor/esm/vs/editor")) return "monaco";
|
|
12
|
+
} } }
|
|
13
|
+
},
|
|
14
|
+
esbuild: { logOverride: { "this-is-undefined-in-esm": "silent" } },
|
|
15
|
+
assetsInclude: [/\.tsp$/],
|
|
16
|
+
optimizeDeps: { exclude: ["swagger-ui"] },
|
|
17
|
+
plugins: [
|
|
18
|
+
react({}),
|
|
19
|
+
playgroundManifestPlugin(config),
|
|
20
|
+
!config.skipBundleLibraries ? typespecBundlePlugin({
|
|
21
|
+
folderName: "libs",
|
|
22
|
+
libraries: config.libraries
|
|
23
|
+
}) : void 0
|
|
24
|
+
],
|
|
25
|
+
server: { fs: { strict: false } }
|
|
26
|
+
};
|
|
42
27
|
}
|
|
43
28
|
function playgroundManifestPlugin(config) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const sampleObj = [
|
|
65
|
-
"{",
|
|
66
|
-
...Object.entries(samples ?? {}).map(
|
|
67
|
-
([label, config2], index) => `${JSON.stringify(label)}: {
|
|
68
|
-
fileName: ${JSON.stringify(config2.filename)},
|
|
69
|
-
preferredEmitter: ${config2.preferredEmitter ? JSON.stringify(config2.preferredEmitter) : "undefined"},
|
|
29
|
+
const { samples, ...manifest } = config;
|
|
30
|
+
let viteConfig;
|
|
31
|
+
return {
|
|
32
|
+
name: "playground-manifest",
|
|
33
|
+
enforce: "pre",
|
|
34
|
+
async configResolved(c) {
|
|
35
|
+
viteConfig = c;
|
|
36
|
+
},
|
|
37
|
+
resolveId(id) {
|
|
38
|
+
if (id === "@typespec/playground/manifest") return id;
|
|
39
|
+
return null;
|
|
40
|
+
},
|
|
41
|
+
load(id) {
|
|
42
|
+
if (id === `@typespec/playground/manifest`) {
|
|
43
|
+
const sampleImport = Object.values(samples ?? {}).map((sampleValue, index) => `import s${index} from "${viteConfig.root}/${sampleValue.filename}?raw"`).join("\n");
|
|
44
|
+
const sampleObj = [
|
|
45
|
+
"{",
|
|
46
|
+
...Object.entries(samples ?? {}).map(([label, config], index) => `${JSON.stringify(label)}: {
|
|
47
|
+
fileName: ${JSON.stringify(config.filename)},
|
|
48
|
+
preferredEmitter: ${config.preferredEmitter ? JSON.stringify(config.preferredEmitter) : "undefined"},
|
|
70
49
|
content: s${index},
|
|
71
|
-
${
|
|
50
|
+
${config.compilerOptions ? `compilerOptions: ${JSON.stringify(config.compilerOptions)},` : ""}
|
|
72
51
|
|
|
73
|
-
}, `
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const file = `
|
|
52
|
+
}, `),
|
|
53
|
+
"}"
|
|
54
|
+
].join("\n");
|
|
55
|
+
return `
|
|
78
56
|
${sampleImport};
|
|
79
57
|
|
|
80
58
|
export default {
|
|
81
59
|
...${JSON.stringify(manifest)},
|
|
82
60
|
samples: ${sampleObj}
|
|
83
61
|
};`;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
89
65
|
}
|
|
90
|
-
|
|
66
|
+
//#endregion
|
|
91
67
|
export { definePlaygroundViteConfig };
|