Skip to content

Commit

Permalink
remove usage of @ff/browser/parseUrlParameter in favor of native URLS…
Browse files Browse the repository at this point in the history
…earchParams object
  • Loading branch information
sdumetz committed Jun 26, 2024
1 parent 90383da commit f764fb7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 33 deletions.
38 changes: 18 additions & 20 deletions source/client/applications/ExplorerApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* limitations under the License.
*/

import parseUrlParameter from "@ff/browser/parseUrlParameter";

import TypeRegistry from "@ff/core/TypeRegistry";

import Notification from "@ff/ui/Notification";
Expand Down Expand Up @@ -265,24 +263,24 @@ Version: ${ENV_VERSION}
{
const props = this.props;
const manager = this.assetManager;

props.root = props.root || parseUrlParameter("root") || parseUrlParameter("r");
props.dracoRoot = props.dracoRoot || parseUrlParameter("dracoRoot") || parseUrlParameter("dr");
props.resourceRoot = props.resourceRoot || parseUrlParameter("resourceRoot") || parseUrlParameter("rr");
props.document = props.document || parseUrlParameter("document") || parseUrlParameter("d");
props.model = props.model || parseUrlParameter("model") || parseUrlParameter("m");
props.geometry = props.geometry || parseUrlParameter("geometry") || parseUrlParameter("g");
props.texture = props.texture || parseUrlParameter("texture") || parseUrlParameter("t");
props.occlusion = props.occlusion || parseUrlParameter("occlusion") || parseUrlParameter("o");
props.normals = props.normals || parseUrlParameter("normals") || parseUrlParameter("n");
props.quality = props.quality || parseUrlParameter("quality") || parseUrlParameter("q");
props.uiMode = props.uiMode || parseUrlParameter("uiMode") || parseUrlParameter("u");
props.bgColor = props.bgColor || parseUrlParameter("bgColor") || parseUrlParameter("bc");
props.bgStyle = props.bgStyle || parseUrlParameter("bgStyle") || parseUrlParameter("bs");
props.controls = props.controls || parseUrlParameter("controls") || parseUrlParameter("ct");
props.prompt = props.prompt || parseUrlParameter("prompt") || parseUrlParameter("pm");
props.reader = props.reader || parseUrlParameter("reader") || parseUrlParameter("rdr");
props.lang = props.lang || parseUrlParameter("lang") || parseUrlParameter("l");
const qs = new URL(window.location.href).searchParams;
props.root = props.root || qs.get("root") || qs.get("r");
props.dracoRoot = props.dracoRoot || qs.get("dracoRoot") || qs.get("dr");
props.resourceRoot = props.resourceRoot || qs.get("resourceRoot") || qs.get("rr");
props.document = props.document || qs.get("document") || qs.get("d");
props.model = props.model || qs.get("model") || qs.get("m");
props.geometry = props.geometry || qs.get("geometry") || qs.get("g");
props.texture = props.texture || qs.get("texture") || qs.get("t");
props.occlusion = props.occlusion || qs.get("occlusion") || qs.get("o");
props.normals = props.normals || qs.get("normals") || qs.get("n");
props.quality = props.quality || qs.get("quality") || qs.get("q");
props.uiMode = props.uiMode || qs.get("uiMode") || qs.get("u");
props.bgColor = props.bgColor || qs.get("bgColor") || qs.get("bc");
props.bgStyle = props.bgStyle || qs.get("bgStyle") || qs.get("bs");
props.controls = props.controls || qs.get("controls") || qs.get("ct");
props.prompt = props.prompt || qs.get("prompt") || qs.get("pm");
props.reader = props.reader || qs.get("reader") || qs.get("rdr");
props.lang = props.lang || qs.get("lang") || qs.get("l");

const url = props.root || props.document || props.model || props.geometry;
this.setBaseUrl(new URL(url || ".", window.location as any).href);
Expand Down
14 changes: 7 additions & 7 deletions source/client/applications/MiniApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import parseUrlParameter from "@ff/browser/parseUrlParameter";

import TypeRegistry from "@ff/core/TypeRegistry";

Expand Down Expand Up @@ -175,12 +174,13 @@ export default class MiniApplication
const props = this.props;
const manager = this.assetManager;

props.root = props.root || parseUrlParameter("root") || parseUrlParameter("r");
props.document = props.document || parseUrlParameter("document") || parseUrlParameter("d");
props.model = props.model || parseUrlParameter("model") || parseUrlParameter("m");
props.geometry = props.geometry || parseUrlParameter("geometry") || parseUrlParameter("g");
props.texture = props.texture || parseUrlParameter("texture") || parseUrlParameter("t");
props.quality = props.quality || parseUrlParameter("quality") || parseUrlParameter("q");
const qs = new URL(window.location.href).searchParams;
props.root = props.root || qs.get("root") || qs.get("r");
props.document = props.document || qs.get("document") || qs.get("d");
props.model = props.model || qs.get("model") || qs.get("m");
props.geometry = props.geometry || qs.get("geometry") || qs.get("g");
props.texture = props.texture || qs.get("texture") || qs.get("t");
props.quality = props.quality || qs.get("quality") || qs.get("q");

const url = props.root || props.document || props.model || props.geometry;
this.setBaseUrl(new URL(url || ".", window.location as any).href);
Expand Down
8 changes: 4 additions & 4 deletions source/client/applications/StoryApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import parseUrlParameter from "@ff/browser/parseUrlParameter";
import System from "@ff/graph/System";

import CPickSelection from "@ff/scene/components/CPickSelection";
Expand Down Expand Up @@ -144,9 +143,10 @@ export default class StoryApplication
{
const props = this.props;

props.referrer = props.referrer || parseUrlParameter("referrer");
props.mode = props.mode || parseUrlParameter("mode") || "prep";
props.expert = props.expert !== undefined ? props.expert : parseUrlParameter("expert") !== "false";
const qs = new URL(window.location.href).searchParams;
props.referrer = props.referrer || qs.get("referrer");
props.mode = props.mode || qs.get("mode") || "prep";
props.expert = props.expert !== undefined ? props.expert : qs.get("expert") !== "false";
props.dragdrop = props.dragdrop || false;

// If in standalone mode, remove root and document params that may be present
Expand Down
3 changes: 1 addition & 2 deletions source/client/ui/story/MainView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import parseUrlParameter from "@ff/browser/parseUrlParameter";
import localStorage from "@ff/browser/localStorage";

import StoryApplication, { IStoryApplicationProps } from "../../applications/StoryApplication";
Expand Down Expand Up @@ -146,7 +145,7 @@ export default class MainView extends CustomElement
registry.set("article-editor", () => new EditorPanel(system));
registry.set("collection", () => new CollectionPanel(system));

const reset = parseUrlParameter("reset") !== undefined;
const reset = new URL(window.location.href).searchParams.get("reset") !== null;
const state = reset ? null : localStorage.get("voyager-story", MainView.stateKey);

this.state = state || {
Expand Down

0 comments on commit f764fb7

Please sign in to comment.