@3cr/viewer-browser 0.0.126 → 0.0.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -8,9 +8,19 @@ import {
8
8
  } from "@/models/LoadViewerOptions";
9
9
  import { LoadViewerPayload } from "@/models/LoadViewerPayload";
10
10
  import { disableTheme } from "@/plugins/vuetify";
11
+ import { injectedStyleId } from "./config";
11
12
 
12
13
  let mountedApp: ComponentPublicInstance | undefined = undefined;
13
14
 
15
+ let modalId = `__${uuidv4()}__`;
16
+ function uuidv4() {
17
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) =>
18
+ (
19
+ +c ^
20
+ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))
21
+ ).toString(16)
22
+ );
23
+ }
14
24
  export async function registerViewer(
15
25
  version: string,
16
26
  options = {
@@ -21,7 +31,7 @@ export async function registerViewer(
21
31
 
22
32
  newElement.style.width = "0";
23
33
  newElement.style.height = "0";
24
- // newElement.style.all = "initial";
34
+ newElement.id = modalId;
25
35
 
26
36
  document.body.appendChild(newElement);
27
37
 
@@ -47,3 +57,11 @@ export async function loadViewer(
47
57
  }
48
58
  await (mountedApp as any).loadInstance(payload, options);
49
59
  }
60
+
61
+ export async function ejectViewer() {
62
+ const modal = document.getElementById(modalId);
63
+ const styleSheet = document.getElementById(injectedStyleId);
64
+
65
+ modal?.remove();
66
+ styleSheet?.remove();
67
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3cr/viewer-browser",
3
- "version": "0.0.126",
3
+ "version": "0.0.130",
4
4
  "main": "./dist/Viewer3CR.umd.js",
5
5
  "module": "dist/Viewer3CR.umd.js",
6
6
  "homepage": "https://docs.3cr.singular.health",
package/vite.config.mts CHANGED
@@ -7,8 +7,8 @@ import ViteFonts from 'unplugin-fonts/vite'
7
7
  // Utilities
8
8
  import { defineConfig } from 'vite'
9
9
  import { fileURLToPath, URL } from 'node:url'
10
- import {resolve} from "node:dns";
11
10
  import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
11
+ import {injectedStyleId} from "./config";
12
12
 
13
13
  // https://vitejs.dev/config/
14
14
  export default defineConfig({
@@ -19,7 +19,7 @@ export default defineConfig({
19
19
  // https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin#readme
20
20
  Vuetify(),
21
21
  Components(),
22
- cssInjectedByJsPlugin(),
22
+ cssInjectedByJsPlugin({styleId: injectedStyleId}),
23
23
  ViteFonts({
24
24
  google: {
25
25
  families: [{