Skip to content

Commit aa24e14

Browse files
committed
Change from Shiny to window.Shiny
1 parent a886073 commit aa24e14

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

js/chat/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class ChatInput extends LightElement {
224224
if (this.valueIsEmpty) return;
225225
if (this.disabled) return;
226226

227-
Shiny.setInputValue!(this.id, this.value, { priority: "event" });
227+
window.Shiny.setInputValue!(this.id, this.value, { priority: "event" });
228228

229229
// Emit event so parent element knows to insert the message
230230
const sentEvent = new CustomEvent("shiny-chat-input-sent", {

js/data-frame/index.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = ({
527527
useEffect(() => {
528528
if (!htmlDeps) return;
529529
// Register the Shiny HtmlDependencies
530-
Shiny.renderDependenciesAsync([...htmlDeps]);
530+
window.Shiny.renderDependenciesAsync([...htmlDeps]);
531531
}, [htmlDeps]);
532532

533533
useEffect(() => {
@@ -701,7 +701,7 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = ({
701701
} else {
702702
console.error("Unhandled row selection mode:", selectionModes);
703703
}
704-
Shiny.setInputValue!(`${id}_cell_selection`, shinyValue);
704+
window.Shiny.setInputValue!(`${id}_cell_selection`, shinyValue);
705705
}, [id, selection, selectionModes, table, table.getSortedRowModel]);
706706

707707
useEffect(() => {
@@ -714,10 +714,10 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = ({
714714
desc: sortObj.desc,
715715
});
716716
});
717-
Shiny.setInputValue!(`${id}_sort`, shinySort);
717+
window.Shiny.setInputValue!(`${id}_sort`, shinySort);
718718

719719
// Deprecated as of 2024-05-21
720-
Shiny.setInputValue!(`${id}_column_sort`, shinySort);
720+
window.Shiny.setInputValue!(`${id}_column_sort`, shinySort);
721721
}, [columns, id, sorting]);
722722
useEffect(() => {
723723
if (!id) return;
@@ -732,10 +732,10 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = ({
732732
value: filterObj.value as FilterValue,
733733
});
734734
});
735-
Shiny.setInputValue!(`${id}_filter`, shinyFilter);
735+
window.Shiny.setInputValue!(`${id}_filter`, shinyFilter);
736736

737737
// Deprecated as of 2024-05-21
738-
Shiny.setInputValue!(`${id}_column_filter`, shinyFilter);
738+
window.Shiny.setInputValue!(`${id}_column_filter`, shinyFilter);
739739
}, [id, columnFilters, columns]);
740740
useEffect(() => {
741741
if (!id) return;
@@ -744,10 +744,10 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = ({
744744
// Already prefiltered rows!
745745
.getSortedRowModel()
746746
.rows.map((row) => row.index);
747-
Shiny.setInputValue!(`${id}_data_view_rows`, shinyRows);
747+
window.Shiny.setInputValue!(`${id}_data_view_rows`, shinyRows);
748748

749749
// Legacy value as of 2024-05-13
750-
Shiny.setInputValue!(`${id}_data_view_indices`, shinyRows);
750+
window.Shiny.setInputValue!(`${id}_data_view_indices`, shinyRows);
751751
}, [
752752
id,
753753
table,
@@ -773,7 +773,7 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = ({
773773
.filter((x): x is number => x !== null)
774774
.sort();
775775
}
776-
Shiny.setInputValue!(`${id}_selected_rows`, shinyValue);
776+
window.Shiny.setInputValue!(`${id}_selected_rows`, shinyValue);
777777
}, [id, selection, selectionModes, table]);
778778

779779
// ### End row selection ############################################################
@@ -1083,7 +1083,7 @@ function useVirtualizerMeasureWorkaround(
10831083
return measureElementWithRetry;
10841084
}
10851085

1086-
class ShinyDataFrameOutputBinding extends Shiny.OutputBinding {
1086+
class ShinyDataFrameOutputBinding extends window.Shiny.OutputBinding {
10871087
find(scope: HTMLElement | JQuery<HTMLElement>): JQuery<HTMLElement> {
10881088
return $(scope).find("shiny-data-frame");
10891089
}
@@ -1103,7 +1103,7 @@ class ShinyDataFrameOutputBinding extends Shiny.OutputBinding {
11031103
el.clearError();
11041104
}
11051105
}
1106-
Shiny.outputBindings.register(
1106+
window.Shiny.outputBindings.register(
11071107
new ShinyDataFrameOutputBinding(),
11081108
"shinyDataFrame"
11091109
);
@@ -1215,11 +1215,14 @@ customElements.define("shiny-data-frame", ShinyDataFrameOutput);
12151215
// It would be better to have something similar to session.send_input_message
12161216
// for updating outputs, but that requires changes to ShinyJS.
12171217
$(function () {
1218-
Shiny.addCustomMessageHandler("shinyDataFrameMessage", function (message) {
1219-
const evt = new CustomEvent(message.handler, {
1220-
detail: message.obj,
1221-
});
1222-
const el = document.getElementById(message.id);
1223-
el?.dispatchEvent(evt);
1224-
});
1218+
window.Shiny.addCustomMessageHandler(
1219+
"shinyDataFrameMessage",
1220+
function (message) {
1221+
const evt = new CustomEvent(message.handler, {
1222+
detail: message.obj,
1223+
});
1224+
const el = document.getElementById(message.id);
1225+
el?.dispatchEvent(evt);
1226+
}
1227+
);
12251228
});

js/markdown-stream/markdown-stream.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ function handleMessage(message: ContentMessage | IsStreamingMessage): void {
273273
}
274274

275275
$(function () {
276-
Shiny.addCustomMessageHandler("shinyMarkdownStreamMessage", handleMessage);
276+
window.Shiny.addCustomMessageHandler(
277+
"shinyMarkdownStreamMessage",
278+
handleMessage
279+
);
277280
});
278281

279282
export { MarkdownElement, contentToHTML };

js/page-output/page-output.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import type { ErrorsMessageValue } from "rstudio-shiny/srcts/types/src/shiny/shinyapp";
22

3-
class PageOutputBinding extends Shiny.OutputBinding {
3+
class PageOutputBinding extends window.Shiny.OutputBinding {
44
originalBodyTagAttrs: Array<Attr> | null = null;
55

66
find(scope: HTMLElement | JQuery<HTMLElement>): JQuery<HTMLElement> {
77
return $(scope).find(".shiny-page-output");
88
}
99

1010
onValueError(el: HTMLElement, err: ErrorsMessageValue): void {
11-
if (Shiny.unbindAll) Shiny.unbindAll(el);
11+
if (window.Shiny.unbindAll) window.Shiny.unbindAll(el);
1212
this.renderError(el, err);
1313
}
1414

1515
async renderValue(
1616
el: HTMLElement,
17-
data: Parameters<typeof Shiny.renderContentAsync>[1]
17+
data: Parameters<typeof window.Shiny.renderContentAsync>[1]
1818
): Promise<void> {
1919
if (data === null) return;
2020
if (el !== document.body) {
@@ -67,11 +67,11 @@ class PageOutputBinding extends Shiny.OutputBinding {
6767
data.html = content;
6868
}
6969

70-
await Shiny.renderContentAsync(el, data);
70+
await window.Shiny.renderContentAsync(el, data);
7171
}
7272
}
7373

74-
Shiny.outputBindings.register(
74+
window.Shiny.outputBindings.register(
7575
new PageOutputBinding(),
7676
"shinyPageOutputBinding"
7777
);

0 commit comments

Comments
 (0)