@typespec/playground 0.6.0-dev.2 → 0.6.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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { c as createBrowserHost, r as registerMonacoLanguage } from './services-CJ51i-Fc.js';
1
+ export { c as createBrowserHost, r as registerMonacoLanguage } from './services-VCejxTUV.js';
2
2
  export { createUrlStateStorage } from './state-storage.js';
3
3
 
4
4
  function registerMonacoDefaultWorkersForVite() {
@@ -5,7 +5,7 @@ import { mergeClasses, Popover, PopoverTrigger, PopoverSurface, Title3, Table, T
5
5
  import { Settings24Regular, Save16Regular, Broom16Filled, Bug16Regular, FolderListRegular, DataLineRegular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
6
6
  import debounce from 'debounce';
7
7
  import { CompletionItemTag } from 'vscode-languageserver';
8
- import { a as resolveVirtualPath, g as getMonacoRange, c as createBrowserHost, r as registerMonacoLanguage } from '../services-CJ51i-Fc.js';
8
+ import { a as resolveVirtualPath, g as getMonacoRange, c as createBrowserHost, r as registerMonacoLanguage } from '../services-VCejxTUV.js';
9
9
  import { ErrorBoundary } from 'react-error-boundary';
10
10
  import { TypeGraph } from '@typespec/html-program-viewer/react';
11
11
  import '@typespec/html-program-viewer/style.css';
@@ -34,9 +34,6 @@ const Editor = ({ model, options, actions, onMount }) => {
34
34
  });
35
35
  onMount?.({ editor: editorRef.current });
36
36
  }, []);
37
- useEffect(() => {
38
- editor.setTheme(options.theme ?? "typespec");
39
- }, [options.theme]);
40
37
  useEffect(() => {
41
38
  const disposables = [];
42
39
  for (const command of actions ?? []) {
@@ -1586,15 +1583,20 @@ const Sash = ({
1586
1583
  ...others
1587
1584
  }) => {
1588
1585
  const [draging, setDrag] = useState(false);
1589
- const handleMouseMove = (e) => {
1590
- onDragging(e);
1591
- };
1586
+ const handleMouseMove = (e) => onDragging(createDraggingEventFromMouseEvent(e));
1592
1587
  const handleMouseUp = (e) => {
1593
1588
  setDrag(false);
1594
- onDragEnd(e);
1589
+ onDragEnd(createDraggingEventFromMouseEvent(e));
1595
1590
  window.removeEventListener("mousemove", handleMouseMove);
1596
1591
  window.removeEventListener("mouseup", handleMouseUp);
1597
1592
  };
1593
+ const handleTouchMove = (e) => onDragging(createDraggingEventFromTouchEvent(e));
1594
+ const handleTouchUp = (e) => {
1595
+ setDrag(false);
1596
+ onDragEnd(createDraggingEventFromTouchEvent(e));
1597
+ window.removeEventListener("touchmove", handleTouchMove);
1598
+ window.removeEventListener("touchend", handleTouchUp);
1599
+ };
1598
1600
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
1599
1601
  "div",
1600
1602
  {
@@ -1602,16 +1604,37 @@ const Sash = ({
1602
1604
  className: mergeClasses(style$1$1["sash"], className),
1603
1605
  onMouseDown: (e) => {
1604
1606
  setDrag(true);
1605
- onDragStart(e);
1607
+ onDragStart(createDraggingEventFromMouseEvent(e));
1606
1608
  window.addEventListener("mousemove", handleMouseMove);
1607
1609
  window.addEventListener("mouseup", handleMouseUp);
1608
1610
  },
1611
+ onTouchStart: (e) => {
1612
+ setDrag(true);
1613
+ onDragStart(createDraggingEventFromTouchEvent(e));
1614
+ window.addEventListener("touchmove", handleTouchMove);
1615
+ window.addEventListener("touchend", handleTouchUp);
1616
+ },
1609
1617
  onDoubleClick: onReset,
1610
1618
  ...others,
1611
1619
  children: render(draging)
1612
1620
  }
1613
1621
  );
1614
1622
  };
1623
+ function createDraggingEventFromMouseEvent(originalEvent) {
1624
+ return {
1625
+ originalEvent,
1626
+ pageX: originalEvent.pageX,
1627
+ pageY: originalEvent.pageY
1628
+ };
1629
+ }
1630
+ function createDraggingEventFromTouchEvent(originalEvent) {
1631
+ const lastTouch = originalEvent.touches[originalEvent.touches.length - 1];
1632
+ return {
1633
+ originalEvent,
1634
+ pageX: lastTouch.clientX,
1635
+ pageY: lastTouch.clientY
1636
+ };
1637
+ }
1615
1638
 
1616
1639
  const defaultDimensions = { width: 0, height: 0 };
1617
1640
  function useElDimensions(ref) {
@@ -2600,6 +2623,9 @@ const ProblemPaneContent = ({
2600
2623
  const Playground = (props) => {
2601
2624
  const { host, onSave } = props;
2602
2625
  const editorRef = useRef(void 0);
2626
+ useEffect(() => {
2627
+ editor.setTheme(props.editorOptions?.theme ?? "typespec");
2628
+ }, [props.editorOptions?.theme]);
2603
2629
  const [selectedEmitter, onSelectedEmitterChange] = useControllableValue(
2604
2630
  props.emitter,
2605
2631
  props.defaultEmitter,
@@ -518,7 +518,6 @@ async function registerMonacoLanguage(host) {
518
518
  { token: "function", foreground: "#E06C75" }
519
519
  ]
520
520
  });
521
- monaco.editor.setTheme("typespec");
522
521
  monaco.languages.registerDocumentSemanticTokensProvider("typespec", {
523
522
  getLegend() {
524
523
  const legend = lsConfig.capabilities.semanticTokensProvider.legend;
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/react/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,MAAM,EAAoB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE3E,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC,oCAAoC,CAAC;IACrD,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC,qBAAqB,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,CA2CjD,CAAC;AAEF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAK5E"}
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/react/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,MAAM,EAAoB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE3E,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC,oCAAoC,CAAC;IACrD,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC,qBAAqB,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,CAuCjD,CAAC;AAEF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAK5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/react/playground.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,oBAAoB,CAAC;AAEtE,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;AAOjE,OAAO,KAAK,EAAoB,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC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e;IAC9B,4BAA4B;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAgOzD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmC9C,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,WAAW,iBAiU7D;AAED,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,cAAc,oBAAoB,CAAC,EACrD,MAAM,EAAE,gBAAgB,GAAG,OAAO,QAAQ,GACzC,MAAM,CAAC,MAAM,CAkBf"}
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmC9C,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,WAAW,iBAgU7D;AAED,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,cAAc,oBAAoB,CAAC,EACrD,MAAM,EAAE,gBAAgB,GAAG,OAAO,QAAQ,GACzC,MAAM,CAAC,MAAM,CAkBf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/playground",
3
- "version": "0.6.0-dev.2",
3
+ "version": "0.6.0",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec playground UI components.",
6
6
  "homepage": "https://typespec.io",
@@ -61,15 +61,6 @@
61
61
  "dependencies": {
62
62
  "@fluentui/react-components": "~9.55.0",
63
63
  "@fluentui/react-icons": "^2.0.260",
64
- "@typespec/bundler": "~0.1.8 || >=0.2.0-dev <0.2.0",
65
- "@typespec/compiler": "~0.61.0 || >=0.62.0-dev <0.62.0",
66
- "@typespec/html-program-viewer": "~0.61.0 || >=0.62.0-dev <0.62.0",
67
- "@typespec/http": "~0.61.0 || >=0.62.0-dev <0.62.0",
68
- "@typespec/openapi": "~0.61.0 || >=0.62.0-dev <0.62.0",
69
- "@typespec/openapi3": "~0.61.0 || >=0.62.0-dev <0.62.0",
70
- "@typespec/protobuf": "~0.61.0 || >=0.62.0-dev <0.62.0",
71
- "@typespec/rest": "~0.61.0 || >=0.62.0-dev <0.62.0",
72
- "@typespec/versioning": "~0.61.0 || >=0.62.0-dev <0.62.0",
73
64
  "clsx": "^2.1.1",
74
65
  "debounce": "~2.1.1",
75
66
  "lzutf8": "0.6.3",
@@ -79,7 +70,16 @@
79
70
  "react-error-boundary": "^4.0.13",
80
71
  "swagger-ui-dist": "^5.17.14",
81
72
  "vscode-languageserver": "~9.0.1",
82
- "vscode-languageserver-textdocument": "~1.0.12"
73
+ "vscode-languageserver-textdocument": "~1.0.12",
74
+ "@typespec/bundler": "~0.1.9",
75
+ "@typespec/compiler": "~0.62.0",
76
+ "@typespec/http": "~0.62.0",
77
+ "@typespec/html-program-viewer": "~0.62.0",
78
+ "@typespec/openapi": "~0.62.0",
79
+ "@typespec/openapi3": "~0.62.0",
80
+ "@typespec/protobuf": "~0.62.0",
81
+ "@typespec/rest": "~0.62.0",
82
+ "@typespec/versioning": "~0.62.0"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@babel/core": "^7.25.2",
@@ -95,7 +95,6 @@
95
95
  "@types/react": "~18.3.11",
96
96
  "@types/react-dom": "~18.3.0",
97
97
  "@types/swagger-ui-dist": "~3.30.5",
98
- "@typespec/bundler": "~0.1.8 || >=0.2.0-dev <0.2.0",
99
98
  "@vitejs/plugin-react": "~4.3.2",
100
99
  "c8": "^10.1.2",
101
100
  "cross-env": "~7.0.3",
@@ -105,9 +104,9 @@
105
104
  "vite": "^5.4.8",
106
105
  "vite-plugin-checker": "^0.8.0",
107
106
  "vite-plugin-dts": "4.2.3",
108
- "@typespec/react-components": "~0.57.0"
107
+ "@typespec/react-components": "~0.57.0",
108
+ "@typespec/bundler": "~0.1.9"
109
109
  },
110
- "peerDependencies": {},
111
110
  "scripts": {
112
111
  "clean": "rimraf ./dist ./dist-dev ./temp ./typespecContents.json",
113
112
  "build": "vite build",