Skip to content

Commit

Permalink
hotfix for save error in production
Browse files Browse the repository at this point in the history
* this replaces json-utils.js needed for editor in production with the 0.4.6 version
* this still uses the new jsonutils as a 1.1 version for latest version
* soon we can revert this and get rid of json-utils versions
  • Loading branch information
kfarr committed Feb 26, 2024
1 parent 413b078 commit 57efa3a
Show file tree
Hide file tree
Showing 4 changed files with 694 additions and 32 deletions.
4 changes: 2 additions & 2 deletions dist/aframe-street-component.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require('babel-polyfill');
if (typeof VERSION !== 'undefined') { console.log(`3DStreet Version: ${VERSION} (Date: ${new Date(COMMIT_DATE).toISOString().split('T')[0]}, Commit Hash: #${COMMIT_HASH})`); }
var streetmixParsers = require('./aframe-streetmix-parsers');
var streetmixUtils = require('./tested/streetmix-utils');
require('./json-utils.js');
require('./json-utils_1.1.js');
require('./components/gltf-part');
require('./components/ocean');
require('./components/svg-extruder.js');
Expand Down
35 changes: 6 additions & 29 deletions src/json-utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* global AFRAME, Node */
/* version: 1.0 */

window.STREET = {};
var assetsUrl;
var STREET = {};
STREET.utils = {};

function getSceneUuidFromURLHash () {
Expand Down Expand Up @@ -44,9 +43,6 @@ function convertDOMElToObject (entity) {
const referenceEntities = document.querySelector('#reference-layers');
const sceneEntities = [entity, environmentElement, referenceEntities];

// get assets url address
assetsUrl = document.querySelector('street-assets').getAttribute('url');

for (const entry of sceneEntities) {
const entityData = getElementData(entry);
if (entityData) {
Expand All @@ -60,8 +56,6 @@ function convertDOMElToObject (entity) {
};
}

STREET.utils.convertDOMElToObject = convertDOMElToObject;

function getElementData (entity) {
if (!entity.isEntity) {
return;
Expand Down Expand Up @@ -143,12 +137,7 @@ function toPropString (propData) {
return Object.entries(propData)
.map(([key, value]) => {
if (key == 'src') {
// checking to ensure the object's src value is correctly stored
if (value.src && !value.src.includes(assetsUrl)) {
// asset came from external sources. So need to save it src value if it has
return `${key}: ${value.src}`;
} else if (value.id) {
// asset came from 3dstreet. So it has id for link to it
if (value.id) {
return `${key}: #${value.id}`;
} else {
return `${key}: ${value}`;
Expand Down Expand Up @@ -186,7 +175,7 @@ const renameProps = {
intersection: 'not-intersection'
};

function filterJSONstreet (streetJSON) {
function filterJSONstreet (removeProps, renameProps, streetJSON) {
function removeValueCheck (removeVal, value) {
if (AFRAME.utils.deepEqual(removeVal, value) || removeVal === '*') {
return true;
Expand All @@ -195,11 +184,10 @@ function filterJSONstreet (streetJSON) {
}

let stringJSON = JSON.stringify(streetJSON, function replacer (key, value) {
let compAttributes;
const compAttributes = AFRAME.utils.styleParser.parse(value);
for (var removeKey in removeProps) {
// check for removing components
if (key === removeKey) {
compAttributes = AFRAME.utils.styleParser.parse(value);
const removeVal = removeProps[removeKey];
// check for deleting component's attribute
if (typeof removeVal === 'object' && !isEmpty(removeVal)) {
Expand All @@ -222,7 +210,7 @@ function filterJSONstreet (streetJSON) {
}
}

return compAttributes || value;
return compAttributes;
});
// rename components
for (var renameKey in renameProps) {
Expand All @@ -232,8 +220,6 @@ function filterJSONstreet (streetJSON) {
return stringJSON;
}

STREET.utils.filterJSONstreet = filterJSONstreet;

/**
* function from 3dstreet-editor/src/lib/entity.js
* Gets the value for a component or component's property coming from mixins of
Expand Down Expand Up @@ -380,8 +366,6 @@ function createEntities (entitiesData, parentEl) {
}
}

STREET.utils.createEntities = createEntities;

/*
Add a new entity with a list of components and children (if exists)
* @param {object} entityData Entity definition to add:
Expand Down Expand Up @@ -566,7 +550,7 @@ AFRAME.registerComponent('set-loader-from-hash', {
'[set-loader-from-hash]',
'200 response received and JSON parsed, now createElementsFromJSON'
);
STREET.utils.createElementsFromJSON(jsonData);
createElementsFromJSON(jsonData);
const sceneId = getUUIDFromPath(requestURL);
if (sceneId) {
console.log('sceneId from fetchJSON from url hash loader', sceneId);
Expand Down Expand Up @@ -624,8 +608,6 @@ function inputStreetmix () {
'""></a-entity>';
}

STREET.utils.inputStreetmix = inputStreetmix;

// JSON loading starts here
function getValidJSON (stringJSON) {
// Preserve newlines, etc. - use valid JSON
Expand Down Expand Up @@ -660,8 +642,6 @@ function createElementsFromJSON (streetJSON) {
STREET.notify.successMessage('Scene loaded from JSON');
}

STREET.utils.createElementsFromJSON = createElementsFromJSON;

// viewer widget click to paste json string of 3dstreet scene
function inputJSON () {
const stringJSON = prompt('Please paste 3DStreet JSON string');
Expand All @@ -680,6 +660,3 @@ function fileJSON () {
};
reader.readAsText(this.files[0]);
}

// temporarily place the UI function in utils, which is used in index.html.
STREET.utils.fileJSON = fileJSON;
Loading

0 comments on commit 57efa3a

Please sign in to comment.