Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse.js fixes to allow "custom" ColorSpace formats #595

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
// Check against both <dashed-ident> and <ident> versions
let alternateId = id.startsWith("--") ? id.substring(2) : `--${id}`;
let ids = [id, alternateId];
format = ColorSpace.findFormat({name, id: ids, type: "function"});

Check failure on line 49 in src/parse.js

View workflow job for this annotation

GitHub Actions / Lint & Test Types

Property 'findFormat' does not exist on type 'typeof ColorSpace'.

if (!format) {
// Not found
Expand Down Expand Up @@ -78,7 +78,7 @@
}
}
else {
format = ColorSpace.findFormat({name, type: "function"});

Check failure on line 81 in src/parse.js

View workflow job for this annotation

GitHub Actions / Lint & Test Types

Property 'findFormat' does not exist on type 'typeof ColorSpace'.
space = format.space;
}

Expand All @@ -92,7 +92,7 @@
alpha = env.parsed.args.pop();

if (meta) {
meta.alphaType = types.pop();

Check failure on line 95 in src/parse.js

View workflow job for this annotation

GitHub Actions / Lint & Test Types

Property 'alphaType' does not exist on type 'ArgumentMeta'.
}
}

Expand All @@ -108,6 +108,7 @@
}
else {
// Custom, colorspace-specific format
let found;
for (let space of ColorSpace.all) {
for (let formatId in space.formats) {
let format = space.formats[formatId];
Expand All @@ -121,19 +122,23 @@
}

// Convert to Format object
format = space.getFormat(format);

Check failure on line 125 in src/parse.js

View workflow job for this annotation

GitHub Actions / Lint & Test Types

Type 'import("/home/runner/work/color.js/color.js/src/Format").default' is not assignable to type 'import("/home/runner/work/color.js/color.js/src/ColorSpace").Format'.

let color = format.parse(env.str);
let color = format.parse?.(env.str);

if (color) {
if (meta) {
Object.assign(meta, { format, formatId });
}

ret = color;
found = true;
break;
}
}
if (found) {
break;
}
}
}

Expand Down
Loading