timvir 0.2.14 → 0.2.16

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.
@@ -64,12 +64,12 @@ function Code(props, ref) {
64
64
  React.useEffect(() => {
65
65
  (async () => {
66
66
  const html = await codeToHtml(children.trim(), {
67
- lang: language !== null && language !== void 0 ? language : "markup",
67
+ lang: language ?? "markup",
68
68
  themes: {
69
69
  light: "github-light",
70
70
  dark: "github-dark"
71
71
  },
72
- decorations: (highlightedLines !== null && highlightedLines !== void 0 ? highlightedLines : []).map(line => ({
72
+ decorations: (highlightedLines ?? []).map(line => ({
73
73
  start: {
74
74
  line: line - 1,
75
75
  character: 0
@@ -36,7 +36,6 @@ var cx_default = cx;
36
36
  */
37
37
  const Root = "div";
38
38
  function ColorBar(props, ref) {
39
- var _selected$value;
40
39
  const block = useBlock(props);
41
40
  const {
42
41
  values,
@@ -69,7 +68,7 @@ function ColorBar(props, ref) {
69
68
  ...(typeof selected === "string" ? {
70
69
  value: selected
71
70
  } : {
72
- value: (_selected$value = selected === null || selected === void 0 ? void 0 : selected.value) !== null && _selected$value !== void 0 ? _selected$value : ""
71
+ value: selected?.value ?? ""
73
72
  }),
74
73
  onMouseLeave: () => {
75
74
  setSelected(undefined);
@@ -127,7 +127,7 @@ function Icon(props, ref) {
127
127
  ...rest
128
128
  } = props;
129
129
  const [roRef, roe] = useResizeObserverEntry();
130
- const width = roe === null || roe === void 0 ? void 0 : roe.contentRect.width;
130
+ const width = roe?.contentRect.width;
131
131
  return /*#__PURE__*/React.createElement(Root, {
132
132
  ref: ref,
133
133
  className: cx_default(className, "r1k0w618"),
@@ -61,11 +61,11 @@ function Swatch(props, ref) {
61
61
  onClick: ev => {
62
62
  navigator.clipboard.writeText(value);
63
63
  setLabel("Copied to clipboard");
64
- onClick === null || onClick === void 0 ? void 0 : onClick(ev);
64
+ onClick?.(ev);
65
65
  },
66
66
  onMouseLeave: ev => {
67
67
  setLabel(name);
68
- onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(ev);
68
+ onMouseLeave?.(ev);
69
69
  }
70
70
  }, /*#__PURE__*/React.createElement("div", {
71
71
  className: "dhgsgky",
@@ -147,7 +147,6 @@ function Ruler(props) {
147
147
  */
148
148
  const Root = "div";
149
149
  function Viewport(props, ref) {
150
- var _iframeRef$current, _iframeRef$current$co;
151
150
  const block = useBlock(props);
152
151
  const {
153
152
  src,
@@ -186,13 +185,10 @@ function Viewport(props, ref) {
186
185
  if (lock.current && svgROE) {
187
186
  ev.preventDefault();
188
187
  const max = svgROE.contentRect.width - 2 * (56 + 8 + 8);
189
- setWidth(width => {
190
- var _left$right$lock$curr;
191
- return Math.min(max, Math.max(320, (width !== null && width !== void 0 ? width : 0) + 2 * ev.movementX * ((_left$right$lock$curr = {
192
- left: -1,
193
- right: 1
194
- }[lock.current]) !== null && _left$right$lock$curr !== void 0 ? _left$right$lock$curr : 1)));
195
- });
188
+ setWidth(width => Math.min(max, Math.max(320, (width ?? 0) + 2 * ev.movementX * ({
189
+ left: -1,
190
+ right: 1
191
+ }[lock.current] ?? 1))));
196
192
  }
197
193
  };
198
194
  const onMouseUp = () => {
@@ -214,7 +210,7 @@ function Viewport(props, ref) {
214
210
  const iframeRO = useResizeObserver(entries => {
215
211
  const height = entries[entries.length - 1].contentRect.height;
216
212
  setHeight(height);
217
- setMaxHeight(Math.max(height, maxHeight !== null && maxHeight !== void 0 ? maxHeight : 0));
213
+ setMaxHeight(Math.max(height, maxHeight ?? 0));
218
214
  });
219
215
 
220
216
  /*
@@ -225,7 +221,7 @@ function Viewport(props, ref) {
225
221
  * We hope that nobody intentionally adds margins around the <html> element. By default
226
222
  * it doesn't have.
227
223
  */
228
- const html = (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentDocument) === null || _iframeRef$current$co === void 0 ? void 0 : _iframeRef$current$co.querySelector("html");
224
+ const html = iframeRef.current?.contentDocument?.querySelector("html");
229
225
  React.useEffect(() => {
230
226
  if (html) {
231
227
  iframeRO.observe(html);
@@ -241,7 +237,7 @@ function Viewport(props, ref) {
241
237
  ref: svgRef,
242
238
  className: "d1uj09ka"
243
239
  }, /*#__PURE__*/React.createElement(Ruler, {
244
- containerWidth: svgROE === null || svgROE === void 0 ? void 0 : svgROE.contentRect.width,
240
+ containerWidth: svgROE?.contentRect.width,
245
241
  viewportWidth: width
246
242
  }), /*#__PURE__*/React.createElement("div", {
247
243
  className: "d2uawyc"
@@ -260,13 +256,12 @@ function Viewport(props, ref) {
260
256
  frameBorder: "0",
261
257
  src: src,
262
258
  onLoad: () => {
263
- var _iframeRef$current2, _iframeRef$current2$c;
264
259
  /*
265
260
  * Once the iframe has loaded, initialize the height/maxHeight.
266
261
  * The <html> element may not exist though (eg. the page failed
267
262
  * to load, or it's not a HTML page).
268
263
  */
269
- const html = (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentDocument) === null || _iframeRef$current2$c === void 0 ? void 0 : _iframeRef$current2$c.querySelector("html");
264
+ const html = iframeRef.current?.contentDocument?.querySelector("html");
270
265
  if (html) {
271
266
  const {
272
267
  height
@@ -291,14 +286,14 @@ function Viewport(props, ref) {
291
286
  edge: "right",
292
287
  iframeRef: iframeRef
293
288
  })))), /*#__PURE__*/React.createElement(Ruler, {
294
- containerWidth: svgROE === null || svgROE === void 0 ? void 0 : svgROE.contentRect.width,
289
+ containerWidth: svgROE?.contentRect.width,
295
290
  viewportWidth: width
296
291
  })), /*#__PURE__*/React.createElement(Caption$1, {
297
292
  src: src,
298
293
  code: code
299
294
  }), /*#__PURE__*/React.createElement("div", {
300
295
  style: {
301
- height: (maxHeight !== null && maxHeight !== void 0 ? maxHeight : 0) - (height !== null && height !== void 0 ? height : 0),
296
+ height: (maxHeight ?? 0) - (height ?? 0),
302
297
  transition: "height 0.16s"
303
298
  }
304
299
  }));
@@ -35,7 +35,6 @@ var cx_default = cx;
35
35
  */
36
36
  const Root = "a";
37
37
  function WebLink(props, ref) {
38
- var _useContext$blocks$We, _useContext$blocks, _metadata$open_graph, _metadata$open_graph$, _metadata$open_graph$2, _ref, _metadata$open_graph$3, _metadata$open_graph2, _metadata$open_graph$4, _metadata$open_graph3;
39
38
  const {
40
39
  url,
41
40
  className,
@@ -44,11 +43,11 @@ function WebLink(props, ref) {
44
43
  const [metadata, setMetadata] = React.useState(undefined);
45
44
  const {
46
45
  unfurl = defaultUnfurl
47
- } = (_useContext$blocks$We = (_useContext$blocks = useContext().blocks) === null || _useContext$blocks === void 0 ? void 0 : _useContext$blocks.WebLink) !== null && _useContext$blocks$We !== void 0 ? _useContext$blocks$We : {};
46
+ } = useContext().blocks?.WebLink ?? {};
48
47
  React.useEffect(() => {
49
48
  unfurl(url).then(setMetadata);
50
49
  }, [url, setMetadata]);
51
- const image = metadata === null || metadata === void 0 ? void 0 : (_metadata$open_graph = metadata.open_graph) === null || _metadata$open_graph === void 0 ? void 0 : (_metadata$open_graph$ = _metadata$open_graph.images) === null || _metadata$open_graph$ === void 0 ? void 0 : (_metadata$open_graph$2 = _metadata$open_graph$[0]) === null || _metadata$open_graph$2 === void 0 ? void 0 : _metadata$open_graph$2.url;
50
+ const image = metadata?.open_graph?.images?.[0]?.url;
52
51
  return /*#__PURE__*/React.createElement(Root, {
53
52
  ref: ref,
54
53
  href: url,
@@ -60,16 +59,16 @@ function WebLink(props, ref) {
60
59
  className: classes.text
61
60
  }, /*#__PURE__*/React.createElement("div", {
62
61
  className: classes.title
63
- }, (_ref = (_metadata$open_graph$3 = metadata === null || metadata === void 0 ? void 0 : (_metadata$open_graph2 = metadata.open_graph) === null || _metadata$open_graph2 === void 0 ? void 0 : _metadata$open_graph2.title) !== null && _metadata$open_graph$3 !== void 0 ? _metadata$open_graph$3 : metadata === null || metadata === void 0 ? void 0 : metadata.title) !== null && _ref !== void 0 ? _ref : /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0")), /*#__PURE__*/React.createElement("div", {
62
+ }, metadata?.open_graph?.title ?? metadata?.title ?? /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0")), /*#__PURE__*/React.createElement("div", {
64
63
  className: classes.description
65
- }, (_metadata$open_graph$4 = metadata === null || metadata === void 0 ? void 0 : (_metadata$open_graph3 = metadata.open_graph) === null || _metadata$open_graph3 === void 0 ? void 0 : _metadata$open_graph3.description) !== null && _metadata$open_graph$4 !== void 0 ? _metadata$open_graph$4 : metadata === null || metadata === void 0 ? void 0 : metadata.description), /*#__PURE__*/React.createElement("div", {
64
+ }, metadata?.open_graph?.description ?? metadata?.description), /*#__PURE__*/React.createElement("div", {
66
65
  className: classes.url
67
66
  }, /*#__PURE__*/React.createElement("img", {
68
67
  style: {
69
- opacity: metadata !== null && metadata !== void 0 && metadata.favicon ? 1 : 0
68
+ opacity: metadata?.favicon ? 1 : 0
70
69
  },
71
70
  className: classes.favicon,
72
- src: metadata === null || metadata === void 0 ? void 0 : metadata.favicon
71
+ src: metadata?.favicon
73
72
  }), /*#__PURE__*/React.createElement("div", null, metadata ? url : null))), image && /*#__PURE__*/React.createElement("div", {
74
73
  className: classes.imageContainer
75
74
  }, /*#__PURE__*/React.createElement("img", {
package/core/index.js CHANGED
@@ -159,7 +159,7 @@ function Dialog(props) {
159
159
  transform: "scale(0.95)"
160
160
  };
161
161
  setTimeout(() => {
162
- onDispose === null || onDispose === void 0 ? void 0 : onDispose();
162
+ onDispose === null || onDispose === void 0 || onDispose();
163
163
  }, 200);
164
164
  }
165
165
  });
@@ -202,7 +202,7 @@ function Dialog(props) {
202
202
  key: index,
203
203
  label: node.label,
204
204
  onClick: () => {
205
- onClose === null || onClose === void 0 ? void 0 : onClose();
205
+ onClose === null || onClose === void 0 || onClose();
206
206
  window.location.href = node.path;
207
207
  }
208
208
  })))));
@@ -216,7 +216,7 @@ const classes$3 = {
216
216
  };
217
217
 
218
218
  function Commands(props) {
219
- var _state$dialog$reactPo, _state$dialog;
219
+ var _state$dialog;
220
220
  const [state, mutate] = useImmer({
221
221
  /**
222
222
  * Whether the command palette should be open or not. The command palette is
@@ -314,7 +314,7 @@ function Commands(props) {
314
314
  };
315
315
  }
316
316
  }, [state.open]);
317
- return (_state$dialog$reactPo = (_state$dialog = state.dialog) === null || _state$dialog === void 0 ? void 0 : _state$dialog.reactPortal) !== null && _state$dialog$reactPo !== void 0 ? _state$dialog$reactPo : null;
317
+ return ((_state$dialog = state.dialog) === null || _state$dialog === void 0 ? void 0 : _state$dialog.reactPortal) ?? null;
318
318
  }
319
319
  const classes$2 = {
320
320
  root: "rfei6z8"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "timvir",
4
- "version": "0.2.14",
4
+ "version": "0.2.16",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
7
7
  "exports": {
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "bytestring": "^1",
19
- "downshift": "^7",
19
+ "downshift": "^7 || ^8 || ^9",
20
20
  "fuzzaldrin-plus": "^0.6.0",
21
21
  "immer": "^9 || ^10",
22
22
  "shiki": "^1",
package/search/index.js CHANGED
@@ -97,14 +97,12 @@ const Highlight = ({
97
97
  }
98
98
  });
99
99
  };
100
- var Highlight$1 = Highlight;
101
100
 
102
101
  /**
103
102
  * The underlying DOM element which is rendered by this component.
104
103
  */
105
104
  const Root = "div";
106
105
  function Dialog(props, ref) {
107
- var _result$edges;
108
106
  const {
109
107
  onClose,
110
108
  q,
@@ -122,7 +120,7 @@ function Dialog(props, ref) {
122
120
  setResult(result);
123
121
  });
124
122
  }, [value, q, setResult]);
125
- const items = (_result$edges = result === null || result === void 0 ? void 0 : result.edges) !== null && _result$edges !== void 0 ? _result$edges : [];
123
+ const items = (result === null || result === void 0 ? void 0 : result.edges) ?? [];
126
124
  const {
127
125
  getMenuProps,
128
126
  getInputProps,
@@ -135,7 +133,7 @@ function Dialog(props, ref) {
135
133
  onInputValueChange: ({
136
134
  inputValue
137
135
  }) => {
138
- setValue(inputValue !== null && inputValue !== void 0 ? inputValue : "");
136
+ setValue(inputValue ?? "");
139
137
  },
140
138
  onSelectedItemChange: ({
141
139
  selectedItem
@@ -201,7 +199,7 @@ function Dialog(props, ref) {
201
199
  }), /*#__PURE__*/React.createElement("path", {
202
200
  d: "M9.5 0.5L9.5 5.5 14.5 5.5"
203
201
  }))),
204
- label: /*#__PURE__*/React.createElement(Highlight$1, {
202
+ label: /*#__PURE__*/React.createElement(Highlight, {
205
203
  string: item.node.path,
206
204
  query: value
207
205
  }),