@pinepaper.studio/mcp-server 1.6.28 → 1.6.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/SECURITY.md +2 -3
- package/dist/agent/export-manager.js +125 -125
- package/dist/assets/repositories/fontawesome.d.ts.map +1 -1
- package/dist/assets/repositories/fontawesome.js +2 -1
- package/dist/assets/repositories/fontawesome.js.map +1 -1
- package/dist/assets/repositories/iconify.d.ts.map +1 -1
- package/dist/assets/repositories/iconify.js +4 -3
- package/dist/assets/repositories/iconify.js.map +1 -1
- package/dist/browser/puppeteer-controller.d.ts +40 -0
- package/dist/browser/puppeteer-controller.d.ts.map +1 -1
- package/dist/browser/puppeteer-controller.js +176 -24
- package/dist/browser/puppeteer-controller.js.map +1 -1
- package/dist/build-info.json +2 -2
- package/dist/cli.js +54 -54
- package/dist/execution/canvas-state.js +25 -25
- package/dist/i18n/locales/en.js +22 -22
- package/dist/i18n/locales/fil.js +44 -44
- package/dist/i18n/locales/is.js +22 -22
- package/dist/i18n/locales/ur.js +22 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5574 -5568
- package/dist/index.js.map +1 -1
- package/dist/ontology/upstream-vocabulary.d.ts +2 -2
- package/dist/ontology/upstream-vocabulary.js +6 -6
- package/dist/ontology/vocabulary.d.ts.map +1 -1
- package/dist/ontology/vocabulary.js +2 -0
- package/dist/ontology/vocabulary.js.map +1 -1
- package/dist/tools/craft-tools.js +18 -18
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/definitions.js +2832 -2823
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/effect-check.d.ts +1 -1
- package/dist/tools/effect-check.d.ts.map +1 -1
- package/dist/tools/effect-check.js +68 -68
- package/dist/tools/effect-check.js.map +1 -1
- package/dist/tools/engine-lists.d.ts +3 -3
- package/dist/tools/engine-lists.js +3 -3
- package/dist/tools/engine-methods.d.ts.map +1 -1
- package/dist/tools/engine-methods.js +4 -1
- package/dist/tools/engine-methods.js.map +1 -1
- package/dist/tools/engine-surface.d.ts +1 -1
- package/dist/tools/engine-surface.d.ts.map +1 -1
- package/dist/tools/engine-surface.js +19 -4
- package/dist/tools/engine-surface.js.map +1 -1
- package/dist/tools/handlers/font.js +22 -22
- package/dist/tools/handlers/generate.d.ts +2 -2
- package/dist/tools/handlers/generate.d.ts.map +1 -1
- package/dist/tools/handlers/generate.js +5 -4
- package/dist/tools/handlers/generate.js.map +1 -1
- package/dist/tools/handlers.d.ts.map +1 -1
- package/dist/tools/handlers.js +57 -18
- package/dist/tools/handlers.js.map +1 -1
- package/dist/tools/lane.d.ts +8 -2
- package/dist/tools/lane.d.ts.map +1 -1
- package/dist/tools/lane.js +86 -67
- package/dist/tools/lane.js.map +1 -1
- package/dist/tools/p5-compat/p5-helpers.d.ts +6 -17
- package/dist/tools/p5-compat/p5-helpers.d.ts.map +1 -1
- package/dist/tools/p5-compat/p5-helpers.js +349 -342
- package/dist/tools/p5-compat/p5-helpers.js.map +1 -1
- package/dist/tools/shape-params.d.ts +2 -2
- package/dist/tools/shape-params.d.ts.map +1 -1
- package/dist/tools/shape-params.js +5 -2
- package/dist/tools/shape-params.js.map +1 -1
- package/dist/tools/stick-vocabulary.d.ts +1 -1
- package/dist/tools/stick-vocabulary.js +1 -1
- package/dist/tools/timeline.js +82 -82
- package/dist/types/code-generator.d.ts.map +1 -1
- package/dist/types/code-generator.js +6646 -5853
- package/dist/types/code-generator.js.map +1 -1
- package/dist/types/schemas.d.ts +13 -0
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/schemas.js +6 -0
- package/dist/types/schemas.js.map +1 -1
- package/dist/utils/safe-fetch.d.ts +8 -0
- package/dist/utils/safe-fetch.d.ts.map +1 -1
- package/dist/utils/safe-fetch.js +125 -34
- package/dist/utils/safe-fetch.js.map +1 -1
- package/dist/vendor/design/device-mockup-generator.js +167 -150
- package/dist/vendor/design/recursive-subdivision-generator.js +107 -107
- package/dist/vendor/design/textile-weave-generator.js +429 -429
- package/dist/vendor/design/ui-kit-runtime.js +674 -674
- package/manifest.json +1 -1
- package/package.json +7 -4
|
@@ -13,366 +13,373 @@
|
|
|
13
13
|
* - Mode: rectMode, ellipseMode
|
|
14
14
|
* - Constants: PI, TWO_PI, HALF_PI, QUARTER_PI, CENTER, CORNER
|
|
15
15
|
*/
|
|
16
|
+
import { capabilityAllowed, capabilityRefusal } from '../../utils/capabilities.js';
|
|
16
17
|
/**
|
|
17
18
|
* Browser-side p5.js compatibility helpers.
|
|
18
19
|
* This code is injected into the PinePaper page context and run there as a script.
|
|
19
20
|
*/
|
|
20
|
-
export const P5_HELPERS =
|
|
21
|
-
(function() {
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
}
|
|
21
|
+
export const P5_HELPERS = ("\n(function() {\n // Prevent double-initialization\n if (window._p5Initialized) {\n console.log('[p5-compat] Already initialized');\n return;\n }\n\n // ==========================================================================\n // STATE MANAGEMENT\n // ==========================================================================\n\n window._p5State = {\n fillColor: '#ffffff',\n strokeColor: '#000000',\n strokeWidth: 1,\n rectMode: 'corner',\n ellipseMode: 'center'\n };\n\n // ==========================================================================\n // CONSTANTS\n // ==========================================================================\n\n window.PI =" +
|
|
22
|
+
" Math.PI;\n window.TWO_PI = Math.PI * 2;\n window.HALF_PI = Math.PI / 2;\n window.QUARTER_PI = Math.PI / 4;\n\n window.CENTER = 'center';\n window.CORNER = 'corner';\n\n // ==========================================================================\n // CANVAS PROPERTIES\n // ==========================================================================\n\n Object.defineProperty(window, 'width', {\n get: function() {\n return paper.view ? paper.view.size.width : 800;\n },\n configurable: true\n });\n\n Object.defineProperty(window, 'height', {\n get: function() {\n return paper.view ? paper.view.size.height : 600;\n },\n configurable: true\n });\n\n // =" +
|
|
23
|
+
"=========================================================================\n // MATH UTILITIES\n // ==========================================================================\n\n window.random = function(min, max) {\n if (arguments.length === 0) {\n return Math.random();\n } else if (arguments.length === 1) {\n if (Array.isArray(min)) {\n // random(array) - return random element\n return min[Math.floor(Math.random() * min.length)];\n }\n // random(max) - return 0 to max\n return Math.random() * min;\n } else {\n // random(min, max)\n return Math.random() * (max - min) + min;\n }\n };\n\n window.map = function(value, start1, s" +
|
|
24
|
+
"top1, start2, stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n };\n\n window.constrain = function(value, min, max) {\n return Math.min(Math.max(value, min), max);\n };\n\n window.dist = function(x1, y1, x2, y2) {\n return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n };\n\n window.lerp = function(start, stop, amount) {\n return start + (stop - start) * amount;\n };\n\n window.radians = function(degrees) {\n return degrees * Math.PI / 180;\n };\n\n window.degrees = function(radians) {\n return radians * 180 / Math.PI;\n };\n\n // ==========================================================================\n // " +
|
|
25
|
+
"STYLE FUNCTIONS\n // ==========================================================================\n\n /**\n * Parse color arguments into a valid color string.\n * Supports: fill(gray), fill(r,g,b), fill(r,g,b,a), fill('#hex')\n */\n function parseColor(args) {\n if (args.length === 0) return null;\n\n if (args.length === 1) {\n var val = args[0];\n if (typeof val === 'string') {\n return val;\n } else if (typeof val === 'number') {\n // Grayscale\n return 'rgb(' + val + ', ' + val + ', ' + val + ')';\n }\n } else if (args.length === 3) {\n // RGB\n return 'rgb(' + args[0] + ', ' + args[1] + ', ' + args[2] + ')';\n } else" +
|
|
26
|
+
" if (args.length === 4) {\n // RGBA (p5 uses 0-255 for alpha, CSS uses 0-1)\n return 'rgba(' + args[0] + ', ' + args[1] + ', ' + args[2] + ', ' + (args[3] / 255) + ')';\n }\n\n return null;\n }\n\n window.fill = function() {\n var color = parseColor(Array.prototype.slice.call(arguments));\n window._p5State.fillColor = color;\n };\n\n window.noFill = function() {\n window._p5State.fillColor = null;\n };\n\n window.stroke = function() {\n var color = parseColor(Array.prototype.slice.call(arguments));\n window._p5State.strokeColor = color;\n };\n\n window.noStroke = function() {\n window._p5State.strokeColor = null;\n };\n\n window.strokeWeight = fu" +
|
|
27
|
+
"nction(weight) {\n window._p5State.strokeWidth = weight;\n };\n\n window.background = function() {\n var color = parseColor(Array.prototype.slice.call(arguments));\n if (color && typeof app !== 'undefined' && app.setBackgroundColor) {\n app.setBackgroundColor(color);\n }\n };\n\n // ==========================================================================\n // MODE FUNCTIONS\n // ==========================================================================\n\n window.rectMode = function(mode) {\n window._p5State.rectMode = mode.toLowerCase();\n };\n\n window.ellipseMode = function(mode) {\n window._p5State.ellipseMode = mode.toLowerCase();\n };\n\n // ======" +
|
|
28
|
+
"====================================================================\n // SHAPE FUNCTIONS\n // ==========================================================================\n\n /**\n * Apply current style state to an item\n */\n function applyStyle(item) {\n if (window._p5State.fillColor) {\n item.fillColor = window._p5State.fillColor;\n }\n if (window._p5State.strokeColor) {\n item.strokeColor = window._p5State.strokeColor;\n item.strokeWidth = window._p5State.strokeWidth;\n }\n }\n\n /**\n * Register item with PinePaper's ItemRegistry\n */\n function registerItem(item, type) {\n if (typeof app !== 'undefined' && app.registerItem) {\n app.reg" +
|
|
29
|
+
"isterItem(item, type, { source: 'p5' });\n }\n return item;\n }\n\n /**\n * Draw a circle\n * circle(x, y, diameter)\n */\n window.circle = function(x, y, d) {\n var item = new paper.Path.Circle({\n center: [x, y],\n radius: d / 2\n });\n applyStyle(item);\n return registerItem(item, 'circle');\n };\n\n /**\n * Draw an ellipse\n * ellipse(x, y, width, [height])\n */\n window.ellipse = function(x, y, w, h) {\n h = h !== undefined ? h : w;\n var mode = window._p5State.ellipseMode;\n var center = mode === 'center' ? [x, y] : [x + w / 2, y + h / 2];\n\n var item = new paper.Path.Ellipse({\n center: center,\n size: [w, h]\n " +
|
|
30
|
+
"});\n applyStyle(item);\n return registerItem(item, 'ellipse');\n };\n\n /**\n * Draw a rectangle\n * rect(x, y, width, height, [cornerRadius])\n */\n window.rect = function(x, y, w, h, r) {\n var mode = window._p5State.rectMode;\n var point = mode === 'center' ? [x - w / 2, y - h / 2] : [x, y];\n\n var options = {\n point: point,\n size: [w, h]\n };\n\n if (r !== undefined && r > 0) {\n options.radius = r;\n }\n\n var item = new paper.Path.Rectangle(options);\n applyStyle(item);\n return registerItem(item, 'rectangle');\n };\n\n /**\n * Draw a line\n * line(x1, y1, x2, y2)\n */\n window.line = function(x1, y1, x2, y2) {\n " +
|
|
31
|
+
" var item = new paper.Path.Line({\n from: [x1, y1],\n to: [x2, y2]\n });\n // Lines typically don't have fill\n if (window._p5State.strokeColor) {\n item.strokeColor = window._p5State.strokeColor;\n item.strokeWidth = window._p5State.strokeWidth;\n }\n return registerItem(item, 'line');\n };\n\n /**\n * Draw a triangle\n * triangle(x1, y1, x2, y2, x3, y3)\n */\n window.triangle = function(x1, y1, x2, y2, x3, y3) {\n var item = new paper.Path({\n segments: [[x1, y1], [x2, y2], [x3, y3]],\n closed: true\n });\n applyStyle(item);\n return registerItem(item, 'triangle');\n };\n\n /**\n * Draw a quadrilateral\n * quad(x1, " +
|
|
32
|
+
"y1, x2, y2, x3, y3, x4, y4)\n */\n window.quad = function(x1, y1, x2, y2, x3, y3, x4, y4) {\n var item = new paper.Path({\n segments: [[x1, y1], [x2, y2], [x3, y3], [x4, y4]],\n closed: true\n });\n applyStyle(item);\n return registerItem(item, 'quad');\n };\n\n /**\n * Draw an arc\n * arc(x, y, width, height, startAngle, stopAngle)\n * Note: p5.js uses radians by default\n */\n window.arc = function(x, y, w, h, start, stop) {\n // Calculate the arc using Paper.js\n var cx = x;\n var cy = y;\n var rx = w / 2;\n var ry = h / 2;\n\n // Convert from p5's angle system to Paper.js\n // p5 uses radians where 0 is right, PI/2 is down\n v" +
|
|
33
|
+
"ar startDeg = start * 180 / Math.PI;\n var stopDeg = stop * 180 / Math.PI;\n\n // Create arc using path segments\n var item = new paper.Path.Arc({\n from: [\n cx + rx * Math.cos(start),\n cy + ry * Math.sin(start)\n ],\n through: [\n cx + rx * Math.cos((start + stop) / 2),\n cy + ry * Math.sin((start + stop) / 2)\n ],\n to: [\n cx + rx * Math.cos(stop),\n cy + ry * Math.sin(stop)\n ]\n });\n\n applyStyle(item);\n return registerItem(item, 'arc');\n };\n\n /**\n * Draw a point (tiny circle)\n * point(x, y)\n */\n window.point = function(x, y) {\n var size = window._p5State.strokeWidth || 1;" +
|
|
34
|
+
"\n var item = new paper.Path.Circle({\n center: [x, y],\n radius: size / 2\n });\n // Points use stroke color as fill\n if (window._p5State.strokeColor) {\n item.fillColor = window._p5State.strokeColor;\n }\n return registerItem(item, 'point');\n };\n\n // ==========================================================================\n // INITIALIZATION COMPLETE\n // ==========================================================================\n\n window._p5Initialized = true;\n console.log('[p5-compat] p5.js compatibility layer loaded (v1.3.1)');\n console.log('[p5-compat] Available: circle, ellipse, rect, line, triangle, quad, arc, point');\n console.log" +
|
|
35
|
+
"('[p5-compat] Style: fill, noFill, stroke, noStroke, strokeWeight, background');\n console.log('[p5-compat] Math: random, map, constrain, dist, lerp, radians, degrees');\n})();\n"
|
|
27
36
|
|
|
28
|
-
// ==========================================================================
|
|
29
|
-
// STATE MANAGEMENT
|
|
30
|
-
// ==========================================================================
|
|
31
|
-
|
|
32
|
-
window._p5State = {
|
|
33
|
-
fillColor: '#ffffff',
|
|
34
|
-
strokeColor: '#000000',
|
|
35
|
-
strokeWidth: 1,
|
|
36
|
-
rectMode: 'corner',
|
|
37
|
-
ellipseMode: 'center'
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// ==========================================================================
|
|
41
|
-
// CONSTANTS
|
|
42
|
-
// ==========================================================================
|
|
43
|
-
|
|
44
|
-
window.PI = Math.PI;
|
|
45
|
-
window.TWO_PI = Math.PI * 2;
|
|
46
|
-
window.HALF_PI = Math.PI / 2;
|
|
47
|
-
window.QUARTER_PI = Math.PI / 4;
|
|
48
|
-
|
|
49
|
-
window.CENTER = 'center';
|
|
50
|
-
window.CORNER = 'corner';
|
|
51
|
-
|
|
52
|
-
// ==========================================================================
|
|
53
|
-
// CANVAS PROPERTIES
|
|
54
|
-
// ==========================================================================
|
|
55
|
-
|
|
56
|
-
Object.defineProperty(window, 'width', {
|
|
57
|
-
get: function() {
|
|
58
|
-
return paper.view ? paper.view.size.width : 800;
|
|
59
|
-
},
|
|
60
|
-
configurable: true
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
Object.defineProperty(window, 'height', {
|
|
64
|
-
get: function() {
|
|
65
|
-
return paper.view ? paper.view.size.height : 600;
|
|
66
|
-
},
|
|
67
|
-
configurable: true
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// ==========================================================================
|
|
71
|
-
// MATH UTILITIES
|
|
72
|
-
// ==========================================================================
|
|
73
|
-
|
|
74
|
-
window.random = function(min, max) {
|
|
75
|
-
if (arguments.length === 0) {
|
|
76
|
-
return Math.random();
|
|
77
|
-
} else if (arguments.length === 1) {
|
|
78
|
-
if (Array.isArray(min)) {
|
|
79
|
-
// random(array) - return random element
|
|
80
|
-
return min[Math.floor(Math.random() * min.length)];
|
|
81
|
-
}
|
|
82
|
-
// random(max) - return 0 to max
|
|
83
|
-
return Math.random() * min;
|
|
84
|
-
} else {
|
|
85
|
-
// random(min, max)
|
|
86
|
-
return Math.random() * (max - min) + min;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
window.map = function(value, start1, stop1, start2, stop2) {
|
|
91
|
-
return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
window.constrain = function(value, min, max) {
|
|
95
|
-
return Math.min(Math.max(value, min), max);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
window.dist = function(x1, y1, x2, y2) {
|
|
99
|
-
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
window.lerp = function(start, stop, amount) {
|
|
103
|
-
return start + (stop - start) * amount;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
window.radians = function(degrees) {
|
|
107
|
-
return degrees * Math.PI / 180;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
window.degrees = function(radians) {
|
|
111
|
-
return radians * 180 / Math.PI;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// ==========================================================================
|
|
115
|
-
// STYLE FUNCTIONS
|
|
116
|
-
// ==========================================================================
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Parse color arguments into a valid color string.
|
|
120
|
-
* Supports: fill(gray), fill(r,g,b), fill(r,g,b,a), fill('#hex')
|
|
121
|
-
*/
|
|
122
|
-
function parseColor(args) {
|
|
123
|
-
if (args.length === 0) return null;
|
|
124
|
-
|
|
125
|
-
if (args.length === 1) {
|
|
126
|
-
var val = args[0];
|
|
127
|
-
if (typeof val === 'string') {
|
|
128
|
-
return val;
|
|
129
|
-
} else if (typeof val === 'number') {
|
|
130
|
-
// Grayscale
|
|
131
|
-
return 'rgb(' + val + ', ' + val + ', ' + val + ')';
|
|
132
|
-
}
|
|
133
|
-
} else if (args.length === 3) {
|
|
134
|
-
// RGB
|
|
135
|
-
return 'rgb(' + args[0] + ', ' + args[1] + ', ' + args[2] + ')';
|
|
136
|
-
} else if (args.length === 4) {
|
|
137
|
-
// RGBA (p5 uses 0-255 for alpha, CSS uses 0-1)
|
|
138
|
-
return 'rgba(' + args[0] + ', ' + args[1] + ', ' + args[2] + ', ' + (args[3] / 255) + ')';
|
|
139
|
-
}
|
|
140
37
|
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
38
|
|
|
144
|
-
window.fill = function() {
|
|
145
|
-
var color = parseColor(Array.prototype.slice.call(arguments));
|
|
146
|
-
window._p5State.fillColor = color;
|
|
147
|
-
};
|
|
148
39
|
|
|
149
|
-
window.noFill = function() {
|
|
150
|
-
window._p5State.fillColor = null;
|
|
151
|
-
};
|
|
152
40
|
|
|
153
|
-
window.stroke = function() {
|
|
154
|
-
var color = parseColor(Array.prototype.slice.call(arguments));
|
|
155
|
-
window._p5State.strokeColor = color;
|
|
156
|
-
};
|
|
157
41
|
|
|
158
|
-
window.noStroke = function() {
|
|
159
|
-
window._p5State.strokeColor = null;
|
|
160
|
-
};
|
|
161
42
|
|
|
162
|
-
window.strokeWeight = function(weight) {
|
|
163
|
-
window._p5State.strokeWidth = weight;
|
|
164
|
-
};
|
|
165
43
|
|
|
166
|
-
window.background = function() {
|
|
167
|
-
var color = parseColor(Array.prototype.slice.call(arguments));
|
|
168
|
-
if (color && typeof app !== 'undefined' && app.setBackgroundColor) {
|
|
169
|
-
app.setBackgroundColor(color);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
// ==========================================================================
|
|
174
|
-
// MODE FUNCTIONS
|
|
175
|
-
// ==========================================================================
|
|
176
|
-
|
|
177
|
-
window.rectMode = function(mode) {
|
|
178
|
-
window._p5State.rectMode = mode.toLowerCase();
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
window.ellipseMode = function(mode) {
|
|
182
|
-
window._p5State.ellipseMode = mode.toLowerCase();
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// ==========================================================================
|
|
186
|
-
// SHAPE FUNCTIONS
|
|
187
|
-
// ==========================================================================
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Apply current style state to an item
|
|
191
|
-
*/
|
|
192
|
-
function applyStyle(item) {
|
|
193
|
-
if (window._p5State.fillColor) {
|
|
194
|
-
item.fillColor = window._p5State.fillColor;
|
|
195
|
-
}
|
|
196
|
-
if (window._p5State.strokeColor) {
|
|
197
|
-
item.strokeColor = window._p5State.strokeColor;
|
|
198
|
-
item.strokeWidth = window._p5State.strokeWidth;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
44
|
|
|
202
|
-
/**
|
|
203
|
-
* Register item with PinePaper's ItemRegistry
|
|
204
|
-
*/
|
|
205
|
-
function registerItem(item, type) {
|
|
206
|
-
if (typeof app !== 'undefined' && app.registerItem) {
|
|
207
|
-
app.registerItem(item, type, { source: 'p5' });
|
|
208
|
-
}
|
|
209
|
-
return item;
|
|
210
|
-
}
|
|
211
45
|
|
|
212
|
-
/**
|
|
213
|
-
* Draw a circle
|
|
214
|
-
* circle(x, y, diameter)
|
|
215
|
-
*/
|
|
216
|
-
window.circle = function(x, y, d) {
|
|
217
|
-
var item = new paper.Path.Circle({
|
|
218
|
-
center: [x, y],
|
|
219
|
-
radius: d / 2
|
|
220
|
-
});
|
|
221
|
-
applyStyle(item);
|
|
222
|
-
return registerItem(item, 'circle');
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Draw an ellipse
|
|
227
|
-
* ellipse(x, y, width, [height])
|
|
228
|
-
*/
|
|
229
|
-
window.ellipse = function(x, y, w, h) {
|
|
230
|
-
h = h !== undefined ? h : w;
|
|
231
|
-
var mode = window._p5State.ellipseMode;
|
|
232
|
-
var center = mode === 'center' ? [x, y] : [x + w / 2, y + h / 2];
|
|
233
|
-
|
|
234
|
-
var item = new paper.Path.Ellipse({
|
|
235
|
-
center: center,
|
|
236
|
-
size: [w, h]
|
|
237
|
-
});
|
|
238
|
-
applyStyle(item);
|
|
239
|
-
return registerItem(item, 'ellipse');
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Draw a rectangle
|
|
244
|
-
* rect(x, y, width, height, [cornerRadius])
|
|
245
|
-
*/
|
|
246
|
-
window.rect = function(x, y, w, h, r) {
|
|
247
|
-
var mode = window._p5State.rectMode;
|
|
248
|
-
var point = mode === 'center' ? [x - w / 2, y - h / 2] : [x, y];
|
|
249
|
-
|
|
250
|
-
var options = {
|
|
251
|
-
point: point,
|
|
252
|
-
size: [w, h]
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
if (r !== undefined && r > 0) {
|
|
256
|
-
options.radius = r;
|
|
257
|
-
}
|
|
258
46
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
);
|
|
372
373
|
/**
|
|
373
|
-
* Generate code that initializes p5 helpers and
|
|
374
|
+
* Generate code that initializes p5 helpers and runs the caller's p5-style code in the studio page.
|
|
375
|
+
*
|
|
376
|
+
* SECURITY BOUNDARY: this runs caller-written JavaScript, so it is off unless the person running the server started it
|
|
377
|
+
* with PINEPAPER_ALLOW_CODE=1 (utils/capabilities.ts). The handler refuses first; this refuses again, so no other path
|
|
378
|
+
* can produce the code with the switch off. The code runs in the browser page, never in the server process.
|
|
374
379
|
*/
|
|
375
380
|
export function generateP5DrawCode(userCode) {
|
|
381
|
+
if (!capabilityAllowed('code'))
|
|
382
|
+
throw new Error(capabilityRefusal('code', 'pinepaper_p5_draw'));
|
|
376
383
|
return `
|
|
377
384
|
// Initialize p5.js compatibility layer if not already loaded
|
|
378
385
|
if (!window._p5Initialized) {
|