Skip to content

Commit ebaf69f

Browse files
committed
feat: inject legacy scripts in document head
1 parent 503a34a commit ebaf69f

File tree

2 files changed

+11
-1
lines changed
  • apps/playground/src/instruments/examples/interactive/Interactive-With-Legacy-Script
  • packages/react-core/src/components/InteractiveContent

2 files changed

+11
-1
lines changed

apps/playground/src/instruments/examples/interactive/Interactive-With-Legacy-Script/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { defineInstrument } from '/runtime/v1/@opendatacapture/runtime-core';
44
import { z } from '/runtime/v1/[email protected]';
55

6-
import './legacy.js';
6+
import './legacy.js?legacy';
77

88
export default defineInstrument({
99
kind: 'INTERACTIVE',

packages/react-core/src/components/InteractiveContent/bootstrap.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ if (!bundle) {
5252
}
5353

5454
const instrument = await evaluateInstrument(bundle);
55+
56+
/** @type {string[] | undefined} */
57+
const scripts = instrument.content.__injectHead?.scripts;
58+
scripts?.forEach((encodedScript) => {
59+
const script = document.createElement('script');
60+
script.type = 'text/javascript';
61+
script.textContent = atob(encodedScript);
62+
document.head.appendChild(script);
63+
});
64+
5565
const encodedStyle = instrument.content.__injectHead?.style;
5666
if (encodedStyle) {
5767
const style = atob(encodedStyle);

0 commit comments

Comments
 (0)