mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-09 06:12:34 -05:00
Prebuilt module for commit 56dd636f22
This commit is contained in:
parent
c7c9d74dba
commit
b4cf0c6fcd
5 changed files with 93 additions and 75 deletions
46
dist/docs/assets/js/paper.js
vendored
46
dist/docs/assets/js/paper.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Sun Feb 14 15:12:52 2016 +0100
|
* Date: Sun Feb 14 17:16:40 2016 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -265,6 +265,10 @@ Base.inject({
|
||||||
return this._class || '';
|
return this._class || '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
importJSON: function(json) {
|
||||||
|
return Base.importJSON(json, this);
|
||||||
|
},
|
||||||
|
|
||||||
exportJSON: function(options) {
|
exportJSON: function(options) {
|
||||||
return Base.exportJSON(this, options);
|
return Base.exportJSON(this, options);
|
||||||
},
|
},
|
||||||
|
@ -423,9 +427,9 @@ Base.inject({
|
||||||
serialize: function(obj, options, compact, dictionary) {
|
serialize: function(obj, options, compact, dictionary) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var root = !dictionary,
|
var isRoot = !dictionary,
|
||||||
res;
|
res;
|
||||||
if (root) {
|
if (isRoot) {
|
||||||
options.formatter = new Formatter(options.precision);
|
options.formatter = new Formatter(options.precision);
|
||||||
dictionary = {
|
dictionary = {
|
||||||
length: 0,
|
length: 0,
|
||||||
|
@ -450,15 +454,15 @@ Base.inject({
|
||||||
if (obj && obj._serialize) {
|
if (obj && obj._serialize) {
|
||||||
res = obj._serialize(options, dictionary);
|
res = obj._serialize(options, dictionary);
|
||||||
var name = obj._class;
|
var name = obj._class;
|
||||||
if (name && !compact && !res._compact && res[0] !== name)
|
if (name && !obj._compactSerialize && (isRoot || !compact)
|
||||||
|
&& res[0] !== name) {
|
||||||
res.unshift(name);
|
res.unshift(name);
|
||||||
|
}
|
||||||
} else if (Array.isArray(obj)) {
|
} else if (Array.isArray(obj)) {
|
||||||
res = [];
|
res = [];
|
||||||
for (var i = 0, l = obj.length; i < l; i++)
|
for (var i = 0, l = obj.length; i < l; i++)
|
||||||
res[i] = Base.serialize(obj[i], options, compact,
|
res[i] = Base.serialize(obj[i], options, compact,
|
||||||
dictionary);
|
dictionary);
|
||||||
if (compact)
|
|
||||||
res._compact = true;
|
|
||||||
} else if (Base.isPlainObject(obj)) {
|
} else if (Base.isPlainObject(obj)) {
|
||||||
res = {};
|
res = {};
|
||||||
var keys = Object.keys(obj);
|
var keys = Object.keys(obj);
|
||||||
|
@ -472,31 +476,33 @@ Base.inject({
|
||||||
} else {
|
} else {
|
||||||
res = obj;
|
res = obj;
|
||||||
}
|
}
|
||||||
return root && dictionary.length > 0
|
return isRoot && dictionary.length > 0
|
||||||
? [['dictionary', dictionary.definitions], res]
|
? [['dictionary', dictionary.definitions], res]
|
||||||
: res;
|
: res;
|
||||||
},
|
},
|
||||||
|
|
||||||
deserialize: function(json, create, _data, _isDictionary) {
|
deserialize: function(json, create, _data, _setDictionary, _isRoot) {
|
||||||
var res = json,
|
var res = json,
|
||||||
isRoot = !_data;
|
isFirst = !_data,
|
||||||
|
hasDictionary = isFirst && json && json.length
|
||||||
|
&& json[0][0] === 'dictionary';
|
||||||
_data = _data || {};
|
_data = _data || {};
|
||||||
if (Array.isArray(json)) {
|
if (Array.isArray(json)) {
|
||||||
var type = json[0],
|
var type = json[0],
|
||||||
isDictionary = type === 'dictionary';
|
isDictionary = type === 'dictionary';
|
||||||
if (json.length == 1 && /^#/.test(type))
|
if (json.length == 1 && /^#/.test(type)) {
|
||||||
return _data.dictionary[type];
|
return _data.dictionary[type];
|
||||||
|
}
|
||||||
type = Base.exports[type];
|
type = Base.exports[type];
|
||||||
res = [];
|
res = [];
|
||||||
if (_isDictionary)
|
for (var i = type ? 1 : 0, l = json.length; i < l; i++) {
|
||||||
_data.dictionary = res;
|
|
||||||
for (var i = type ? 1 : 0, l = json.length; i < l; i++)
|
|
||||||
res.push(Base.deserialize(json[i], create, _data,
|
res.push(Base.deserialize(json[i], create, _data,
|
||||||
isDictionary));
|
isDictionary, hasDictionary));
|
||||||
|
}
|
||||||
if (type) {
|
if (type) {
|
||||||
var args = res;
|
var args = res;
|
||||||
if (create) {
|
if (create) {
|
||||||
res = create(type, args, isRoot);
|
res = create(type, args, isFirst || _isRoot);
|
||||||
} else {
|
} else {
|
||||||
res = Base.create(type.prototype);
|
res = Base.create(type.prototype);
|
||||||
type.apply(res, args);
|
type.apply(res, args);
|
||||||
|
@ -504,14 +510,12 @@ Base.inject({
|
||||||
}
|
}
|
||||||
} else if (Base.isPlainObject(json)) {
|
} else if (Base.isPlainObject(json)) {
|
||||||
res = {};
|
res = {};
|
||||||
if (_isDictionary)
|
if (_setDictionary)
|
||||||
_data.dictionary = res;
|
_data.dictionary = res;
|
||||||
for (var key in json)
|
for (var key in json)
|
||||||
res[key] = Base.deserialize(json[key], create, _data);
|
res[key] = Base.deserialize(json[key], create, _data);
|
||||||
}
|
}
|
||||||
return isRoot && json && json.length && json[0][0] === 'dictionary'
|
return hasDictionary ? res[1] : res;
|
||||||
? res[1]
|
|
||||||
: res;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
exportJSON: function(obj, options) {
|
exportJSON: function(obj, options) {
|
||||||
|
@ -529,7 +533,8 @@ Base.inject({
|
||||||
&& target.constructor === ctor,
|
&& target.constructor === ctor,
|
||||||
obj = useTarget ? target
|
obj = useTarget ? target
|
||||||
: Base.create(ctor.prototype),
|
: Base.create(ctor.prototype),
|
||||||
init = useTarget ? obj._initialize || obj._set
|
init = useTarget
|
||||||
|
? obj._initialize || obj.initialize || obj._set
|
||||||
: ctor;
|
: ctor;
|
||||||
if (args.length === 1 && obj instanceof Item
|
if (args.length === 1 && obj instanceof Item
|
||||||
&& (useTarget || !(obj instanceof Layer))) {
|
&& (useTarget || !(obj instanceof Layer))) {
|
||||||
|
@ -2552,6 +2557,7 @@ var Project = PaperScopeItem.extend({
|
||||||
_class: 'Project',
|
_class: 'Project',
|
||||||
_list: 'projects',
|
_list: 'projects',
|
||||||
_reference: 'project',
|
_reference: 'project',
|
||||||
|
_compactSerialize: true,
|
||||||
|
|
||||||
initialize: function Project(element) {
|
initialize: function Project(element) {
|
||||||
PaperScopeItem.call(this, true);
|
PaperScopeItem.call(this, true);
|
||||||
|
|
46
dist/paper-core.js
vendored
46
dist/paper-core.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Sun Feb 14 15:12:52 2016 +0100
|
* Date: Sun Feb 14 17:16:40 2016 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -265,6 +265,10 @@ Base.inject({
|
||||||
return this._class || '';
|
return this._class || '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
importJSON: function(json) {
|
||||||
|
return Base.importJSON(json, this);
|
||||||
|
},
|
||||||
|
|
||||||
exportJSON: function(options) {
|
exportJSON: function(options) {
|
||||||
return Base.exportJSON(this, options);
|
return Base.exportJSON(this, options);
|
||||||
},
|
},
|
||||||
|
@ -423,9 +427,9 @@ Base.inject({
|
||||||
serialize: function(obj, options, compact, dictionary) {
|
serialize: function(obj, options, compact, dictionary) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var root = !dictionary,
|
var isRoot = !dictionary,
|
||||||
res;
|
res;
|
||||||
if (root) {
|
if (isRoot) {
|
||||||
options.formatter = new Formatter(options.precision);
|
options.formatter = new Formatter(options.precision);
|
||||||
dictionary = {
|
dictionary = {
|
||||||
length: 0,
|
length: 0,
|
||||||
|
@ -450,15 +454,15 @@ Base.inject({
|
||||||
if (obj && obj._serialize) {
|
if (obj && obj._serialize) {
|
||||||
res = obj._serialize(options, dictionary);
|
res = obj._serialize(options, dictionary);
|
||||||
var name = obj._class;
|
var name = obj._class;
|
||||||
if (name && !compact && !res._compact && res[0] !== name)
|
if (name && !obj._compactSerialize && (isRoot || !compact)
|
||||||
|
&& res[0] !== name) {
|
||||||
res.unshift(name);
|
res.unshift(name);
|
||||||
|
}
|
||||||
} else if (Array.isArray(obj)) {
|
} else if (Array.isArray(obj)) {
|
||||||
res = [];
|
res = [];
|
||||||
for (var i = 0, l = obj.length; i < l; i++)
|
for (var i = 0, l = obj.length; i < l; i++)
|
||||||
res[i] = Base.serialize(obj[i], options, compact,
|
res[i] = Base.serialize(obj[i], options, compact,
|
||||||
dictionary);
|
dictionary);
|
||||||
if (compact)
|
|
||||||
res._compact = true;
|
|
||||||
} else if (Base.isPlainObject(obj)) {
|
} else if (Base.isPlainObject(obj)) {
|
||||||
res = {};
|
res = {};
|
||||||
var keys = Object.keys(obj);
|
var keys = Object.keys(obj);
|
||||||
|
@ -472,31 +476,33 @@ Base.inject({
|
||||||
} else {
|
} else {
|
||||||
res = obj;
|
res = obj;
|
||||||
}
|
}
|
||||||
return root && dictionary.length > 0
|
return isRoot && dictionary.length > 0
|
||||||
? [['dictionary', dictionary.definitions], res]
|
? [['dictionary', dictionary.definitions], res]
|
||||||
: res;
|
: res;
|
||||||
},
|
},
|
||||||
|
|
||||||
deserialize: function(json, create, _data, _isDictionary) {
|
deserialize: function(json, create, _data, _setDictionary, _isRoot) {
|
||||||
var res = json,
|
var res = json,
|
||||||
isRoot = !_data;
|
isFirst = !_data,
|
||||||
|
hasDictionary = isFirst && json && json.length
|
||||||
|
&& json[0][0] === 'dictionary';
|
||||||
_data = _data || {};
|
_data = _data || {};
|
||||||
if (Array.isArray(json)) {
|
if (Array.isArray(json)) {
|
||||||
var type = json[0],
|
var type = json[0],
|
||||||
isDictionary = type === 'dictionary';
|
isDictionary = type === 'dictionary';
|
||||||
if (json.length == 1 && /^#/.test(type))
|
if (json.length == 1 && /^#/.test(type)) {
|
||||||
return _data.dictionary[type];
|
return _data.dictionary[type];
|
||||||
|
}
|
||||||
type = Base.exports[type];
|
type = Base.exports[type];
|
||||||
res = [];
|
res = [];
|
||||||
if (_isDictionary)
|
for (var i = type ? 1 : 0, l = json.length; i < l; i++) {
|
||||||
_data.dictionary = res;
|
|
||||||
for (var i = type ? 1 : 0, l = json.length; i < l; i++)
|
|
||||||
res.push(Base.deserialize(json[i], create, _data,
|
res.push(Base.deserialize(json[i], create, _data,
|
||||||
isDictionary));
|
isDictionary, hasDictionary));
|
||||||
|
}
|
||||||
if (type) {
|
if (type) {
|
||||||
var args = res;
|
var args = res;
|
||||||
if (create) {
|
if (create) {
|
||||||
res = create(type, args, isRoot);
|
res = create(type, args, isFirst || _isRoot);
|
||||||
} else {
|
} else {
|
||||||
res = Base.create(type.prototype);
|
res = Base.create(type.prototype);
|
||||||
type.apply(res, args);
|
type.apply(res, args);
|
||||||
|
@ -504,14 +510,12 @@ Base.inject({
|
||||||
}
|
}
|
||||||
} else if (Base.isPlainObject(json)) {
|
} else if (Base.isPlainObject(json)) {
|
||||||
res = {};
|
res = {};
|
||||||
if (_isDictionary)
|
if (_setDictionary)
|
||||||
_data.dictionary = res;
|
_data.dictionary = res;
|
||||||
for (var key in json)
|
for (var key in json)
|
||||||
res[key] = Base.deserialize(json[key], create, _data);
|
res[key] = Base.deserialize(json[key], create, _data);
|
||||||
}
|
}
|
||||||
return isRoot && json && json.length && json[0][0] === 'dictionary'
|
return hasDictionary ? res[1] : res;
|
||||||
? res[1]
|
|
||||||
: res;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
exportJSON: function(obj, options) {
|
exportJSON: function(obj, options) {
|
||||||
|
@ -529,7 +533,8 @@ Base.inject({
|
||||||
&& target.constructor === ctor,
|
&& target.constructor === ctor,
|
||||||
obj = useTarget ? target
|
obj = useTarget ? target
|
||||||
: Base.create(ctor.prototype),
|
: Base.create(ctor.prototype),
|
||||||
init = useTarget ? obj._initialize || obj._set
|
init = useTarget
|
||||||
|
? obj._initialize || obj.initialize || obj._set
|
||||||
: ctor;
|
: ctor;
|
||||||
if (args.length === 1 && obj instanceof Item
|
if (args.length === 1 && obj instanceof Item
|
||||||
&& (useTarget || !(obj instanceof Layer))) {
|
&& (useTarget || !(obj instanceof Layer))) {
|
||||||
|
@ -2552,6 +2557,7 @@ var Project = PaperScopeItem.extend({
|
||||||
_class: 'Project',
|
_class: 'Project',
|
||||||
_list: 'projects',
|
_list: 'projects',
|
||||||
_reference: 'project',
|
_reference: 'project',
|
||||||
|
_compactSerialize: true,
|
||||||
|
|
||||||
initialize: function Project(element) {
|
initialize: function Project(element) {
|
||||||
PaperScopeItem.call(this, true);
|
PaperScopeItem.call(this, true);
|
||||||
|
|
16
dist/paper-core.min.js
vendored
16
dist/paper-core.min.js
vendored
File diff suppressed because one or more lines are too long
46
dist/paper-full.js
vendored
46
dist/paper-full.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Sun Feb 14 15:12:52 2016 +0100
|
* Date: Sun Feb 14 17:16:40 2016 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -265,6 +265,10 @@ Base.inject({
|
||||||
return this._class || '';
|
return this._class || '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
importJSON: function(json) {
|
||||||
|
return Base.importJSON(json, this);
|
||||||
|
},
|
||||||
|
|
||||||
exportJSON: function(options) {
|
exportJSON: function(options) {
|
||||||
return Base.exportJSON(this, options);
|
return Base.exportJSON(this, options);
|
||||||
},
|
},
|
||||||
|
@ -423,9 +427,9 @@ Base.inject({
|
||||||
serialize: function(obj, options, compact, dictionary) {
|
serialize: function(obj, options, compact, dictionary) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var root = !dictionary,
|
var isRoot = !dictionary,
|
||||||
res;
|
res;
|
||||||
if (root) {
|
if (isRoot) {
|
||||||
options.formatter = new Formatter(options.precision);
|
options.formatter = new Formatter(options.precision);
|
||||||
dictionary = {
|
dictionary = {
|
||||||
length: 0,
|
length: 0,
|
||||||
|
@ -450,15 +454,15 @@ Base.inject({
|
||||||
if (obj && obj._serialize) {
|
if (obj && obj._serialize) {
|
||||||
res = obj._serialize(options, dictionary);
|
res = obj._serialize(options, dictionary);
|
||||||
var name = obj._class;
|
var name = obj._class;
|
||||||
if (name && !compact && !res._compact && res[0] !== name)
|
if (name && !obj._compactSerialize && (isRoot || !compact)
|
||||||
|
&& res[0] !== name) {
|
||||||
res.unshift(name);
|
res.unshift(name);
|
||||||
|
}
|
||||||
} else if (Array.isArray(obj)) {
|
} else if (Array.isArray(obj)) {
|
||||||
res = [];
|
res = [];
|
||||||
for (var i = 0, l = obj.length; i < l; i++)
|
for (var i = 0, l = obj.length; i < l; i++)
|
||||||
res[i] = Base.serialize(obj[i], options, compact,
|
res[i] = Base.serialize(obj[i], options, compact,
|
||||||
dictionary);
|
dictionary);
|
||||||
if (compact)
|
|
||||||
res._compact = true;
|
|
||||||
} else if (Base.isPlainObject(obj)) {
|
} else if (Base.isPlainObject(obj)) {
|
||||||
res = {};
|
res = {};
|
||||||
var keys = Object.keys(obj);
|
var keys = Object.keys(obj);
|
||||||
|
@ -472,31 +476,33 @@ Base.inject({
|
||||||
} else {
|
} else {
|
||||||
res = obj;
|
res = obj;
|
||||||
}
|
}
|
||||||
return root && dictionary.length > 0
|
return isRoot && dictionary.length > 0
|
||||||
? [['dictionary', dictionary.definitions], res]
|
? [['dictionary', dictionary.definitions], res]
|
||||||
: res;
|
: res;
|
||||||
},
|
},
|
||||||
|
|
||||||
deserialize: function(json, create, _data, _isDictionary) {
|
deserialize: function(json, create, _data, _setDictionary, _isRoot) {
|
||||||
var res = json,
|
var res = json,
|
||||||
isRoot = !_data;
|
isFirst = !_data,
|
||||||
|
hasDictionary = isFirst && json && json.length
|
||||||
|
&& json[0][0] === 'dictionary';
|
||||||
_data = _data || {};
|
_data = _data || {};
|
||||||
if (Array.isArray(json)) {
|
if (Array.isArray(json)) {
|
||||||
var type = json[0],
|
var type = json[0],
|
||||||
isDictionary = type === 'dictionary';
|
isDictionary = type === 'dictionary';
|
||||||
if (json.length == 1 && /^#/.test(type))
|
if (json.length == 1 && /^#/.test(type)) {
|
||||||
return _data.dictionary[type];
|
return _data.dictionary[type];
|
||||||
|
}
|
||||||
type = Base.exports[type];
|
type = Base.exports[type];
|
||||||
res = [];
|
res = [];
|
||||||
if (_isDictionary)
|
for (var i = type ? 1 : 0, l = json.length; i < l; i++) {
|
||||||
_data.dictionary = res;
|
|
||||||
for (var i = type ? 1 : 0, l = json.length; i < l; i++)
|
|
||||||
res.push(Base.deserialize(json[i], create, _data,
|
res.push(Base.deserialize(json[i], create, _data,
|
||||||
isDictionary));
|
isDictionary, hasDictionary));
|
||||||
|
}
|
||||||
if (type) {
|
if (type) {
|
||||||
var args = res;
|
var args = res;
|
||||||
if (create) {
|
if (create) {
|
||||||
res = create(type, args, isRoot);
|
res = create(type, args, isFirst || _isRoot);
|
||||||
} else {
|
} else {
|
||||||
res = Base.create(type.prototype);
|
res = Base.create(type.prototype);
|
||||||
type.apply(res, args);
|
type.apply(res, args);
|
||||||
|
@ -504,14 +510,12 @@ Base.inject({
|
||||||
}
|
}
|
||||||
} else if (Base.isPlainObject(json)) {
|
} else if (Base.isPlainObject(json)) {
|
||||||
res = {};
|
res = {};
|
||||||
if (_isDictionary)
|
if (_setDictionary)
|
||||||
_data.dictionary = res;
|
_data.dictionary = res;
|
||||||
for (var key in json)
|
for (var key in json)
|
||||||
res[key] = Base.deserialize(json[key], create, _data);
|
res[key] = Base.deserialize(json[key], create, _data);
|
||||||
}
|
}
|
||||||
return isRoot && json && json.length && json[0][0] === 'dictionary'
|
return hasDictionary ? res[1] : res;
|
||||||
? res[1]
|
|
||||||
: res;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
exportJSON: function(obj, options) {
|
exportJSON: function(obj, options) {
|
||||||
|
@ -529,7 +533,8 @@ Base.inject({
|
||||||
&& target.constructor === ctor,
|
&& target.constructor === ctor,
|
||||||
obj = useTarget ? target
|
obj = useTarget ? target
|
||||||
: Base.create(ctor.prototype),
|
: Base.create(ctor.prototype),
|
||||||
init = useTarget ? obj._initialize || obj._set
|
init = useTarget
|
||||||
|
? obj._initialize || obj.initialize || obj._set
|
||||||
: ctor;
|
: ctor;
|
||||||
if (args.length === 1 && obj instanceof Item
|
if (args.length === 1 && obj instanceof Item
|
||||||
&& (useTarget || !(obj instanceof Layer))) {
|
&& (useTarget || !(obj instanceof Layer))) {
|
||||||
|
@ -2552,6 +2557,7 @@ var Project = PaperScopeItem.extend({
|
||||||
_class: 'Project',
|
_class: 'Project',
|
||||||
_list: 'projects',
|
_list: 'projects',
|
||||||
_reference: 'project',
|
_reference: 'project',
|
||||||
|
_compactSerialize: true,
|
||||||
|
|
||||||
initialize: function Project(element) {
|
initialize: function Project(element) {
|
||||||
PaperScopeItem.call(this, true);
|
PaperScopeItem.call(this, true);
|
||||||
|
|
14
dist/paper-full.min.js
vendored
14
dist/paper-full.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue