Format files with prettier
This commit is contained in:
parent
a2df120e66
commit
1ce0f9c059
9 changed files with 5988 additions and 5997 deletions
|
|
@ -3,8 +3,5 @@
|
||||||
"printWidth": 90,
|
"printWidth": 90,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"endOfLine": "lf",
|
"endOfLine": "lf"
|
||||||
"importOrder": ["^[./]", ".*", ".scss$"],
|
|
||||||
"importOrderSeparation": true,
|
|
||||||
"importOrderSortSpecifiers": true
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,38 +1,32 @@
|
||||||
{
|
{
|
||||||
"name": "portfolio",
|
"name": "reconcile-example-website",
|
||||||
"description": "An easily configurable timeline of projects.",
|
"description": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "webpack serve --open --mode development",
|
"start": "webpack serve --open --mode development",
|
||||||
"format": "prettier --write \"src/**/*.(ts|scss|json|html)\"",
|
"format": "prettier --write \"./**/*.(ts|scss|json|html)\"",
|
||||||
"build": "webpack --mode production"
|
"build": "webpack --mode production"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/schmelczer/schmelczer.github.io.git"
|
"url": "git+https://github.com/schmelczer/reconcile.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [],
|
||||||
"CV",
|
|
||||||
"curriculum",
|
|
||||||
"vitae",
|
|
||||||
"portfolio",
|
|
||||||
"resumé"
|
|
||||||
],
|
|
||||||
"author": "Andras Schmelczer",
|
"author": "Andras Schmelczer",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/schmelczer/schmelczer.github.io/issues"
|
"url": "https://github.com/schmelczer/reconcile/issues"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"defaults"
|
"defaults"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/schmelczer/schmelczer.github.io#readme",
|
"homepage": "https://github.com/schmelczer/reconcile#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"reconcile": "file:../../reconcile-js",
|
"reconcile": "file:../../reconcile-js",
|
||||||
"css-loader": "^7.1.2",
|
"css-loader": "^7.1.2",
|
||||||
"html-webpack-plugin": "^5.6.3",
|
"html-webpack-plugin": "^5.6.3",
|
||||||
"inline-source-webpack-plugin": "^3.0.1",
|
|
||||||
"mini-css-extract-plugin": "^2.9.2",
|
"mini-css-extract-plugin": "^2.9.2",
|
||||||
|
"inline-source-webpack-plugin": "^3.0.1",
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.6.2",
|
||||||
"resolve-url-loader": "^5.0.0",
|
"resolve-url-loader": "^5.0.0",
|
||||||
"sass": "^1.89.2",
|
"sass": "^1.89.2",
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,5 @@
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"inlineSourceMap": true
|
"inlineSourceMap": true
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": ["./dist"]
|
||||||
"./dist"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
17
reconcile-js/package-lock.json
generated
17
reconcile-js/package-lock.json
generated
|
|
@ -10,6 +10,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^30.0.0",
|
"@types/jest": "^30.0.0",
|
||||||
"jest": "^30.0.4",
|
"jest": "^30.0.4",
|
||||||
|
"prettier": "^3.6.2",
|
||||||
"reconcile": "file:../pkg",
|
"reconcile": "file:../pkg",
|
||||||
"ts-jest": "^29.4.0",
|
"ts-jest": "^29.4.0",
|
||||||
"ts-loader": "^9.5.2",
|
"ts-loader": "^9.5.2",
|
||||||
|
|
@ -4449,6 +4450,22 @@
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/prettier": {
|
||||||
|
"version": "3.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
|
||||||
|
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"prettier": "bin/prettier.cjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/pretty-format": {
|
"node_modules/pretty-format": {
|
||||||
"version": "30.0.2",
|
"version": "30.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.0.2.tgz",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack --mode production",
|
"build": "webpack --mode production",
|
||||||
|
"format": "prettier --write \"./**/*.(ts|scss|json|html)\"",
|
||||||
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest"
|
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
@ -19,6 +20,7 @@
|
||||||
"tslib": "2.8.1",
|
"tslib": "2.8.1",
|
||||||
"typescript": "5.8.3",
|
"typescript": "5.8.3",
|
||||||
"webpack": "^5.99.9",
|
"webpack": "^5.99.9",
|
||||||
"webpack-cli": "^6.0.1"
|
"webpack-cli": "^6.0.1",
|
||||||
|
"prettier": "^3.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,32 +1,28 @@
|
||||||
import { init, reconcile, reconcileWithHistory } from "./index";
|
import { init, reconcile, reconcileWithHistory } from './index';
|
||||||
import * as fs from "fs";
|
import * as fs from 'fs';
|
||||||
|
|
||||||
describe("reconcile", () => {
|
describe('reconcile', () => {
|
||||||
it("tries calling functions without init", () => {
|
it('tries calling functions without init', () => {
|
||||||
expect(() => reconcile("Hello", "Hello world", "Hi world")).toThrow(
|
expect(() => reconcile('Hello', 'Hello world', 'Hi world')).toThrow(/call init()/);
|
||||||
|
|
||||||
|
expect(() => reconcileWithHistory('Hello', 'Hello world', 'Hi world')).toThrow(
|
||||||
/call init()/
|
/call init()/
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
reconcileWithHistory("Hello", "Hello world", "Hi world")
|
|
||||||
).toThrow(/call init()/);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("call reconcile without cursors", async () => {
|
it('call reconcile without cursors', async () => {
|
||||||
await initWasm();
|
await initWasm();
|
||||||
|
|
||||||
expect(reconcile("Hello", "Hello world", "Hi world").text).toEqual(
|
expect(reconcile('Hello', 'Hello world', 'Hi world').text).toEqual('Hi world');
|
||||||
"Hi world"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("call reconcile with cursors", async () => {
|
it('call reconcile with cursors', async () => {
|
||||||
await initWasm();
|
await initWasm();
|
||||||
|
|
||||||
const result = reconcile(
|
const result = reconcile(
|
||||||
"Hello",
|
'Hello',
|
||||||
{
|
{
|
||||||
text: "Hello world",
|
text: 'Hello world',
|
||||||
cursors: [
|
cursors: [
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
|
|
@ -35,7 +31,7 @@ describe("reconcile", () => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Hi world",
|
text: 'Hi world',
|
||||||
cursors: [
|
cursors: [
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
|
|
@ -46,7 +42,7 @@ describe("reconcile", () => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.text).toEqual("Hi world");
|
expect(result.text).toEqual('Hi world');
|
||||||
expect(result.cursors).toEqual([
|
expect(result.cursors).toEqual([
|
||||||
{ id: 3, position: 0 },
|
{ id: 3, position: 0 },
|
||||||
{ id: 4, position: 0 },
|
{ id: 4, position: 0 },
|
||||||
|
|
@ -54,17 +50,17 @@ describe("reconcile", () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("call reconcileWithHistory", async () => {
|
it('call reconcileWithHistory', async () => {
|
||||||
await initWasm();
|
await initWasm();
|
||||||
|
|
||||||
const result = reconcileWithHistory("Hello", "Hello world", "Hi world");
|
const result = reconcileWithHistory('Hello', 'Hello world', 'Hi world');
|
||||||
|
|
||||||
expect(result.text).toEqual("Hi world");
|
expect(result.text).toEqual('Hi world');
|
||||||
expect(result.history.length).toBeGreaterThan(0);
|
expect(result.history.length).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
async function initWasm() {
|
async function initWasm() {
|
||||||
const wasmBin = fs.readFileSync("../pkg/reconcile_bg.wasm");
|
const wasmBin = fs.readFileSync('../pkg/reconcile_bg.wasm');
|
||||||
await init({ module_or_path: wasmBin });
|
await init({ module_or_path: wasmBin });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import wasmInit, {
|
||||||
reconcileWithHistory as wasmReconcileWithHistory,
|
reconcileWithHistory as wasmReconcileWithHistory,
|
||||||
History,
|
History,
|
||||||
InitInput,
|
InitInput,
|
||||||
} from "reconcile";
|
} from 'reconcile';
|
||||||
|
|
||||||
export interface TextWithCursors {
|
export interface TextWithCursors {
|
||||||
/** The document's entire content */
|
/** The document's entire content */
|
||||||
|
|
@ -39,16 +39,16 @@ export interface SpanWithHistory {
|
||||||
history: History;
|
history: History;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Tokenizer = "Line" | "Word" | "Character";
|
export type Tokenizer = 'Line' | 'Word' | 'Character';
|
||||||
const TOKENIZERS = ["Line", "Word", "Character"];
|
const TOKENIZERS = ['Line', 'Word', 'Character'];
|
||||||
|
|
||||||
let isInitialised = false;
|
let isInitialised = false;
|
||||||
|
|
||||||
const UNINITIALISED_MODULE_ERROR =
|
const UNINITIALISED_MODULE_ERROR =
|
||||||
"Reconcile module has not been initialized. Please call init() before using any other functions.";
|
'Reconcile module has not been initialized. Please call init() before using any other functions.';
|
||||||
|
|
||||||
const UNSUPPORTED_TOKENIZER_ERROR = `Unsupported tokenizer. Only ${TOKENIZERS.join(
|
const UNSUPPORTED_TOKENIZER_ERROR = `Unsupported tokenizer. Only ${TOKENIZERS.join(
|
||||||
", "
|
', '
|
||||||
)} are supported.`;
|
)} are supported.`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -83,7 +83,7 @@ export function reconcile(
|
||||||
original: string,
|
original: string,
|
||||||
left: string | TextWithCursors,
|
left: string | TextWithCursors,
|
||||||
right: string | TextWithCursors,
|
right: string | TextWithCursors,
|
||||||
tokenizer: BuiltinTokenizer = "Word"
|
tokenizer: BuiltinTokenizer = 'Word'
|
||||||
): TextWithCursors {
|
): TextWithCursors {
|
||||||
if (!isInitialised) {
|
if (!isInitialised) {
|
||||||
throw new Error(UNINITIALISED_MODULE_ERROR);
|
throw new Error(UNINITIALISED_MODULE_ERROR);
|
||||||
|
|
@ -122,7 +122,7 @@ export function reconcileWithHistory(
|
||||||
original: string,
|
original: string,
|
||||||
left: string | TextWithCursors,
|
left: string | TextWithCursors,
|
||||||
right: string | TextWithCursors,
|
right: string | TextWithCursors,
|
||||||
tokenizer: BuiltinTokenizer = "Word"
|
tokenizer: BuiltinTokenizer = 'Word'
|
||||||
): TextWithCursorsAndHistory {
|
): TextWithCursorsAndHistory {
|
||||||
if (!isInitialised) {
|
if (!isInitialised) {
|
||||||
throw new Error(UNINITIALISED_MODULE_ERROR);
|
throw new Error(UNINITIALISED_MODULE_ERROR);
|
||||||
|
|
@ -135,12 +135,7 @@ export function reconcileWithHistory(
|
||||||
const leftCursor = toWasmTextWithCursors(left);
|
const leftCursor = toWasmTextWithCursors(left);
|
||||||
const rightCursor = toWasmTextWithCursors(right);
|
const rightCursor = toWasmTextWithCursors(right);
|
||||||
|
|
||||||
const result = wasmReconcileWithHistory(
|
const result = wasmReconcileWithHistory(original, leftCursor, rightCursor, tokenizer);
|
||||||
original,
|
|
||||||
leftCursor,
|
|
||||||
rightCursor,
|
|
||||||
tokenizer
|
|
||||||
);
|
|
||||||
|
|
||||||
leftCursor.free();
|
leftCursor.free();
|
||||||
rightCursor.free();
|
rightCursor.free();
|
||||||
|
|
@ -155,29 +150,19 @@ export function reconcileWithHistory(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function toWasmTextWithCursors(
|
function toWasmTextWithCursors(text: string | TextWithCursors): wasmTextWithCursors {
|
||||||
text: string | TextWithCursors
|
const isInputString = typeof text == 'string';
|
||||||
): wasmTextWithCursors {
|
|
||||||
const isInputString = typeof text == "string";
|
|
||||||
const leftText = isInputString ? text : text.text;
|
const leftText = isInputString ? text : text.text;
|
||||||
const leftCursors = isInputString ? [] : text.cursors ?? [];
|
const leftCursors = isInputString ? [] : (text.cursors ?? []);
|
||||||
|
|
||||||
return new wasmTextWithCursors(
|
return new wasmTextWithCursors(leftText, leftCursors.map(toWasmCursorPosition));
|
||||||
leftText,
|
|
||||||
leftCursors.map(toWasmCursorPosition)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toWasmCursorPosition({
|
function toWasmCursorPosition({ id, position }: CursorPosition): wasmCursorPosition {
|
||||||
id,
|
|
||||||
position,
|
|
||||||
}: CursorPosition): wasmCursorPosition {
|
|
||||||
return new wasmCursorPosition(id, position);
|
return new wasmCursorPosition(id, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toTextWithCursors(
|
function toTextWithCursors(textWithCursor: wasmTextWithCursors): TextWithCursors {
|
||||||
textWithCursor: wasmTextWithCursors
|
|
||||||
): TextWithCursors {
|
|
||||||
return {
|
return {
|
||||||
text: textWithCursor.text(),
|
text: textWithCursor.text(),
|
||||||
cursors: textWithCursor.cursors().map(toCursorPosition),
|
cursors: textWithCursor.cursors().map(toCursorPosition),
|
||||||
|
|
@ -191,9 +176,7 @@ function toCursorPosition(cursor: wasmCursorPosition): CursorPosition {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function toSpanWithHistory(
|
function toSpanWithHistory(textWithHistory: wasmSpanWithHistory): SpanWithHistory {
|
||||||
textWithHistory: wasmSpanWithHistory
|
|
||||||
): SpanWithHistory {
|
|
||||||
return {
|
return {
|
||||||
text: textWithHistory.text(),
|
text: textWithHistory.text(),
|
||||||
history: textWithHistory.history(),
|
history: textWithHistory.history(),
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,5 @@
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"inlineSourceMap": true
|
"inlineSourceMap": true
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": ["./dist"]
|
||||||
"./dist"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
@ -5,4 +5,10 @@ set -e
|
||||||
cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged
|
cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged
|
||||||
cargo fmt --all
|
cargo fmt --all
|
||||||
|
|
||||||
|
cd reconcile-js
|
||||||
|
npm run format
|
||||||
|
|
||||||
|
cd ../examples/website
|
||||||
|
npm run format
|
||||||
|
|
||||||
echo "Success!"
|
echo "Success!"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue