Skip to content

Commit

Permalink
A lot of temporary changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Oct 19, 2023
1 parent 73c188a commit 1766b0d
Show file tree
Hide file tree
Showing 45 changed files with 539 additions and 967 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"tslib": "2.3.1",
"y-protocols": "^1.0.6",
"y-webrtc": "^10.2.5",
"yjs-redux": "^0.9.0"
"yjs-redux": "^0.12.0"
},
"scripts": {
"start": "node --max_old_space_size=6096 node_modules/webpack/bin/webpack.js serve --config config/webpack.config.js --port 3002 --hot --server-type https --server-options-pfx dev/squidex-dev.pfx --server-options-passphrase password",
Expand Down
1 change: 0 additions & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export * from './utils/color';
export * from './utils/helpers';
export * from './utils/immutable-list';
export * from './utils/immutable-map';
export * from './utils/immutable-set';
export * from './utils/math-helper';
export * from './utils/react';
export * from './utils/record';
Expand Down
9 changes: 9 additions & 0 deletions src/core/utils/color.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,13 @@ describe('Color', () => {
it('should throw error for invalid string', () => {
expect(() => Color.fromValue('INVALID')).toThrowError('Color is not in a valid format.');
});

it('should convert and read from json', () =>{
const source = new Color(1, 2, 3);
const serialized = source.toJS();

const deserialized = Color.fromJS(serialized);

expect(deserialized).toEqual(source);
});
});
37 changes: 32 additions & 5 deletions src/core/utils/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,30 @@ export class Color {

public readonly __typeName = Color.TYPE_NAME;

public static readonly BLACK = new Color(0, 0, 0);
public static readonly WHITE = new Color(1, 1, 1);
public static readonly GREEN = new Color(0, 1, 0);
public static readonly BLUE = new Color(0, 0, 1);
public static readonly RED = new Color(1, 0, 0);
public static readonly BLACK = new Color(
0,
0,
0);

public static readonly WHITE = new Color(
1,
1,
1);

public static readonly GREEN = new Color(
0,
1,
0);

public static readonly BLUE = new Color(
0,
0,
1);

public static readonly RED = new Color(
1,
0,
0);

public readonly r: number;
public readonly g: number;
Expand Down Expand Up @@ -219,4 +238,12 @@ export class Color {

return new Color(r, g, b);
}

public toJS() {
return { r: this.r, g: this.g, b: this.b };
}

public static fromJS(source: any) {
return new Color(source.r, source.g, source.b);
}
}
6 changes: 4 additions & 2 deletions src/core/utils/immutable-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ describe('ImmutableList', () => {
const list = ImmutableList.empty<number>();

expect(list.size).toBe(0);
expect(list).not.toBe(ImmutableList.empty());
});

it('should cache empty instance', () => {
it('should return new empty instance if creating map from empty array', () => {
const list = ImmutableList.of([]);

expect(list).toBe(ImmutableList.empty());
expect(list.size).toBe(0);
expect(list).not.toBe(ImmutableList.empty());
});

it('should instantiate from array of items', () => {
Expand Down
4 changes: 0 additions & 4 deletions src/core/utils/immutable-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export class ImmutableList<T> {
return this.items;
}

public get raw() {
return this.items;
}

public at(index: number): T | undefined {
return this.items[index];
}
Expand Down
6 changes: 4 additions & 2 deletions src/core/utils/immutable-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ describe('ImmutableMap', () => {
const list = ImmutableMap.empty<number>();

expect(list.size).toBe(0);
expect(list).not.toBe(ImmutableMap.empty());
});

it('should return empty instance if creating map from empty object', () => {
it('should return new empty instance if creating map from empty object', () => {
const list = ImmutableMap.of({});

expect(list).toBe(ImmutableMap.empty());
expect(list.size).toBe(0);
expect(list).not.toBe(ImmutableMap.empty());
});

it('should add items', () => {
Expand Down
151 changes: 0 additions & 151 deletions src/core/utils/immutable-set.spec.ts

This file was deleted.

Loading

0 comments on commit 1766b0d

Please sign in to comment.