Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import{v as e}from"./index-MO5nEwio.js";var t={ar:()=>e(()=>import(`./ar-DPJDxCQI-DVxXrl8b.js`),[]),de:()=>e(()=>import(`./de-CakHBokE-Bc7uuGiX.js`),[]),en:()=>e(()=>import(`./en-BGdzE27X-TW1aad9S.js`),[]),es:()=>e(()=>import(`./es-VeBX6MEG-Kiej93jn.js`),[]),fa:()=>e(()=>import(`./fa-Dt7EYtKf-B5W0KSh4.js`),[]),fr:()=>e(()=>import(`./fr-DUhhjxrJ-ZlHjDAmJ.js`),[]),he:()=>e(()=>import(`./he-BShJg1dK-LKJKt0F1.js`),[]),hr:()=>e(()=>import(`./hr-BXtyqmwg-DyP3pX1K.js`),[]),is:()=>e(()=>import(`./is-2Fb-0w_j-BgcKBDLw.js`),[]),it:()=>e(()=>import(`./it-CiZtVb3Y-DvxSJeVo.js`),[]),ja:()=>e(()=>import(`./ja-CsxD3kEL-CvaZrDnL.js`),[]),ko:()=>e(()=>import(`./ko-It6g03Cy-ZSCK4kOT.js`),[]),nb:()=>e(()=>import(`./nb-CLao87La-CG_xJQwn.js`),[]),nl:()=>e(()=>import(`./nl-JQSo8dht-CaVSlD7w.js`),[]),pl:()=>e(()=>import(`./pl-DEMBgHEP-Dj8IbNR0.js`),[]),pt:()=>e(()=>import(`./pt-CBCdYAax-CxE-Nyim.js`),[]),ru:()=>e(()=>import(`./ru-BQk_9Q-L-c3bOsG2P.js`),[]),sk:()=>e(()=>import(`./sk-kgB2DtDL-Dc169kAC.js`),[]),tr:()=>e(()=>import(`./tr-DkcSXX8f-jMWTyLfk.js`),[]),uk:()=>e(()=>import(`./uk-Bib-e6bV-ErQ7vi1L.js`),[]),uz:()=>e(()=>import(`./uz-B2jaKhJb-BWnnlbUQ.js`),[]),vi:()=>e(()=>import(`./vi-V_GFRxE8-B_ZUa_6s.js`),[]),zh:()=>e(()=>import(`./zh-jglyCmjs-BDbB1o9o.js`),[]),"zh-hant":()=>e(()=>import(`./zh-hant-2ZrAkFnC-CdiPnK-W.js`),[])},n={no:`nb`,"zh-tw":`zh-hant`},r=new Map;function i(e){return{light:e(0),"medium-light":e(1),medium:e(2),"medium-dark":e(3),dark:e(4)}}function a(e){let[t,n,r,...a]=e.split(`
import{v as e}from"./index-BqKtmCPh.js";var t={ar:()=>e(()=>import(`./ar-DPJDxCQI-DVxXrl8b.js`),[]),de:()=>e(()=>import(`./de-CakHBokE-Bc7uuGiX.js`),[]),en:()=>e(()=>import(`./en-BGdzE27X-TW1aad9S.js`),[]),es:()=>e(()=>import(`./es-VeBX6MEG-Kiej93jn.js`),[]),fa:()=>e(()=>import(`./fa-Dt7EYtKf-B5W0KSh4.js`),[]),fr:()=>e(()=>import(`./fr-DUhhjxrJ-ZlHjDAmJ.js`),[]),he:()=>e(()=>import(`./he-BShJg1dK-LKJKt0F1.js`),[]),hr:()=>e(()=>import(`./hr-BXtyqmwg-DyP3pX1K.js`),[]),is:()=>e(()=>import(`./is-2Fb-0w_j-BgcKBDLw.js`),[]),it:()=>e(()=>import(`./it-CiZtVb3Y-DvxSJeVo.js`),[]),ja:()=>e(()=>import(`./ja-CsxD3kEL-CvaZrDnL.js`),[]),ko:()=>e(()=>import(`./ko-It6g03Cy-ZSCK4kOT.js`),[]),nb:()=>e(()=>import(`./nb-CLao87La-CG_xJQwn.js`),[]),nl:()=>e(()=>import(`./nl-JQSo8dht-CaVSlD7w.js`),[]),pl:()=>e(()=>import(`./pl-DEMBgHEP-Dj8IbNR0.js`),[]),pt:()=>e(()=>import(`./pt-CBCdYAax-CxE-Nyim.js`),[]),ru:()=>e(()=>import(`./ru-BQk_9Q-L-c3bOsG2P.js`),[]),sk:()=>e(()=>import(`./sk-kgB2DtDL-Dc169kAC.js`),[]),tr:()=>e(()=>import(`./tr-DkcSXX8f-jMWTyLfk.js`),[]),uk:()=>e(()=>import(`./uk-Bib-e6bV-ErQ7vi1L.js`),[]),uz:()=>e(()=>import(`./uz-B2jaKhJb-BWnnlbUQ.js`),[]),vi:()=>e(()=>import(`./vi-V_GFRxE8-B_ZUa_6s.js`),[]),zh:()=>e(()=>import(`./zh-jglyCmjs-BDbB1o9o.js`),[]),"zh-hant":()=>e(()=>import(`./zh-hant-2ZrAkFnC-CdiPnK-W.js`),[])},n={no:`nb`,"zh-tw":`zh-hant`},r=new Map;function i(e){return{light:e(0),"medium-light":e(1),medium:e(2),"medium-dark":e(3),dark:e(4)}}function a(e){let[t,n,r,...a]=e.split(`
`),o=`0,1,3,4,5,6,7,8,9`.split(`,`).map(Number),s=`😀 0 1
😃 0 0.6
😄 0 0.6
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/web/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta name="theme-color" content="#0d0f14" />
<meta name="description" content="Private, encrypted notes" />
<title>KyNotes</title>
<script type="module" crossorigin src="/assets/index-MO5nEwio.js"></script>
<script type="module" crossorigin src="/assets/index-BqKtmCPh.js"></script>
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-COiEfhsA.js">
<link rel="stylesheet" crossorigin href="/assets/index-DXs7t0vx.css">
</head>
Expand Down
4 changes: 2 additions & 2 deletions web/src/CanvasPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type CanvasBox, type CanvasPage as Page, type CanvasStroke, type InkColor,
} from "./document";
import { History, addBox, contentExtent, eraseAt, fitBox, freeSpot, isUndoKey, pageFits, pruneEmpty, readingOrder, updateBox } from "./canvas";
import { strokePath } from "./ink";
import { samplesOf, strokePath } from "./ink";
import { FORMATS, applyFormat, blockOf, type Format, type TextEditor } from "./format";
import { NavIcon } from "./NavIcon";

Expand Down Expand Up @@ -298,7 +298,7 @@ export default function CanvasPage({ pageID, body, onChange, onError, uploadFile
}
const points = draft.current;
if (!points) return;
for (const sample of event.nativeEvent.getCoalescedEvents?.() ?? [event.nativeEvent]) {
for (const sample of samplesOf(event.nativeEvent)) {
if (points.length >= MAX_STROKE_POINTS * 3) break;
const { x, y } = local(sample);
points.push(Math.round(x), Math.round(y), pressureOf(sample));
Expand Down
18 changes: 17 additions & 1 deletion web/src/ink.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import { describe, expect, it } from "vitest";
import { strokePath } from "./ink";
import { samplesOf, strokePath } from "./ink";

type Move = { x: number; getCoalescedEvents?: () => Move[] };

describe("samplesOf", () => {
it("uses the browser's coalesced samples", () => {
const samples: Move[] = [{ x: 1 }, { x: 2 }];
const move: Move = { x: 2, getCoalescedEvents: () => samples };
expect(samplesOf(move)).toBe(samples);
});
it("falls back to the move itself when the list is empty or missing", () => {
const empty: Move = { x: 3, getCoalescedEvents: () => [] };
const missing: Move = { x: 4 };
expect(samplesOf(empty)).toEqual([empty]);
expect(samplesOf(missing)).toEqual([missing]);
});
});

describe("strokePath", () => {
it("renders nothing without points", () => {
Expand Down
6 changes: 6 additions & 0 deletions web/src/ink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ export function strokePath(points: number[], size: number, highlighter: boolean)
if (!outline.length) return "";
return `M${outline.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join("L")}Z`;
}

/** A pointer move's samples, or the move itself when the browser lists none (Ladybird lists none). */
export function samplesOf<T extends { getCoalescedEvents?: () => T[] }>(event: T): T[] {
const coalesced = event.getCoalescedEvents?.() ?? [];
return coalesced.length ? coalesced : [event];
}