p5.zine 0.0.1 → 0.0.2
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/LICENSE +600 -0
- package/README.md +31 -38
- package/dist/p5.zine.js +570 -0
- package/dist/p5.zine.legacy.js +570 -0
- package/package.json +21 -3
- package/.github/workflows/build.yml +0 -27
- package/build.js +0 -77
- package/scripts/smoke-test.js +0 -53
- package/src/adapters/p5-1.js +0 -65
- package/src/adapters/p5-2.js +0 -46
- package/src/custom.js +0 -430
- package/src/html.js +0 -6
- package/src/index.js +0 -3
- package/src/index.legacy.js +0 -3
- package/src/index.modern.js +0 -3
- package/src/page-size.js +0 -143
- package/src/style.js +0 -28
- package/src/ui.css +0 -245
- package/src/ui.html +0 -33
- package/src/zine.js +0 -1003
- package/test/compat.html +0 -95
- package/test/index.html +0 -19
- package/test/index.legacy.html +0 -19
- package/test/sketch.js +0 -21
package/package.json
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "p5.zine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "p5.zine is an open-sourced and friendly library for anyone curious about creative code and zine-making.",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/p5.zine.js",
|
|
6
|
+
"browser": "dist/p5.zine.js",
|
|
7
|
+
"unpkg": "dist/p5.zine.js",
|
|
8
|
+
"jsdelivr": "dist/p5.zine.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
6
14
|
"scripts": {
|
|
7
15
|
"build": "node build.js",
|
|
8
16
|
"dev": "node build.js --watch --serve --dev",
|
|
9
17
|
"preview": "node build.js --serve --dev",
|
|
10
18
|
"test": "node build.js && node scripts/smoke-test.js",
|
|
11
|
-
"
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"release": "npm publish"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/munusshih/p5.zine.git"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/munusshih/p5.zine",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/munusshih/p5.zine/issues"
|
|
12
29
|
},
|
|
13
30
|
"publishConfig": {
|
|
14
31
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -21,6 +38,7 @@
|
|
|
21
38
|
"zine-coding"
|
|
22
39
|
],
|
|
23
40
|
"author": "Munus Shih, Tuan Huang, Iley Cao",
|
|
41
|
+
"sideEffects": true,
|
|
24
42
|
"license": "GPL-3.0-only",
|
|
25
43
|
"devDependencies": {
|
|
26
44
|
"esbuild": "^0.24.0"
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
name: Build and Deploy
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- main
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
build:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout code
|
|
17
|
-
uses: actions/checkout@v3
|
|
18
|
-
|
|
19
|
-
- name: Set up Node.js
|
|
20
|
-
uses: actions/setup-node@v3
|
|
21
|
-
with:
|
|
22
|
-
node-version: '16'
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies and build
|
|
25
|
-
run: |
|
|
26
|
-
npm install
|
|
27
|
-
npm run build
|
package/build.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
const esbuild = require("esbuild");
|
|
2
|
-
|
|
3
|
-
// Define the banner content
|
|
4
|
-
const banner = `/* ==========================================================
|
|
5
|
-
*
|
|
6
|
-
* p5.zine
|
|
7
|
-
* Copyright (c) 2026 Munus Shih, Tuan Huang, Iley Cao
|
|
8
|
-
*
|
|
9
|
-
* Licensed under GNU General Public License.
|
|
10
|
-
* https://www.gnu.org/licenses
|
|
11
|
-
===========================================================*/`;
|
|
12
|
-
|
|
13
|
-
const args = new Set(process.argv.slice(2));
|
|
14
|
-
const isWatch = args.has("--watch");
|
|
15
|
-
const isServe = args.has("--serve");
|
|
16
|
-
const isDev = args.has("--dev") || isWatch || isServe;
|
|
17
|
-
|
|
18
|
-
const host = process.env.HOST || "localhost";
|
|
19
|
-
const port = process.env.PORT ? Number(process.env.PORT) : 3000;
|
|
20
|
-
|
|
21
|
-
const buildOptions = {
|
|
22
|
-
entryPoints: {
|
|
23
|
-
"p5.zine": "src/index.modern.js",
|
|
24
|
-
"p5.zine.legacy": "src/index.legacy.js",
|
|
25
|
-
},
|
|
26
|
-
bundle: true,
|
|
27
|
-
minify: !isDev,
|
|
28
|
-
sourcemap: isDev ? "inline" : false,
|
|
29
|
-
outdir: "dist",
|
|
30
|
-
legalComments: "inline",
|
|
31
|
-
banner: {
|
|
32
|
-
js: banner,
|
|
33
|
-
},
|
|
34
|
-
logLevel: "info",
|
|
35
|
-
color: true,
|
|
36
|
-
loader: {
|
|
37
|
-
".html": "text",
|
|
38
|
-
".css": "text",
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
async function run() {
|
|
43
|
-
if (!isWatch && !isServe) {
|
|
44
|
-
try {
|
|
45
|
-
await esbuild.build(buildOptions);
|
|
46
|
-
console.log("Build successful! 🎉");
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error("❌ Build failed: ", error);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const ctx = await esbuild.context(buildOptions);
|
|
55
|
-
|
|
56
|
-
if (isServe) {
|
|
57
|
-
const server = await ctx.serve({
|
|
58
|
-
servedir: ".",
|
|
59
|
-
host,
|
|
60
|
-
port,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
console.log(
|
|
64
|
-
`Serving on http://${server.host}:${server.port} (open /test/index.html or /test/index.legacy.html)`,
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (isWatch) {
|
|
69
|
-
await ctx.watch();
|
|
70
|
-
console.log("Watching for changes...");
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
run().catch((error) => {
|
|
75
|
-
console.error("❌ Build failed: ", error);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
});
|
package/scripts/smoke-test.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const assert = require("assert");
|
|
4
|
-
|
|
5
|
-
const root = path.resolve(__dirname, "..");
|
|
6
|
-
const distModern = path.join(root, "dist", "p5.zine.js");
|
|
7
|
-
const distLegacy = path.join(root, "dist", "p5.zine.legacy.js");
|
|
8
|
-
const testModern = path.join(root, "test", "index.html");
|
|
9
|
-
const testLegacy = path.join(root, "test", "index.legacy.html");
|
|
10
|
-
|
|
11
|
-
function fileExists(filePath) {
|
|
12
|
-
try {
|
|
13
|
-
fs.accessSync(filePath, fs.constants.F_OK);
|
|
14
|
-
return true;
|
|
15
|
-
} catch (error) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
assert.ok(fileExists(distModern), "dist/p5.zine.js does not exist. Run npm run build first.");
|
|
21
|
-
assert.ok(fileExists(distLegacy), "dist/p5.zine.legacy.js does not exist. Run npm run build first.");
|
|
22
|
-
|
|
23
|
-
const modernStat = fs.statSync(distModern);
|
|
24
|
-
const legacyStat = fs.statSync(distLegacy);
|
|
25
|
-
assert.ok(modernStat.size > 0, "dist/p5.zine.js is empty.");
|
|
26
|
-
assert.ok(legacyStat.size > 0, "dist/p5.zine.legacy.js is empty.");
|
|
27
|
-
|
|
28
|
-
const modernContent = fs.readFileSync(distModern, "utf8");
|
|
29
|
-
const legacyContent = fs.readFileSync(distLegacy, "utf8");
|
|
30
|
-
assert.ok(
|
|
31
|
-
modernContent.includes("p5.zine"),
|
|
32
|
-
"dist/p5.zine.js does not include expected library banner/string."
|
|
33
|
-
);
|
|
34
|
-
assert.ok(
|
|
35
|
-
legacyContent.includes("p5.zine"),
|
|
36
|
-
"dist/p5.zine.legacy.js does not include expected library banner/string."
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
assert.ok(fileExists(testModern), "test/index.html is missing.");
|
|
40
|
-
assert.ok(fileExists(testLegacy), "test/index.legacy.html is missing.");
|
|
41
|
-
|
|
42
|
-
const testModernHtml = fs.readFileSync(testModern, "utf8");
|
|
43
|
-
const testLegacyHtml = fs.readFileSync(testLegacy, "utf8");
|
|
44
|
-
assert.ok(
|
|
45
|
-
testModernHtml.includes("../dist/p5.zine.js"),
|
|
46
|
-
"test/index.html does not reference ../dist/p5.zine.js."
|
|
47
|
-
);
|
|
48
|
-
assert.ok(
|
|
49
|
-
testLegacyHtml.includes("../dist/p5.zine.legacy.js"),
|
|
50
|
-
"test/index.legacy.html does not reference ../dist/p5.zine.legacy.js."
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
console.log("Smoke test passed ✅");
|
package/src/adapters/p5-1.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { zineAddon } from "../zine.js";
|
|
2
|
-
import { customAddon } from "../custom.js";
|
|
3
|
-
|
|
4
|
-
function registerLegacyHooks(lifecycles) {
|
|
5
|
-
if (typeof p5 === "undefined") {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
if (typeof p5.prototype.registerMethod !== "function") {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (lifecycles.presetup) {
|
|
13
|
-
p5.prototype.registerMethod("beforeSetup", lifecycles.presetup);
|
|
14
|
-
}
|
|
15
|
-
if (lifecycles.postsetup) {
|
|
16
|
-
p5.prototype.registerMethod("afterSetup", lifecycles.postsetup);
|
|
17
|
-
}
|
|
18
|
-
if (lifecycles.predraw) {
|
|
19
|
-
p5.prototype.registerMethod("pre", lifecycles.predraw);
|
|
20
|
-
}
|
|
21
|
-
if (lifecycles.postdraw) {
|
|
22
|
-
p5.prototype.registerMethod("post", lifecycles.postdraw);
|
|
23
|
-
}
|
|
24
|
-
if (lifecycles.remove) {
|
|
25
|
-
p5.prototype.registerMethod("remove", lifecycles.remove);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function registerLegacyAddon() {
|
|
30
|
-
if (typeof p5 === "undefined") {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const lifecycles = {};
|
|
35
|
-
zineAddon(p5, p5.prototype, lifecycles);
|
|
36
|
-
customAddon(p5, p5.prototype);
|
|
37
|
-
const originalInitZine = p5.prototype.initZine;
|
|
38
|
-
p5.prototype.initZine = function() {
|
|
39
|
-
if (typeof originalInitZine === "function") {
|
|
40
|
-
originalInitZine.call(this);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (typeof window === "undefined") {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const pages = ["cover", "one", "two", "three", "back"];
|
|
48
|
-
pages.forEach((key) => {
|
|
49
|
-
if (this[key]) {
|
|
50
|
-
window[key] = this[key];
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (this.selfie) {
|
|
55
|
-
window.selfie = this.selfie;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (this.all) {
|
|
59
|
-
window.all = this.all;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
registerLegacyHooks(lifecycles);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
registerLegacyAddon();
|
package/src/adapters/p5-2.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { zineAddon } from "../zine.js";
|
|
2
|
-
import { customAddon } from "../custom.js";
|
|
3
|
-
|
|
4
|
-
function registerLegacyHooks(lifecycles) {
|
|
5
|
-
if (typeof p5 === "undefined") {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
if (typeof p5.prototype.registerMethod !== "function") {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (lifecycles.presetup) {
|
|
13
|
-
p5.prototype.registerMethod("beforeSetup", lifecycles.presetup);
|
|
14
|
-
}
|
|
15
|
-
if (lifecycles.postsetup) {
|
|
16
|
-
p5.prototype.registerMethod("afterSetup", lifecycles.postsetup);
|
|
17
|
-
}
|
|
18
|
-
if (lifecycles.predraw) {
|
|
19
|
-
p5.prototype.registerMethod("pre", lifecycles.predraw);
|
|
20
|
-
}
|
|
21
|
-
if (lifecycles.postdraw) {
|
|
22
|
-
p5.prototype.registerMethod("post", lifecycles.postdraw);
|
|
23
|
-
}
|
|
24
|
-
if (lifecycles.remove) {
|
|
25
|
-
p5.prototype.registerMethod("remove", lifecycles.remove);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function registerModernAddon() {
|
|
30
|
-
if (typeof p5 === "undefined") {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (typeof p5.registerAddon === "function") {
|
|
35
|
-
p5.registerAddon(zineAddon);
|
|
36
|
-
p5.registerAddon(customAddon);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const lifecycles = {};
|
|
41
|
-
zineAddon(p5, p5.prototype, lifecycles);
|
|
42
|
-
customAddon(p5, p5.prototype);
|
|
43
|
-
registerLegacyHooks(lifecycles);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
registerModernAddon();
|