মূল কনটেন্টে যান
১৪ দিনের ফ্রি ট্রায়াল, কার্ড লাগবে না৯টি ভাষা১৭৬টি ব্যবসার ধরন · ৫০টি অ্যাপ
BN· USD
লাইভ ডেমো চালিয়ে দেখুনফ্রি ট্রায়াল শুরু করুন

এই পেজটি এখনো বাংলা ভাষায় পাওয়া যায় না, তাই ইংরেজিতে দেখানো হচ্ছে।

Widget scripts in a sealed frame

A widget with a script renders inside a sandboxed iframe with its own policy: it reads the owner's values from window.WIDGET and has no network, cookies or access to the page.

  • about 6 min

When script is set, the widget is painted inside <iframe sandbox="allow-scripts" srcdoc="…">. The frame is an opaque origin: no cookies, no storage, no access to the page around it, no forms, pop-ups or top navigation — and no network at all.

The frame's own Content-Security-Policy (src/lib/marketplace/widget-core.ts)
default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'; script-src 'unsafe-inline'; connect-src 'none'; form-action 'none'; base-uri 'none'
examples/marketplace/widget-countdown/widget.json → script (formatted)
(function () {
  var el = document.querySelector('.cd-time');            // the rendered template
  var end = new Date(window.WIDGET.until + 'T23:59:59');  // the owner's field values
  function tick() {
    var s = Math.max(0, Math.floor((end.getTime() - Date.now()) / 1000));
    var d = Math.floor(s / 86400), h = Math.floor(s % 86400 / 3600), m = Math.floor(s % 3600 / 60);
    el.textContent = d + 'd ' + h + 'h ' + m + 'm';
  }
  tick(); setInterval(tick, 30000);
})();
  • height (60–1200 px, default 320) sets the frame height.
  • fetch, XMLHttpRequest, WebSocket, EventSource, sendBeacon and importScripts are refused at submission; the script may be at most 40,000 characters.
  • Without a script the widget is plain HTML on the page; with one the buyer is told it runs in a sealed frame.

Lifecycle

Install copies the signed definition into the workspace (Setting marketplace:widgets). An update replaces the definition and keeps the values the owner typed — so keep field keys stable between versions. Uninstall removes it; blocks that use it then render nothing.

Written from: docs/DEVELOPERS/WIDGET-SPEC.md, examples/marketplace/widget-countdown/widget.json, src/lib/marketplace/widget-core.ts, src/components/blocks/market-widget.tsx, src/lib/marketplace/install.ts