PageSourceSearch

https://p5js.org/_astro/frame.DmSiFM-Q.js

js p5js.org collected 2026-09-24 08:25:25 UTC 2,998 bytes, 41 lines download raw bytes

1import{A as d,d as f,_ as g,y as w}from"./hooks.module.BJiD9_M9.js";import{p as n,a as y}from"./p5-version.CUG-1lAk.js";import{u as l}from"./jsxRuntime.module.CWllZeke.js";const p={},o=p?.PUBLIC_P5_LIBRARY_PATH||`https://cdn.jsdelivr.net/npm/p5@${n}/lib/p5.min.js`,E=p?.PUBLIC_P5_LIBRARY_PATH||n.startsWith("2")?`https://cdn.jsdelivr.net/npm/p5.sound@${y}/dist/p5.sound.min.js`:`https://cdn.jsdelivr.net/npm/p5@${n}/lib/addons/p5.sound.min.js`;n.split(".")[0];`${n.split(".")[0]}`;const $=p?.PUBLIC_P5_WEBGPU_LIBRARY_PATH||`https://cdn.jsdelivr.net/npm/p5@${n}/lib/p5.webgpu.min.js`,v=t=>t!==""&&!t?.includes("setup")?`
2      function setup() {
3        createCanvas(100, 100);
4        background(200);
5        ${t}
6      }`:t,b=t=>`<!DOCTYPE html>
7<meta charset="utf8" />
8<base href="${t.base||"/assets/"}" />
9<style type='text/css'>
10html, body {
11  margin: 0;
12  padding: 0;
13}
14canvas {
15  display: block;
16}
17${t.css||""}
18</style>
19<!-- If we need an addon script, load p5 the usual way with no caching to make sure
20the import order doesn't get messed up. -->
21${(t.instanceMode||(t.scripts?.length??0)>0?[o,...t.scripts??[]]:[]).map(e=>`<script type="text/javascript" src="${e}"><\/script>`).join(`
22`)}
23<body>${t.htmlBody||""}</body>
24<script id="code" type="text/javascript">${v(t.js)||""}<\/script>
25${(t.scripts?.length??0)>0?"":`
26<script type="text/javascript">
27  // Listen for p5.min.js text content and include in iframe's head as script
28  window.addEventListener("message", event => {
29    // Include check to prevent p5.min.js from being loaded twice
30    const scriptExists = !!document.getElementById("p5ScriptTagInIframe");
31    if (!scriptExists && event.data?.sender === '${o}') {
32      const p5ScriptElement = document.createElement('script');
33      p5ScriptElement.id = "p5ScriptTagInIframe";
34      p5ScriptElement.type = 'text/javascript';
35      p5ScriptElement.textContent = event.data.message;
36      document.head.appendChild(p5ScriptElement);
37    }
38  })
39<\/script>
40`}
41`.replace(/\u00A0/g," "),x=t=>{const e=d(null),a=d(null),r=document.getElementById("p5ScriptTag"),[c,m]=f(!1);return g(()=>{if(!a.current)return;const{IntersectionObserver:s}=window;if(!s)return;const i=new s(u=>{u.forEach(h=>{e.current&&m(h.isIntersecting)})},{rootMargin:"20px"});return i.observe(a.current),()=>i.disconnect()},[]),w(()=>{(async()=>{if(!(!r||!e.current)&&c)try{const s=await fetch(r.src).then(i=>i.text());e.current.contentWindow?.postMessage({sender:o,message:s},"*")}catch{console.error(`Error loading ${r.src}`);return}})()},[t.jsCode,c,r]),l("div",{ref:a,style:{width:t.width,height:t.height},children:l("iframe",{ref:e,srcDoc:c?b({js:t.jsCode,css:t.cssCode,htmlBody:t.htmlBodyCode,base:t.base,scripts:t.scripts,instanceMode:t.jsCode.includes("new p5")}):"",sandbox:"allow-scripts allow-popups allow-modals allow-forms allow-same-origin","aria-label":"Code Preview",title:"Code Preview",loading:t.lazyLoad?"lazy":"eager",style:{width:"100%",height:"100%"}})})};export{x as C,$ as a,o as b,E as c};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.