Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
600b61bb
Commit
600b61bb
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
Added PD.For and PD.Normalize
parent
1e62dbcc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-state/action.ts
+2
-8
2 additions, 8 deletions
src/mol-state/action.ts
src/mol-state/transformer.ts
+2
-8
2 additions, 8 deletions
src/mol-state/transformer.ts
src/mol-util/param-definition.ts
+5
-0
5 additions, 0 deletions
src/mol-util/param-definition.ts
with
9 additions
and
16 deletions
src/mol-state/action.ts
+
2
−
8
View file @
600b61bb
...
...
@@ -78,21 +78,15 @@ namespace StateAction {
}
export
namespace
Builder
{
type
ParamDefinition
<
P
>
=
{
[
K
in
keyof
P
]
-
?:
PD
.
Base
<
P
[
K
]
>
}
export
interface
Type
<
A
extends
StateObject
.
Ctor
,
P
extends
{
}
>
{
from
?:
A
|
A
[],
params
?:
P
aramDefinition
<
P
>
|
((
a
:
StateObject
.
From
<
A
>
,
globalCtx
:
any
)
=>
P
aramDefinition
<
P
>
)
params
?:
P
D
.
For
<
P
>
|
((
a
:
StateObject
.
From
<
A
>
,
globalCtx
:
any
)
=>
P
D
.
For
<
P
>
)
}
export
interface
Root
{
<
A
extends
StateObject
.
Ctor
,
P
extends
{
}
>
(
info
:
Type
<
A
,
P
>
):
Define
<
StateObject
.
From
<
A
>
,
P
arams
<
P
>>
<
A
extends
StateObject
.
Ctor
,
P
extends
{
}
>
(
info
:
Type
<
A
,
P
>
):
Define
<
StateObject
.
From
<
A
>
,
P
D
.
Normalize
<
P
>>
}
type
Optionals
<
P
>
=
{
[
K
in
keyof
P
]
-
?:
undefined
extends
P
[
K
]
?
K
:
never
}[
keyof
P
]
type
NonOptionals
<
P
>
=
{
[
K
in
keyof
P
]
-
?:
undefined
extends
P
[
K
]
?
never
:
K
}[
keyof
P
]
type
Params
<
P
>
=
Pick
<
P
,
NonOptionals
<
P
>>
&
Partial
<
Pick
<
P
,
Optionals
<
P
>>>
export
interface
Define
<
A
extends
StateObject
,
P
>
{
<
T
>
(
def
:
DefinitionBase
<
A
,
T
,
P
>
):
StateAction
<
A
,
T
,
P
>
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-state/transformer.ts
+
2
−
8
View file @
600b61bb
...
...
@@ -147,23 +147,17 @@ export namespace Transformer {
}
export
namespace
Builder
{
type
ParamDefinition
<
P
>
=
{
[
K
in
keyof
P
]
-
?:
PD
.
Base
<
P
[
K
]
>
}
export
interface
Type
<
A
extends
StateObject
.
Ctor
,
B
extends
StateObject
.
Ctor
,
P
extends
{
}
>
{
name
:
string
,
from
:
A
|
A
[],
to
:
B
|
B
[],
params
?:
P
aramDefinition
<
P
>
|
((
a
:
StateObject
.
From
<
A
>
,
globalCtx
:
any
)
=>
P
aramDefinition
<
P
>
)
params
?:
P
D
.
For
<
P
>
|
((
a
:
StateObject
.
From
<
A
>
,
globalCtx
:
any
)
=>
P
D
.
For
<
P
>
)
}
export
interface
Root
{
<
A
extends
StateObject
.
Ctor
,
B
extends
StateObject
.
Ctor
,
P
extends
{
}
>
(
info
:
Type
<
A
,
B
,
P
>
):
Define
<
StateObject
.
From
<
A
>
,
StateObject
.
From
<
B
>
,
P
arams
<
P
>>
<
A
extends
StateObject
.
Ctor
,
B
extends
StateObject
.
Ctor
,
P
extends
{
}
>
(
info
:
Type
<
A
,
B
,
P
>
):
Define
<
StateObject
.
From
<
A
>
,
StateObject
.
From
<
B
>
,
P
D
.
Normalize
<
P
>>
}
type
Optionals
<
P
>
=
{
[
K
in
keyof
P
]
-
?:
undefined
extends
P
[
K
]
?
K
:
never
}[
keyof
P
]
type
NonOptionals
<
P
>
=
{
[
K
in
keyof
P
]
-
?:
undefined
extends
P
[
K
]
?
never
:
K
}[
keyof
P
]
type
Params
<
P
>
=
Pick
<
P
,
NonOptionals
<
P
>>
&
Partial
<
Pick
<
P
,
Optionals
<
P
>>>
export
interface
Define
<
A
extends
StateObject
,
B
extends
StateObject
,
P
>
{
(
def
:
DefinitionBase
<
A
,
B
,
P
>
):
Transformer
<
A
,
B
,
P
>
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/param-definition.ts
+
5
−
0
View file @
600b61bb
...
...
@@ -181,6 +181,11 @@ export namespace ParamDefinition {
export
type
Params
=
{
[
k
:
string
]:
Any
}
export
type
Values
<
T
extends
Params
>
=
{
[
k
in
keyof
T
]:
T
[
k
][
'
defaultValue
'
]
}
type
Optionals
<
P
>
=
{
[
K
in
keyof
P
]
-
?:
undefined
extends
P
[
K
]
?
K
:
never
}[
keyof
P
]
type
NonOptionals
<
P
>
=
{
[
K
in
keyof
P
]
-
?:
undefined
extends
P
[
K
]
?
never
:
K
}[
keyof
P
]
export
type
Normalize
<
P
>
=
Pick
<
P
,
NonOptionals
<
P
>>
&
Partial
<
Pick
<
P
,
Optionals
<
P
>>>
export
type
For
<
P
>
=
{
[
K
in
keyof
P
]
-
?:
Base
<
P
[
K
]
>
}
export
function
getDefaultValues
<
T
extends
Params
>
(
params
:
T
)
{
const
d
:
{
[
k
:
string
]:
any
}
=
{}
for
(
const
k
of
Object
.
keys
(
params
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment