vzcode 0.42.0 → 0.43.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.html CHANGED
@@ -24,7 +24,7 @@
24
24
  href="https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css"
25
25
  rel="stylesheet"
26
26
  />
27
- <script type="module" crossorigin src="/assets/index-EvjpKQwB.js"></script>
27
+ <script type="module" crossorigin src="/assets/index-WNLp-4Rf.js"></script>
28
28
  <link rel="stylesheet" crossorigin href="/assets/index-vD_kE3p2.css">
29
29
  </head>
30
30
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -43,6 +43,18 @@
43
43
  {
44
44
  "name": "Anooj Pai",
45
45
  "url": "https://github.com/Anooj-Pai"
46
+ },
47
+ {
48
+ "name": "Jack Hankin",
49
+ "url": "https://github.com/Darmin-Geek"
50
+ },
51
+ {
52
+ "name": "Amanda Ruan",
53
+ "url": "https://github.com/aruan20"
54
+ },
55
+ {
56
+ "name": "Evan Whymark",
57
+ "url": "https://github.com/EvWhymark"
46
58
  }
47
59
  ],
48
60
  "license": "MIT",
@@ -59,7 +71,7 @@
59
71
  "@codemirror/lang-markdown": "^6.2.3",
60
72
  "@codemirror/state": "^6.3.3",
61
73
  "@codemirror/theme-one-dark": "^6.1.2",
62
- "@codemirror/view": "^6.22.1",
74
+ "@codemirror/view": "^6.22.2",
63
75
  "@lezer/highlight": "^1.2.0",
64
76
  "@replit/codemirror-indentation-markers": "^6.5.0",
65
77
  "@replit/codemirror-interact": "^6.3.0",
@@ -94,16 +106,16 @@
94
106
  "sharedb": "^4.1.2",
95
107
  "sharedb-client-browser": "^4.4.0",
96
108
  "vizhub-ui": "^3.10.0",
97
- "ws": "^8.14.2"
109
+ "ws": "^8.15.0"
98
110
  },
99
111
  "devDependencies": {
100
- "@types/react": "^18.2.42",
112
+ "@types/react": "^18.2.43",
101
113
  "@types/react-dom": "^18.2.17",
102
114
  "@vitejs/plugin-react": "^4.2.1",
103
- "prettier": "^3.1.0",
115
+ "prettier": "^3.1.1",
104
116
  "sass": "^1.69.5",
105
117
  "typescript": "^5.3.3",
106
- "vite": "^5.0.6",
107
- "vitest": "^1.0.1"
118
+ "vite": "^5.0.7",
119
+ "vitest": "^1.0.4"
108
120
  }
109
121
  }
@@ -4,7 +4,6 @@ import {
4
4
  ViewPlugin,
5
5
  Decoration,
6
6
  WidgetType,
7
- keymap,
8
7
  } from '@codemirror/view';
9
8
  import {
10
9
  Annotation,
@@ -30,15 +29,17 @@ export const widgets = ({
30
29
  rules: [
31
30
  // hex color picker
32
31
  // Inspired by https://github.com/replit/codemirror-interact/blob/master/dev/index.ts#L71
32
+ // Extended to support single and double quotes
33
33
  {
34
- regexp: /\"\#([0-9]|[A-F]|[a-f]){6}\"/g,
34
+ regexp: /["']\#([0-9]|[A-F]|[a-f]){6}["']/g,
35
35
  cursor: 'pointer',
36
36
  onClick(text, setText, e) {
37
37
  const res =
38
- /\"(?<hex>\#([0-9]|[A-F]|[a-f]){6})\"/.exec(
38
+ /(?<quote>["'])(?<hex>\#([0-9]|[A-F]|[a-f]){6})\k<quote>/.exec(
39
39
  text,
40
40
  );
41
41
  const startingColor = res.groups?.hex;
42
+ const quoteType = res.groups?.quote;
42
43
 
43
44
  const sel = document.createElement('input');
44
45
  sel.type = 'color';
@@ -54,11 +55,11 @@ export const widgets = ({
54
55
  if (onInteract) onInteract();
55
56
  if (el.value) {
56
57
  setText(
57
- `"${
58
+ `${quoteType}${
58
59
  valueIsUpper
59
60
  ? el.value.toUpperCase()
60
61
  : el.value
61
- }"`,
62
+ }${quoteType}`,
62
63
  );
63
64
  }
64
65
  };
@@ -210,11 +211,12 @@ const rgb2Hex = (r: number, g: number, b: number): string =>
210
211
  '#' + r.toString(16) + g.toString(16) + b.toString(16);
211
212
 
212
213
  const colorCircleTheme = EditorView.baseTheme({
213
- '.color-circle-parent': { display: 'inline-block' },
214
+ '.color-circle-parent': {
215
+ display: 'inline-block',
216
+ cursor: 'inherit',
217
+ },
214
218
  });
215
219
 
216
- const colorCircleAnnotation = Annotation.define();
217
-
218
220
  export const colorsInTextPlugin: Extension = [
219
221
  ViewPlugin.fromClass(
220
222
  class {
@@ -232,7 +234,8 @@ export const colorsInTextPlugin: Extension = [
232
234
  const lines = v.view.state.doc.iter();
233
235
  let line = lines.next();
234
236
 
235
- //Offset is the number of characters before the hex so the circle can be placed properly.
237
+ // Offset is the number of characters before the hex
238
+ // so the circle can be placed properly.
236
239
  let offset = 0;
237
240
  while (!line.done) {
238
241
  if (line.value === '\n') {
@@ -240,15 +243,16 @@ export const colorsInTextPlugin: Extension = [
240
243
  line = lines.next();
241
244
  continue;
242
245
  }
243
- const hexColorOccurances = line.value.matchAll(
244
- /\"\#([0-9]|[A-F]|[a-f]){6}\"/g,
246
+ const hexColorOccurences = line.value.matchAll(
247
+ // /\"\#([0-9]|[A-F]|[a-f]){6}\"/g,
248
+ /["']\#([0-9]|[A-F]|[a-f]){6}["']/g,
245
249
  );
246
- let hexOccurance = hexColorOccurances.next();
250
+ let hexOccurance = hexColorOccurences.next();
247
251
  while (!hexOccurance.done) {
248
252
  const offsetColorInfo = hexOccurance.value;
249
253
  offsetColorInfo.index += offset;
250
254
  colorInfos.push(offsetColorInfo);
251
- hexOccurance = hexColorOccurances.next();
255
+ hexOccurance = hexColorOccurences.next();
252
256
  }
253
257
  offset += line.value.length;
254
258
  line = lines.next();
@@ -257,7 +261,7 @@ export const colorsInTextPlugin: Extension = [
257
261
  return Decoration.set(
258
262
  colorInfos.map((colorInfo) => {
259
263
  return {
260
- //9 is the length of the hex color string including quotation marks
264
+ // 9 is the length of the hex color string including quotation marks
261
265
  from: colorInfo.index + 9,
262
266
  to: colorInfo.index + 9,
263
267
  value: Decoration.widget({
@@ -287,8 +291,13 @@ class ColorWidget extends WidgetType {
287
291
 
288
292
  toDOM(view: EditorView): HTMLElement {
289
293
  const parent = document.createElement('div');
294
+ const size = 20;
295
+ const innerSize = 16;
290
296
 
291
- parent.setAttribute('style', 'width:10px;height:10px');
297
+ parent.setAttribute(
298
+ 'style',
299
+ `width:${size}px;height:${size}px`,
300
+ );
292
301
  parent.className = 'color-circle-parent';
293
302
  const svg = document.createElementNS(
294
303
  'http://www.w3.org/2000/svg',
@@ -301,15 +310,23 @@ class ColorWidget extends WidgetType {
301
310
  colorCircle.setAttributeNS(
302
311
  null,
303
312
  'fill',
304
- this.color.replace(/\"/g, ''),
313
+ this.color.replace(/["']/g, ''),
314
+ );
315
+ colorCircle.setAttributeNS(null, 'stroke', 'black');
316
+ colorCircle.setAttributeNS(
317
+ null,
318
+ 'r',
319
+ '' + innerSize / 2,
320
+ );
321
+ colorCircle.setAttributeNS(null, 'cx', '' + size / 2);
322
+ colorCircle.setAttributeNS(
323
+ null,
324
+ 'cy',
325
+ '' + (size / 2 - 1),
305
326
  );
306
- colorCircle.setAttributeNS(null, 'r', '5');
307
- colorCircle.setAttributeNS(null, 'cx', '5');
308
- colorCircle.setAttributeNS(null, 'cy', '5');
309
327
 
310
- svg.setAttributeNS(null, 'viewBox', '0 0 10 10');
311
- svg.setAttributeNS(null, 'width', '10');
312
- svg.setAttributeNS(null, 'height', '10');
328
+ svg.setAttributeNS(null, 'width', '' + size);
329
+ svg.setAttributeNS(null, 'height', '' + size);
313
330
 
314
331
  svg.appendChild(colorCircle);
315
332
 
@@ -244,4 +244,24 @@ onmessage = async ({ data }) => {
244
244
  };
245
245
  postMessage(linterResponse);
246
246
  }
247
+
248
+ // Handle the transpile-request event, which
249
+ // transpiles TypeScript to JavaScript.
250
+ if (data.event === 'transpile-request') {
251
+ const tsCode = data.tsCode;
252
+
253
+ const compilerOptions = {
254
+ jsx: ts.JsxEmit.React,
255
+ };
256
+
257
+ const jsCode = ts.transpileModule(tsCode, {
258
+ compilerOptions,
259
+ }).outputText;
260
+
261
+ postMessage({
262
+ event: 'transpile-response',
263
+ jsCode,
264
+ fileId: data.fileId,
265
+ });
266
+ }
247
267
  };