@scalar/api-client 0.9.2 → 0.9.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/index.js +30 -144
  3. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @scalar/api-client
2
2
 
3
+ ## 0.9.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [3d712d74]
8
+ - @scalar/use-codemirror@0.7.20
9
+
10
+ ## 0.9.3
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [75e1cdf8]
15
+ - @scalar/use-keyboard-event@0.5.8
16
+
3
17
  ## 0.9.2
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ var __publicField = (obj, key, value) => {
16
16
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
17
17
  return value;
18
18
  };
19
- import { defineComponent, openBlock, createBlock, resolveDynamicComponent, withCtx, createTextVNode, toDisplayString, unref, createCommentVNode, computed, onMounted, watch, reactive, readonly, ref, createElementBlock, toRaw, createElementVNode, createVNode, normalizeClass, normalizeStyle, renderSlot, Fragment, renderList, createStaticVNode, pushScopeId, popScopeId, withDirectives, withModifiers, vModelSelect, vModelText, vModelCheckbox, vShow, withKeys } from "vue";
19
+ import { defineComponent, openBlock, createBlock, resolveDynamicComponent, withCtx, createTextVNode, toDisplayString, unref, createCommentVNode, ref, onMounted, onActivated, onDeactivated, computed, watch, reactive, readonly, createElementBlock, toRaw, createElementVNode, createVNode, normalizeClass, normalizeStyle, renderSlot, Fragment, renderList, createStaticVNode, pushScopeId, popScopeId, withDirectives, withModifiers, vModelSelect, vModelText, vModelCheckbox, vShow, withKeys } from "vue";
20
20
  import { Dialog, DialogPanel, DialogTitle, DialogDescription, Disclosure, DisclosureButton, DisclosurePanel, TabGroup, TabList, Tab, TabPanels, TabPanel } from "@headlessui/vue";
21
21
  import { useMediaQuery } from "@vueuse/core";
22
22
  import TimeAgo from "javascript-time-ago";
@@ -71,6 +71,15 @@ const getThemeById = (themeId = "default") => {
71
71
  }
72
72
  return presets[themeId] ?? defaultTheme;
73
73
  };
74
+ function useActive() {
75
+ const isActive = ref(true);
76
+ onMounted(() => isActive.value = true);
77
+ onActivated(() => isActive.value = true);
78
+ onDeactivated(() => isActive.value = false);
79
+ return {
80
+ isActive: computed(() => isActive.value)
81
+ };
82
+ }
74
83
  function useKeyboardEvent({
75
84
  element,
76
85
  keyList,
@@ -83,13 +92,15 @@ function useKeyboardEvent({
83
92
  active = () => true
84
93
  }) {
85
94
  const targetEl = computed(() => (element == null ? void 0 : element.value) || "document");
95
+ const { isActive: componentIsActive } = useActive();
86
96
  const keys = keyList.map((k) => k.toLocaleLowerCase());
87
97
  const eventHandler = (event) => {
88
98
  const target = event.target;
89
99
  const isInput = ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName) || target.contentEditable;
90
100
  if (
91
- // Check for command or ctrl keys
92
- (withCtrlCmd ? event.ctrlKey || event.metaKey : !event.ctrlKey && !event.metaKey) && // Check for shift key
101
+ // Check if the component is active (e.g. in a `<keepalive>`)
102
+ (componentIsActive.value && // Check for command or ctrl keys
103
+ withCtrlCmd ? event.ctrlKey || event.metaKey : !event.ctrlKey && !event.metaKey) && // Check for shift key
93
104
  (withShift ? event.shiftKey : !event.shiftKey) && // Check for alt key
94
105
  (withAlt ? event.altKey : !event.altKey) && // Check whether or not to ignore inputs
95
106
  (!ignoreInputElements || !isInput) && // Check for key match
@@ -13990,7 +14001,7 @@ function scaleBlock(block, scaler) {
13990
14001
  return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map((b) => scaleBlock(b, scaler)) : block._content);
13991
14002
  }
13992
14003
  const theme = /* @__PURE__ */ Facet.define({ combine: (strs) => strs.join(" ") });
13993
- const darkTheme$1 = /* @__PURE__ */ Facet.define({ combine: (values2) => values2.indexOf(true) > -1 });
14004
+ const darkTheme = /* @__PURE__ */ Facet.define({ combine: (values2) => values2.indexOf(true) > -1 });
13994
14005
  const baseThemeID = /* @__PURE__ */ StyleModule.newName(), baseLightID = /* @__PURE__ */ StyleModule.newName(), baseDarkID = /* @__PURE__ */ StyleModule.newName();
13995
14006
  const lightDarkIDs = { "&light": "." + baseLightID, "&dark": "." + baseDarkID };
13996
14007
  function buildTheme(main, spec, scopes) {
@@ -15318,7 +15329,7 @@ class EditorView {
15318
15329
  Get the CSS classes for the currently active editor themes.
15319
15330
  */
15320
15331
  get themeClasses() {
15321
- return baseThemeID + " " + (this.state.facet(darkTheme$1) ? baseDarkID : baseLightID) + " " + this.state.facet(theme);
15332
+ return baseThemeID + " " + (this.state.facet(darkTheme) ? baseDarkID : baseLightID) + " " + this.state.facet(theme);
15322
15333
  }
15323
15334
  updateAttrs() {
15324
15335
  let editorAttrs = attrsFromFacet(this, editorAttributes, {
@@ -15754,7 +15765,7 @@ class EditorView {
15754
15765
  let prefix = StyleModule.newName();
15755
15766
  let result = [theme.of(prefix), styleModule.of(buildTheme(`.${prefix}`, spec))];
15756
15767
  if (options && options.dark)
15757
- result.push(darkTheme$1.of(true));
15768
+ result.push(darkTheme.of(true));
15758
15769
  return result;
15759
15770
  }
15760
15771
  /**
@@ -15792,7 +15803,7 @@ EditorView.decorations = decorations;
15792
15803
  EditorView.atomicRanges = atomicRanges;
15793
15804
  EditorView.bidiIsolatedRanges = bidiIsolatedRanges;
15794
15805
  EditorView.scrollMargins = scrollMargins;
15795
- EditorView.darkTheme = darkTheme$1;
15806
+ EditorView.darkTheme = darkTheme;
15796
15807
  EditorView.cspNonce = /* @__PURE__ */ Facet.define({ combine: (values2) => values2.length ? values2[0] : "" });
15797
15808
  EditorView.contentAttributes = contentAttributes;
15798
15809
  EditorView.editorAttributes = editorAttributes;
@@ -24745,7 +24756,7 @@ var createTheme = (_ref) => {
24745
24756
  var extension = [themeExtension, syntaxHighlighting(highlightStyle)];
24746
24757
  return extension;
24747
24758
  };
24748
- const lightTheme = createTheme({
24759
+ const customTheme = createTheme({
24749
24760
  theme: "light",
24750
24761
  settings: {
24751
24762
  background: "var(--theme-background-2, var(--default-theme-background-2))",
@@ -24831,95 +24842,8 @@ const lightTheme = createTheme({
24831
24842
  }
24832
24843
  ]
24833
24844
  });
24834
- const darkTheme = createTheme({
24835
- theme: "dark",
24836
- settings: {
24837
- background: "var(--theme-background-2, var(--default-theme-background-2))",
24838
- foreground: "var(--theme-color-1, var(--default-theme-color-1))",
24839
- caret: "var(--theme-color-1, var(--default-theme-color-1))",
24840
- selection: "var(--theme-background-3, var(--default-theme-background-3))",
24841
- selectionMatch: "#e3dcce",
24842
- gutterBackground: "var(--theme-background-2, var(--default-theme-background-2))",
24843
- gutterForeground: "var(--theme-color-3, var(--default-theme-color-3))",
24844
- gutterBorder: "transparent",
24845
- lineHighlight: "var(--theme-background-3, var(--default-theme-background-3))",
24846
- fontFamily: "var(--theme-font-code, var(--default-theme-font-code))"
24847
- },
24848
- styles: [
24849
- {
24850
- tag: [tags$1.standard(tags$1.tagName), tags$1.tagName],
24851
- color: "var(--theme-color-purple, var(--default-theme-color-purple))"
24852
- },
24853
- {
24854
- tag: [tags$1.comment],
24855
- color: "var(--theme-color-3, var(--default-theme-color-3))"
24856
- },
24857
- {
24858
- tag: [tags$1.className],
24859
- color: "var(--theme-color-orange, var(--default-theme-color-orange))"
24860
- },
24861
- {
24862
- tag: [tags$1.variableName, tags$1.propertyName, tags$1.attributeName],
24863
- color: "var(--theme-color-1, var(--default-theme-color-1))"
24864
- },
24865
- {
24866
- tag: [tags$1.operator],
24867
- color: "var(--theme-color-2, var(--default-theme-color-2))"
24868
- },
24869
- {
24870
- tag: [tags$1.keyword, tags$1.typeName, tags$1.typeOperator],
24871
- color: "var(--theme-color-green, var(--default-theme-color-green))"
24872
- },
24873
- {
24874
- tag: [tags$1.string],
24875
- color: "var(--theme-color-blue, var(--default-theme-color-blue))"
24876
- },
24877
- {
24878
- tag: [tags$1.bracket, tags$1.regexp, tags$1.meta],
24879
- color: "var(--theme-color-3, var(--default-theme-color-3))"
24880
- },
24881
- {
24882
- tag: [tags$1.number],
24883
- color: "var(--theme-color-blue, var(--default-theme-color-blue))"
24884
- },
24885
- {
24886
- tag: [tags$1.name, tags$1.quote],
24887
- color: "var(--theme-color-3, var(--default-theme-color-3))"
24888
- },
24889
- {
24890
- tag: [tags$1.heading],
24891
- color: "var(--theme-color-3, var(--default-theme-color-3))",
24892
- fontWeight: "bold"
24893
- },
24894
- {
24895
- tag: [tags$1.emphasis],
24896
- color: "var(--theme-color-3, var(--default-theme-color-3))",
24897
- fontStyle: "italic"
24898
- },
24899
- {
24900
- tag: [tags$1.deleted],
24901
- color: "var(--theme-color-3, var(--default-theme-color-3))",
24902
- backgroundColor: "transparent"
24903
- },
24904
- {
24905
- tag: [tags$1.atom, tags$1.bool, tags$1.special(tags$1.variableName)],
24906
- color: "var(--theme-color-3, var(--default-theme-color-3))"
24907
- },
24908
- {
24909
- tag: [tags$1.url, tags$1.escape, tags$1.regexp, tags$1.link],
24910
- color: "var(--theme-color-1, var(--default-theme-color-1))"
24911
- },
24912
- { tag: tags$1.link, textDecoration: "underline" },
24913
- { tag: tags$1.strikethrough, textDecoration: "line-through" },
24914
- {
24915
- tag: tags$1.invalid,
24916
- color: "var(--theme-color-3, var(--default-theme-color-3))"
24917
- }
24918
- ]
24919
- });
24920
- const isDark = ref(false);
24921
24845
  const useCodeMirror = (parameters) => {
24922
- const { extensions, content: content2, forceDarkMode, forceLightMode, withoutTheme } = parameters;
24846
+ const { extensions, content: content2, withoutTheme } = parameters;
24923
24847
  const value = ref(content2 ?? "");
24924
24848
  const codeMirrorRef = ref(null);
24925
24849
  const codeMirror = ref(null);
@@ -24939,55 +24863,20 @@ const useCodeMirror = (parameters) => {
24939
24863
  codeMirror.value = new EditorView(configuration);
24940
24864
  }
24941
24865
  };
24942
- const getCurrentTheme = () => {
24943
- if (withoutTheme) {
24944
- return null;
24945
- }
24946
- if (forceDarkMode) {
24947
- return darkTheme;
24948
- }
24949
- if (forceLightMode) {
24950
- return lightTheme;
24951
- }
24952
- if (isDark.value) {
24953
- return darkTheme;
24954
- }
24955
- return lightTheme;
24956
- };
24957
24866
  const addDefaultExtensions = (newExtensions = []) => {
24958
- const selectAllKeyBinding = {
24959
- key: "Mod-a",
24960
- run: (view) => {
24961
- view.dispatch({
24962
- selection: { anchor: 0, head: view.state.doc.length },
24963
- scrollIntoView: false
24964
- });
24965
- return true;
24966
- }
24967
- };
24968
24867
  const defaultExtensions = [
24969
- EditorView.theme(
24970
- {
24971
- ".cm-line": {
24972
- lineHeight: "20px"
24973
- },
24974
- ".cm-gutterElement": {
24975
- lineHeight: "20px"
24976
- }
24868
+ withoutTheme ? null : customTheme,
24869
+ EditorView.theme({
24870
+ ".cm-line": {
24871
+ lineHeight: "20px"
24977
24872
  },
24978
- { dark: forceDarkMode ? false : isDark.value }
24979
- ),
24980
- keymap.of([selectAllKeyBinding]),
24981
- getCurrentTheme()
24873
+ ".cm-gutterElement": {
24874
+ lineHeight: "20px"
24875
+ }
24876
+ })
24982
24877
  ].filter((extension) => extension !== null);
24983
24878
  return [...defaultExtensions, newExtensions];
24984
24879
  };
24985
- watch(isDark, () => {
24986
- const { extensions: configuredExtensions } = parameters;
24987
- if (!forceDarkMode) {
24988
- reconfigureCodeMirror(configuredExtensions);
24989
- }
24990
- });
24991
24880
  const destroyCodeMirror = () => {
24992
24881
  var _a2;
24993
24882
  (_a2 = codeMirror.value) == null ? void 0 : _a2.destroy();
@@ -25099,8 +24988,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
25099
24988
  withVariables: { type: Boolean },
25100
24989
  lineNumbers: { type: Boolean },
25101
24990
  withoutTheme: { type: Boolean },
25102
- disableEnter: { type: Boolean, default: false },
25103
- forceDarkMode: { type: Boolean, default: false }
24991
+ disableEnter: { type: Boolean, default: false }
25104
24992
  },
25105
24993
  emits: ["change"],
25106
24994
  setup(__props, { expose: __expose, emit }) {
@@ -25196,8 +25084,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
25196
25084
  } = useCodeMirror({
25197
25085
  content: props.content ?? "",
25198
25086
  extensions: getCodeMirrorExtensions(),
25199
- withoutTheme: props.withoutTheme,
25200
- forceDarkMode: props.forceDarkMode
25087
+ withoutTheme: props.withoutTheme
25201
25088
  });
25202
25089
  watch(
25203
25090
  () => props.content,
@@ -25214,7 +25101,6 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
25214
25101
  watch(
25215
25102
  [
25216
25103
  () => props.disableEnter,
25217
- () => props.forceDarkMode,
25218
25104
  () => props.languages,
25219
25105
  () => props.lineNumbers,
25220
25106
  () => props.readOnly,
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "rest",
14
14
  "testing"
15
15
  ],
16
- "version": "0.9.2",
16
+ "version": "0.9.4",
17
17
  "engines": {
18
18
  "node": ">=18"
19
19
  },
@@ -44,21 +44,21 @@
44
44
  "pretty-ms": "^8.0.0",
45
45
  "vue": "^3.3.0",
46
46
  "@scalar/themes": "0.5.4",
47
- "@scalar/use-codemirror": "0.7.19",
48
- "@scalar/use-modal": "0.2.3",
49
- "@scalar/use-keyboard-event": "0.5.7"
47
+ "@scalar/use-codemirror": "0.7.20",
48
+ "@scalar/use-keyboard-event": "0.5.8",
49
+ "@scalar/use-modal": "0.2.3"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/content-type": "^1.1.6",
53
53
  "@vitejs/plugin-vue": "^4.4.0",
54
54
  "@vitest/coverage-v8": "^0.34.4",
55
55
  "tsc-alias": "^1.8.8",
56
- "vite": "^4.4.12",
56
+ "vite": "^4.5.2",
57
57
  "vite-plugin-css-injected-by-js": "^3.3.0",
58
58
  "vitest": "^0.34.4",
59
59
  "vue-tsc": "^1.8.19",
60
- "@scalar/api-client-proxy": "0.5.13",
61
- "@scalar/echo-server": "0.5.8"
60
+ "@scalar/echo-server": "0.5.8",
61
+ "@scalar/api-client-proxy": "0.5.13"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "vue": "^3.3.0"