Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
74cba7be
Commit
74cba7be
authored
7 years ago
by
Ray Schamp
Browse files
Options
Downloads
Patches
Plain Diff
Revert "Script libraries to process SVG costumes"
This reverts commit
321839ca
.
parent
321839ca
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/containers/costume-library.jsx
+0
-40
0 additions, 40 deletions
src/containers/costume-library.jsx
src/containers/sprite-library.jsx
+0
-49
0 additions, 49 deletions
src/containers/sprite-library.jsx
with
0 additions
and
89 deletions
src/containers/costume-library.jsx
+
0
−
40
View file @
74cba7be
const
bindAll
=
require
(
'
lodash.bindall
'
);
const
PropTypes
=
require
(
'
prop-types
'
);
const
React
=
require
(
'
react
'
);
const
Renderer
=
require
(
'
scratch-render
'
);
const
Storage
=
require
(
'
../lib/storage
'
);
const
VM
=
require
(
'
scratch-vm
'
);
const
costumeLibraryContent
=
require
(
'
../lib/libraries/costumes.json
'
);
const
LibraryComponent
=
require
(
'
../components/library/library.jsx
'
);
function
download
(
content
,
contentType
,
filename
)
{
const
blob
=
new
Blob
([
content
],
{
type
:
contentType
});
const
link
=
document
.
createElement
(
'
a
'
);
link
.
download
=
filename
;
link
.
href
=
window
.
URL
.
createObjectURL
(
blob
);
link
.
onclick
=
function
()
{
setTimeout
(()
=>
window
.
URL
.
revokeObjectURL
(
this
.
href
),
10
);
};
link
.
click
();
link
.
remove
();
}
class
CostumeLibrary
extends
React
.
PureComponent
{
constructor
(
props
)
{
...
...
@@ -27,33 +14,6 @@ class CostumeLibrary extends React.PureComponent {
'
handleItemSelected
'
]);
}
componentDidMount
()
{
const
storage
=
new
Storage
();
Promise
.
all
(
costumeLibraryContent
.
map
(
costume
=>
{
const
[
md5
,
ext
]
=
costume
.
md5
.
split
(
'
.
'
);
if
(
ext
!==
'
svg
'
)
return
Promise
.
resolve
(
costume
);
return
storage
.
load
(
storage
.
AssetType
.
ImageVector
,
md5
)
.
then
(
costumeAsset
=>
new
Promise
(
resolveSVG
=>
{
const
svgRenderer
=
new
Renderer
.
SVGRenderer
();
svgRenderer
.
fromString
(
costumeAsset
.
decodeText
(),
()
=>
{
resolveSVG
(
svgRenderer
.
_toString
());
});
})
)
.
then
(
svgContents
=>
{
const
newMd5
=
storage
.
builtinHelper
.
cache
(
storage
.
AssetType
.
ImageVector
,
storage
.
DataFormat
.
SVG
,
svgContents
);
// download(svgContents, 'image/svg+xml', `${newMd5}.svg`);
costume
.
md5
=
`
${
newMd5
}
.svg`
;
return
costume
;
});
}))
.
then
(
costumes
=>
download
(
JSON
.
stringify
(
costumes
,
null
,
4
),
'
application/json
'
,
'
costumes.json
'
));
}
handleItemSelected
(
item
)
{
const
vmCostume
=
{
name
:
item
.
name
,
...
...
This diff is collapsed.
Click to expand it.
src/containers/sprite-library.jsx
+
0
−
49
View file @
74cba7be
...
...
@@ -2,26 +2,11 @@ const bindAll = require('lodash.bindall');
const
PropTypes
=
require
(
'
prop-types
'
);
const
React
=
require
(
'
react
'
);
const
VM
=
require
(
'
scratch-vm
'
);
const
Renderer
=
require
(
'
scratch-render
'
);
const
Storage
=
require
(
'
../lib/storage
'
);
const
xhr
=
require
(
'
xhr
'
);
const
spriteLibraryContent
=
require
(
'
../lib/libraries/sprites.json
'
);
const
LibraryComponent
=
require
(
'
../components/library/library.jsx
'
);
function
download
(
content
,
contentType
,
filename
)
{
const
blob
=
new
Blob
([
content
],
{
type
:
contentType
});
const
link
=
document
.
createElement
(
'
a
'
);
link
.
download
=
filename
;
link
.
href
=
window
.
URL
.
createObjectURL
(
blob
);
link
.
onclick
=
function
()
{
setTimeout
(()
=>
window
.
URL
.
revokeObjectURL
(
this
.
href
),
10
);
};
link
.
click
();
link
.
remove
();
}
class
SpriteLibrary
extends
React
.
PureComponent
{
constructor
(
props
)
{
super
(
props
);
...
...
@@ -39,40 +24,6 @@ class SpriteLibrary extends React.PureComponent {
sprites
:
spriteLibraryContent
};
}
componentDidMount
()
{
const
storage
=
new
Storage
();
Promise
.
all
(
spriteLibraryContent
.
map
(
sprite
=>
Promise
.
all
(
sprite
.
json
.
costumes
.
map
(
costume
=>
{
const
[
md5
,
ext
]
=
costume
.
baseLayerMD5
.
split
(
'
.
'
);
if
(
ext
!==
'
svg
'
)
return
Promise
.
resolve
(
costume
);
return
storage
.
load
(
storage
.
AssetType
.
ImageVector
,
md5
)
.
then
(
costumeAsset
=>
new
Promise
(
resolveSVG
=>
{
const
svgRenderer
=
new
Renderer
.
SVGRenderer
();
svgRenderer
.
fromString
(
costumeAsset
.
decodeText
(),
()
=>
{
resolveSVG
(
svgRenderer
.
_toString
());
});
})
)
.
then
(
svgContents
=>
{
const
newMd5
=
storage
.
builtinHelper
.
cache
(
storage
.
AssetType
.
ImageVector
,
storage
.
DataFormat
.
SVG
,
svgContents
);
// download(svgContents, 'image/svg+xml', `${newMd5}.svg`);
costume
.
baseLayerMD5
=
`
${
newMd5
}
.svg`
;
return
costume
;
});
}))
.
then
(
costumes
=>
{
sprite
.
json
.
costumes
=
costumes
;
if
(
costumes
[
0
].
baseLayerMD5
.
split
(
'
.
'
)[
1
]
===
'
svg
'
)
sprite
.
md5
=
costumes
[
0
].
baseLayerMD5
;
return
sprite
;
})
))
.
then
(
sprites
=>
download
(
JSON
.
stringify
(
sprites
,
null
,
4
),
'
application/json
'
,
'
sprites.json
'
));
}
componentWillReceiveProps
(
newProps
)
{
if
(
!
newProps
.
visible
)
clearInterval
(
this
.
intervalId
);
}
...
...
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