Skip to content

Commit

Permalink
Save and load the origin
Browse files Browse the repository at this point in the history
  • Loading branch information
ericrosenbaum committed Apr 29, 2021
1 parent 65f22c1 commit 0b4b32d
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/engine/runtime.js
Original file line number Diff line number Diff line change
@@ -392,6 +392,13 @@ class Runtime extends EventEmitter {
* @type {function}
*/
this.removeCloudVariable = this._initializeRemoveCloudVariable(newCloudDataManager);

/**
* A string representing the origin of the current project from outside of the
* Scratch community, such as CSFirst.
* @type {?string}
*/
this.origin = null;
}

/**
10 changes: 10 additions & 0 deletions src/serialization/sb3.js
Original file line number Diff line number Diff line change
@@ -561,6 +561,9 @@ const serialize = function (runtime, targetId) {
const meta = Object.create(null);
meta.semver = '3.0.0';
meta.vm = vmPackage.version;
if (runtime.origin) {
meta.origin = runtime.origin;
}

// Attach full user agent string to metadata if available
meta.agent = 'none';
@@ -1235,6 +1238,13 @@ const deserialize = function (json, runtime, zip, isSingleSprite) {
extensionURLs: new Map()
};

// Store the origin field (e.g. project originated at CSFirst) so that we can save it again.
if (json.meta && json.meta.origin) {
runtime.origin = json.meta.origin;
} else {
runtime.origin = null;
}

// First keep track of the current target order in the json,
// then sort by the layer order property before parsing the targets
// so that their corresponding render drawables can be created in

0 comments on commit 0b4b32d

Please sign in to comment.