Skip to content

Commit 08d9bd7

Browse files
authored
Merge branch 'develop' into fix/storage-bar-contrast
2 parents e5fbff0 + 5e5b3ce commit 08d9bd7

37 files changed

Lines changed: 22714 additions & 26368 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Stay in touch with Processing Foundation across other platforms:
1515
- [Instagram](https://www.instagram.com/p5xjs)
1616
- [Youtube](https://www.youtube.com/@ProcessingFoundation)
1717
- [X](https://x.com/p5xjs)
18-
- [Discord](https://discord.com/invite/esmGA6H6wm)
18+
- [Discord](https://discord.p5js.org)
1919
- [Forum](https://discourse.processing.org)
2020

2121
## Using the p5.js Editor 🤔

SECURITY.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Security Policy
2+
3+
## Reporting a Vulnerability
4+
5+
Please report security vulnerabilities by emailing: responsible.disclosure@processingfoundation.org
6+
7+
## What to Expect
8+
- We will acknowledge your email within 72 hours
9+
- We will provide regular updates about our progress
10+
- Once the issue is confirmed and fixed, we may ask you to verify the solution
11+
12+
## Disclosure Policy
13+
- Please do not disclose the vulnerability publicly until we have had a chance to address it
14+
- We do not offer bounties as we are a non-profit organization
15+
- We appreciate your efforts to responsibly disclose your findings
16+
17+
## Scope
18+
19+
You can use the above email to report vulnerabilities in p5.js and related repositories managed by the processing org, including the reference website.

client/jest.setup.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ import 'regenerator-runtime/runtime';
55
// See: https://github.com/testing-library/jest-dom
66
// eslint-disable-next-line import/no-extraneous-dependencies
77
import '@testing-library/jest-dom';
8+
9+
global.ResizeObserver = class {
10+
observe() {}
11+
12+
unobserve() {}
13+
14+
disconnect() {}
15+
};

client/modules/About/statics/aboutData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const ContactSectionLinks: ContactSectionLink[] = [
1919
{ label: 'About.X', href: 'https://x.com/p5xjs' },
2020
{
2121
label: 'About.Discord',
22-
href: 'https://discord.gg/esmGA6H6wm'
22+
href: 'https://discord.p5js.org'
2323
},
2424
{
2525
label: 'About.Forum',
@@ -87,7 +87,7 @@ export const AboutSectionInfo: AboutSectionInfoSection[] = [
8787
description: 'About.LinkDescriptions.Forum'
8888
},
8989
{
90-
url: 'https://discord.com/invite/esmGA6H6wm',
90+
url: 'https://discord.p5js.org',
9191
title: 'About.DiscordCTA',
9292
description: 'About.LinkDescriptions.Discord'
9393
}

client/modules/IDE/components/Header/Nav.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,7 @@ const ProjectMenu = () => {
321321
>
322322
{t('Nav.Help.ReportBug')}
323323
</MenubarItem>
324-
<MenubarItem
325-
id="help-discord"
326-
href="https://discord.com/invite/SHQ8dH25r9"
327-
>
324+
<MenubarItem id="help-discord" href="https://discord.p5js.org">
328325
{t('Nav.Help.ChatOnDiscord')}
329326
</MenubarItem>
330327
<MenubarItem

client/modules/IDE/components/PreviewFrame.jsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import React, { useRef, useEffect } from 'react';
1+
import React, { useRef, useEffect, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import styled from 'styled-components';
44
import { getConfig } from '../../../utils/getConfig';
55
import { registerFrame } from '../../../utils/dispatcher';
66

77
const Frame = styled.iframe`
8-
min-height: 100%;
9-
min-width: 100%;
8+
display: block;
109
position: ${(props) => (props.fullView ? 'relative' : 'absolute')};
1110
border-width: 0;
1211
`;
1312

1413
function PreviewFrame({ fullView, isOverlayVisible }) {
1514
const iframe = useRef();
15+
const [frameSize, setFrameSize] = useState(null);
1616
const previewUrl = getConfig('PREVIEW_URL');
1717
useEffect(() => {
1818
const unsubscribe = registerFrame(iframe.current.contentWindow, previewUrl);
@@ -21,6 +21,26 @@ function PreviewFrame({ fullView, isOverlayVisible }) {
2121
};
2222
});
2323

24+
useEffect(() => {
25+
const parent = iframe.current?.parentElement;
26+
if (!parent) {
27+
return () => {};
28+
}
29+
const updateSize = () => {
30+
const { width, height } = parent.getBoundingClientRect();
31+
setFrameSize({
32+
width: Math.floor(width),
33+
height: Math.floor(height)
34+
});
35+
};
36+
updateSize();
37+
const observer = new ResizeObserver(updateSize);
38+
observer.observe(parent);
39+
return () => {
40+
observer.disconnect();
41+
};
42+
}, []);
43+
2444
const frameUrl = previewUrl;
2545
const sandboxAttributes = `allow-forms allow-modals allow-pointer-lock allow-popups
2646
allow-same-origin allow-scripts allow-top-navigation-by-user-activation allow-downloads`;
@@ -45,6 +65,11 @@ function PreviewFrame({ fullView, isOverlayVisible }) {
4565
frameBorder="0"
4666
ref={iframe}
4767
fullView={fullView}
68+
style={
69+
frameSize
70+
? { width: frameSize.width, height: frameSize.height }
71+
: undefined
72+
}
4873
/>
4974
</>
5075
);

client/modules/Preview/EmbedFrame.jsx

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import blobUtil from 'blob-util';
22
import PropTypes from 'prop-types';
33
import React, { useRef, useEffect, useMemo } from 'react';
44
import styled from 'styled-components';
5-
import loopProtect from 'loop-protect';
6-
import decomment from 'decomment';
5+
import { jsPreprocess } from './jsPreprocess';
76
import { resolvePathToFile } from '../../../server/utils/filePath';
87
import { getConfig } from '../../utils/getConfig';
98
import {
@@ -55,47 +54,6 @@ function resolveCSSLinksInString(content, files) {
5554
return newContent;
5655
}
5756

58-
function jsPreprocess(jsText) {
59-
let newContent = jsText;
60-
61-
// Skip loop protection if the user explicitly opts out with // noprotect
62-
if (/\/\/\s*noprotect/.test(newContent)) {
63-
return newContent;
64-
}
65-
66-
// Detect and fix multiple consecutive loops on the same line (e.g. "for(){}for(){}")
67-
// which can bypass loop protection. Add semicolons between them so each loop
68-
// is properly wrapped by loopProtect. See #3891.
69-
// Match: for/while/do-while loops followed immediately by another loop
70-
newContent = newContent.replace(
71-
/((?:for|while)\s*\([^)]*\)\s*\{[^}]*\})((?:for|while)\s*\([^)]*\)\s*\{[^}]*\})/g,
72-
'$1; $2'
73-
);
74-
75-
// Always apply loop protection to prevent infinite loops from crashing
76-
// the browser tab. Previously, loop protection was skipped when JSHINT
77-
// found errors, but this left users vulnerable to infinite loops in
78-
// syntactically imperfect code (common while typing). See #3891.
79-
try {
80-
newContent = decomment(newContent, {
81-
ignore: /\/\/\s*noprotect/g,
82-
space: true
83-
});
84-
newContent = loopProtect(newContent);
85-
} catch (e) {
86-
// If decomment or loopProtect fails (e.g. due to syntax issues),
87-
// still try to apply loop protection on the original code.
88-
try {
89-
newContent = loopProtect(jsText);
90-
} catch (err) {
91-
// If loop protection can't be applied at all, return original code.
92-
// The sketch will still run, but without loop protection.
93-
return jsText;
94-
}
95-
}
96-
return newContent;
97-
}
98-
9957
function resolveJSLinksInString(content, files) {
10058
let newContent = content;
10159
let jsFileStrings = content.match(STRING_REGEX);

0 commit comments

Comments
 (0)