@comty.io/core 0.1.0 → 0.1.1

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/src/vite.mjs CHANGED
@@ -17,6 +17,7 @@ export function comty(options = {}) {
17
17
  const anchors = new URL('./anchors.js', import.meta.url);
18
18
  const capture = new URL('./capture.js', import.meta.url);
19
19
  const comments = new URL('./comments.js', import.meta.url);
20
+ const measurements = new URL('./measurements.js', import.meta.url);
20
21
  start = new Promise((resolve, reject) => {
21
22
  const onError = error => {
22
23
  // Vite retries the next port after EADDRINUSE unless strictPort is set.
@@ -44,10 +45,10 @@ export function comty(options = {}) {
44
45
  response.writeHead(403); response.end(); return;
45
46
  }
46
47
  const path = new URL(request.url, origin).pathname;
47
- if (request.method === 'GET' && ['/__comty/browser.js', '/__comty/style.js', '/__comty/anchors.js', '/__comty/capture.js', '/__comty/comments.js', '/__comty/start.js'].includes(path)) {
48
+ if (request.method === 'GET' && ['/__comty/browser.js', '/__comty/style.js', '/__comty/anchors.js', '/__comty/capture.js', '/__comty/comments.js', '/__comty/measurements.js', '/__comty/start.js'].includes(path)) {
48
49
  response.setHeader('Content-Type', 'text/javascript'); response.setHeader('Cache-Control', 'no-store');
49
50
  response.setHeader('X-Content-Type-Options', 'nosniff');
50
- response.end(path.endsWith('/browser.js') ? await readFile(runtime) : path.endsWith('/style.js') ? await readFile(style) : path.endsWith('/anchors.js') ? await readFile(anchors) : path.endsWith('/capture.js') ? await readFile(capture) : path.endsWith('/comments.js') ? await readFile(comments) :
51
+ response.end(path.endsWith('/browser.js') ? await readFile(runtime) : path.endsWith('/style.js') ? await readFile(style) : path.endsWith('/anchors.js') ? await readFile(anchors) : path.endsWith('/capture.js') ? await readFile(capture) : path.endsWith('/comments.js') ? await readFile(comments) : path.endsWith('/measurements.js') ? await readFile(measurements) :
51
52
  `import { initComty } from '/__comty/browser.js';\ninitComty(${JSON.stringify({ projectKey: options.projectKey, apiUrl: options.apiUrl, agent: { url: `${origin}/__comty`, token: companion.token } })}).catch(console.error);`);
52
53
  } else await companion.handle(request, response);
53
54
  } catch (error) { next(error); }