Skip to content

Commit e8caa52

Browse files
fix: uses same unload method, does not reference window object
1 parent 1d83753 commit e8caa52

File tree

13 files changed

+32
-62
lines changed

13 files changed

+32
-62
lines changed

frameworks/angular/TS/src/nutrient/custom-overlays/implementation.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function loadCustomOverlaysViewer(
3939
* @param defaultConfiguration - Base configuration object
4040
*/
4141
function load(
42-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
42+
nutrientViewer: typeof NutrientViewer,
4343
defaultConfiguration: Configuration,
4444
) {
4545
return nutrientViewer.load(defaultConfiguration).then((instance) => {
@@ -61,9 +61,7 @@ function load(
6161
});
6262
}
6363

64-
function getOverlayItemForPage1(
65-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
66-
) {
64+
function getOverlayItemForPage1(nutrientViewer: typeof NutrientViewer) {
6765
// We create a div element with an emoji and a short text.
6866
const overlayElement = document.createElement("div");
6967

@@ -81,9 +79,7 @@ function getOverlayItemForPage1(
8179
});
8280
}
8381

84-
function getOverlayItemForPage2(
85-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
86-
) {
82+
function getOverlayItemForPage2(nutrientViewer: typeof NutrientViewer) {
8783
const overlayElement = document.createElement("div");
8884

8985
// In this case we embed a video to the page

frameworks/next/TS/nutrient/custom-overlays/implementation.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function loadCustomOverlaysViewer(
3939
* @param defaultConfiguration - Base configuration object
4040
*/
4141
function load(
42-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
42+
nutrientViewer: typeof NutrientViewer,
4343
defaultConfiguration: Configuration,
4444
) {
4545
return nutrientViewer.load(defaultConfiguration).then((instance) => {
@@ -61,9 +61,7 @@ function load(
6161
});
6262
}
6363

64-
function getOverlayItemForPage1(
65-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
66-
) {
64+
function getOverlayItemForPage1(nutrientViewer: typeof NutrientViewer) {
6765
// We create a div element with an emoji and a short text.
6866
const overlayElement = document.createElement("div");
6967

@@ -81,9 +79,7 @@ function getOverlayItemForPage1(
8179
});
8280
}
8381

84-
function getOverlayItemForPage2(
85-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
86-
) {
82+
function getOverlayItemForPage2(nutrientViewer: typeof NutrientViewer) {
8783
const overlayElement = document.createElement("div");
8884

8985
// In this case we embed a video to the page

frameworks/next/TS/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"name": "next"
1818
}
1919
],
20+
"baseUrl": ".",
2021
"paths": {
21-
"@/*": ["*"]
22+
"@/*": ["./*"]
2223
},
2324
"target": "ES2017"
2425
},

frameworks/nuxt/TS/nutrient/custom-overlays/implementation.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function loadCustomOverlaysViewer(
3939
* @param defaultConfiguration - Base configuration object
4040
*/
4141
function load(
42-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
42+
nutrientViewer: typeof NutrientViewer,
4343
defaultConfiguration: Configuration,
4444
) {
4545
return nutrientViewer.load(defaultConfiguration).then((instance) => {
@@ -61,9 +61,7 @@ function load(
6161
});
6262
}
6363

64-
function getOverlayItemForPage1(
65-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
66-
) {
64+
function getOverlayItemForPage1(nutrientViewer: typeof NutrientViewer) {
6765
// We create a div element with an emoji and a short text.
6866
const overlayElement = document.createElement("div");
6967

@@ -81,9 +79,7 @@ function getOverlayItemForPage1(
8179
});
8280
}
8381

84-
function getOverlayItemForPage2(
85-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
86-
) {
82+
function getOverlayItemForPage2(nutrientViewer: typeof NutrientViewer) {
8783
const overlayElement = document.createElement("div");
8884

8985
// In this case we embed a video to the page

frameworks/nuxt/TS/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"devDependencies": {
2525
"@nuxt/devtools": "^2.6.5",
2626
"nuxt": "^3.17.4",
27+
"typescript": "^5.6.0",
2728
"vue-tsc": "^2.0.0"
2829
}
2930
}

frameworks/nuxt/TS/pages/custom-overlays.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ onMounted(async () => {
3535
3636
onUnmounted(() => {
3737
const container = containerRef.value;
38-
const { NutrientViewer } = window;
3938
40-
if (container && NutrientViewer) {
41-
unloadCustomOverlaysViewer(NutrientViewer, container);
39+
if (nutrientViewer && container) {
40+
unloadCustomOverlaysViewer(nutrientViewer, container);
4241
}
4342
});
4443
</script>

frameworks/nuxt/TS/pages/magazine-mode.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ onMounted(async () => {
3535
3636
onUnmounted(() => {
3737
const container = containerRef.value;
38-
const { NutrientViewer } = window;
3938
40-
if (container && NutrientViewer) {
41-
unloadMagazineViewer(NutrientViewer, container);
39+
if (nutrientViewer && container) {
40+
unloadMagazineViewer(nutrientViewer, container);
4241
}
4342
});
4443
</script>

frameworks/react/TS/src/nutrient/custom-overlays/implementation.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function loadCustomOverlaysViewer(
3939
* @param defaultConfiguration - Base configuration object
4040
*/
4141
async function load(
42-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
42+
nutrientViewer: typeof NutrientViewer,
4343
defaultConfiguration: Configuration,
4444
) {
4545
return nutrientViewer.load(defaultConfiguration).then((instance) => {
@@ -61,9 +61,7 @@ async function load(
6161
});
6262
}
6363

64-
function getOverlayItemForPage1(
65-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
66-
) {
64+
function getOverlayItemForPage1(nutrientViewer: typeof NutrientViewer) {
6765
// We create a div element with an emoji and a short text.
6866
const overlayElement = document.createElement("div");
6967

@@ -81,9 +79,7 @@ function getOverlayItemForPage1(
8179
});
8280
}
8381

84-
function getOverlayItemForPage2(
85-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
86-
) {
82+
function getOverlayItemForPage2(nutrientViewer: typeof NutrientViewer) {
8783
const overlayElement = document.createElement("div");
8884

8985
// In this case we embed a video to the page

frameworks/svelte/TS/src/nutrient/custom-overlays/implementation.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function loadCustomOverlaysViewer(
3939
* @param defaultConfiguration - Base configuration object
4040
*/
4141
function load(
42-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
42+
nutrientViewer: typeof NutrientViewer,
4343
defaultConfiguration: Configuration,
4444
) {
4545
return nutrientViewer.load(defaultConfiguration).then((instance) => {
@@ -61,9 +61,7 @@ function load(
6161
});
6262
}
6363

64-
function getOverlayItemForPage1(
65-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
66-
) {
64+
function getOverlayItemForPage1(nutrientViewer: typeof NutrientViewer) {
6765
// We create a div element with an emoji and a short text.
6866
const overlayElement = document.createElement("div");
6967

@@ -81,9 +79,7 @@ function getOverlayItemForPage1(
8179
});
8280
}
8381

84-
function getOverlayItemForPage2(
85-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
86-
) {
82+
function getOverlayItemForPage2(nutrientViewer: typeof NutrientViewer) {
8783
const overlayElement = document.createElement("div");
8884

8985
// In this case we embed a video to the page

frameworks/sveltekit/ts/src/lib/nutrient/custom-overlays/implementation.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function loadCustomOverlaysViewer(
3939
* @param defaultConfiguration - Base configuration object
4040
*/
4141
function load(
42-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
42+
nutrientViewer: typeof NutrientViewer,
4343
defaultConfiguration: Configuration,
4444
) {
4545
return nutrientViewer.load(defaultConfiguration).then((instance) => {
@@ -61,9 +61,7 @@ function load(
6161
});
6262
}
6363

64-
function getOverlayItemForPage1(
65-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
66-
) {
64+
function getOverlayItemForPage1(nutrientViewer: typeof NutrientViewer) {
6765
// We create a div element with an emoji and a short text.
6866
const overlayElement = document.createElement("div");
6967

@@ -81,9 +79,7 @@ function getOverlayItemForPage1(
8179
});
8280
}
8381

84-
function getOverlayItemForPage2(
85-
nutrientViewer: NonNullable<typeof window.NutrientViewer>,
86-
) {
82+
function getOverlayItemForPage2(nutrientViewer: typeof NutrientViewer) {
8783
const overlayElement = document.createElement("div");
8884

8985
// In this case we embed a video to the page

0 commit comments

Comments
 (0)