Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

feat: extend plugin API supports get query #374

Merged
merged 6 commits into from
Dec 16, 2022

Conversation

airslice
Copy link
Contributor

@airslice airslice commented Dec 14, 2022

close reearth/reearth-visualizer#378

Overview

Extend the plugin API enable get the query parameters in the URL.

What I've done

Implement the API:

reearth.viewport.query: Record<string, string>

Some refectors:

  • Move viewport related code into a separated file.
  • Some type updates.

What I haven't done

How I tested

  • Test with calling API on devtool console;
  • Test with plugin on plugin editor:
reearth.ui.show(`
  <style>
    html,
    body {
      margin: 0;
      font-size: 14px;
    }
    #wrapper {
      box-sizing: border-box;
      border-radius: 12px;
      padding: 12px;
      background: white;
    }
    h3{
      margin: 0 0 5px;
    }
    h4{
      margin: 10px 0 5px;
      color: #4770FF;
    }
  </style>

  <div id="wrapper">
    <h3>Location Query</h3>
    <h4>Parameters</h4>
    <div id="query"></div>
  </div>

  <script>
    addEventListener("message", (e) => {
      if (e.source !== parent) return;
      if(e.data.type === 'getLocationQuery'){
        document.getElementById("query").innerHTML = JSON.stringify(e.data.payload);
      }
    });
  </script>
`);

reearth.ui.postMessage({
  type: "getLocationQuery",
  payload: reearth.viewport.query
});

Screenshot

Which point I want you to review particularly

Memo

@netlify
Copy link

netlify bot commented Dec 14, 2022

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit d3952f1
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/639bc403d365e60008e269a4
😎 Deploy Preview https://deploy-preview-374--reearth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codecov
Copy link

codecov bot commented Dec 14, 2022

Codecov Report

Merging #374 (d3952f1) into main (172988e) will decrease coverage by 0.02%.
The diff coverage is 1.81%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
- Coverage   24.53%   24.51%   -0.03%     
==========================================
  Files         597      598       +1     
  Lines       62880    62933      +53     
  Branches     1243     1243              
==========================================
  Hits        15428    15428              
- Misses      47406    47459      +53     
  Partials       46       46              
Impacted Files Coverage Δ
src/components/molecules/Visualizer/Plugin/api.ts 5.96% <0.00%> (-0.21%) ⬇️
...rc/components/molecules/Visualizer/Plugin/types.ts 0.00% <0.00%> (ø)
src/components/molecules/Visualizer/hooks.ts 0.00% <0.00%> (ø)
src/components/molecules/Visualizer/storybook.tsx 0.00% <0.00%> (ø)
src/components/molecules/Visualizer/useViewport.ts 0.00% <0.00%> (ø)
...components/molecules/Visualizer/Plugin/context.tsx 31.69% <18.18%> (-0.34%) ⬇️

@airslice airslice marked this pull request as ready for review December 14, 2022 03:09
@airslice airslice merged commit ccae02a into main Dec 16, 2022
@airslice airslice deleted the feat/plugin-api-location-query branch December 16, 2022 01:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants