create-presenter 0.6.4 → 0.7.0

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.
Files changed (2) hide show
  1. package/dist/index.js +70 -1
  2. package/package.json +3 -5
package/dist/index.js CHANGED
@@ -1,2 +1,71 @@
1
1
  #!/usr/bin/env node
2
- (()=>{"use strict";var n={317:n=>{n.exports=require("child_process")}},e={};function t(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return n[r](i,i.exports,t),i.exports}const r=require("path"),o=require("fs"),i=require("readline");var s=function(n,e,t,r){return new(t||(t=Promise))((function(o,i){function s(n){try{a(r.next(n))}catch(n){i(n)}}function c(n){try{a(r.throw(n))}catch(n){i(n)}}function a(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(s,c)}a((r=r.apply(n,e||[])).next())}))},c=function(n,e){var t,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=c(0),s.throw=c(1),s.return=c(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function c(c){return function(a){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(i=0)),i;)try{if(t=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(n,i)}catch(n){c=[6,n],r=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};function a(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];console.log.apply(console,function(n,e,t){if(t||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return n.concat(r||Array.prototype.slice.call(e))}([n],e,!1))}function u(n){return s(this,void 0,void 0,(function(){return c(this,(function(e){return[2,new Promise((function(e){var t=i.createInterface({input:process.stdin,output:process.stdout});t.question(n,(function(n){t.close(),e(n)}))}))]}))}))}function l(n){return s(this,void 0,void 0,(function(){return c(this,(function(e){return[2,new Promise((function(e,t){o.mkdir(n,(function(r){r?("EEXIST"===r.code&&t(new Error("Directory '".concat(n,"' already exists."))),t(r)):e()}))}))]}))}))}function p(n,e,t){return s(this,void 0,void 0,(function(){return c(this,(function(r){return Object.keys(t).forEach((function(n){e=e.replace(new RegExp("{{\\s*".concat(n,"\\s*}}"),"g"),t[n])})),[2,new Promise((function(t,r){o.writeFile(n,e,(function(n){n?r(n):t()}))}))]}))}))}!function(){var n,e,o,i;n=this,e=void 0,i=function(){var n,e,o;return function(n,e){var t,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=c(0),s.throw=c(1),s.return=c(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function c(c){return function(a){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(i=0)),i;)try{if(t=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(n,i)}catch(n){c=[6,n],r=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}(this,(function(i){switch(i.label){case 0:return i.trys.push([0,11,,12]),n=process.cwd(),a("This utility will help you create a new Presenter.js presentation.\n"),[4,u("presentation name: (presentation) ")];case 1:return""===(e=i.sent().replace(/\s+/g,"-").toLowerCase())&&(e="presentation"),a("Creating a new Presenter.js presentation in ".concat(e,"...")),[4,l(e)];case 2:return i.sent(),[4,l(r.join(e,"public"))];case 3:return i.sent(),[4,l(r.join(e,"src"))];case 4:return i.sent(),[4,p(r.join(n,e,"package.json"),'{\n "name": "{{ projectName }}",\n "version": "1.0.0",\n "description": "A Presenter.js presentation",\n "main": "dist/main.js",\n "scripts": {\n "build": "NODE_ENV=production webpack",\n "watch": "NODE_ENV=development webpack --watch",\n "serve": "NODE_ENV=development webpack serve --open"\n },\n "devDependencies": {\n "copy-webpack-plugin": "^12.0.2",\n "ts-loader": "^9.5.1",\n "typescript": "^5.7.2",\n "webpack": "^5.96.1",\n "webpack-cli": "^5.1.4",\n "webpack-dev-server": "^5.1.0"\n },\n "dependencies": {\n "presenter": "^0.6.4"\n }\n}\n',{projectName:e})];case 5:return i.sent(),[4,p(r.join(n,e,"tsconfig.json"),'{\n "compilerOptions": {\n "moduleResolution": "node16",\n "module": "node16",\n "outDir": "./dist/",\n "noImplicitAny": true,\n "target": "es5",\n "allowJs": true\n }\n}\n',{})];case 6:return i.sent(),[4,p(r.join(n,e,"webpack.config.js"),'const path = require("path");\nconst CopyPlugin = require("copy-webpack-plugin");\n\nmodule.exports = {\n mode: process.env.NODE_ENV || "development",\n entry: "./src/index.ts",\n output: {\n filename: "main.js",\n path: path.resolve(__dirname, "dist"),\n },\n devServer: {\n static: "./dist",\n },\n resolve: {\n extensions: [".ts", ".js"],\n },\n module: {\n rules: [\n {\n test: /\\.ts$/,\n use: "ts-loader",\n exclude: /node_modules/,\n },\n {\n test: /\\.(svg)$/i,\n type: "asset/source",\n },\n ],\n },\n plugins: [\n new CopyPlugin({\n patterns: [{ from: "public", to: "." }],\n }),\n ],\n};\n',{})];case 7:return i.sent(),[4,p(r.join(n,e,"public","index.html"),'<!doctype html>\n<html lang="en">\n <head>\n <title>Presenter.js</title>\n <script src="main.js"><\/script>\n </head>\n <body></body>\n</html>\n',{})];case 8:return i.sent(),[4,p(r.join(n,e,"src","index.ts"),'import { Anchor, BrowserCanvasRenderer, Presentation, Slide, Text } from "presenter";\n\nconst presentationSize = { width: 3840, height: 2160 };\n\nconst text = Text("Welcome to Presenter.js!", {\n x: presentationSize.width / 2,\n y: presentationSize.height / 2,\n anchor: Anchor.CENTER,\n fontSize: 150,\n});\n\nconst slide = Slide({\n objects: [text],\n});\n\ndocument.addEventListener("DOMContentLoaded", () => {\n const presentation = Presentation({\n size: presentationSize,\n slides: [slide],\n });\n\n const renderer = new BrowserCanvasRenderer({ presentation });\n renderer.present();\n});\n',{})];case 9:return i.sent(),a("Installing dependencies..."),[4,t(317).execSync("cd ".concat(e," && npm install"),{stdio:"inherit"})];case 10:return i.sent(),a('\nSuccess! Created project "'.concat(e,'" at ').concat(r.join(n,e),"")),a("\nTo run your presentation, run:"),a("\n $ cd ".concat(e)),a("\n $ npm run serve"),a("\n"),[3,12];case 11:return o=i.sent(),console.error(),console.error(o),[3,12];case 12:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,r){function s(n){try{a(i.next(n))}catch(n){r(n)}}function c(n){try{a(i.throw(n))}catch(n){r(n)}}function a(n){var e;n.done?t(n.value):(e=n.value,e instanceof o?e:new o((function(n){n(e)}))).then(s,c)}a((i=i.apply(n,e||[])).next())}))}()})();
2
+ "use strict";const u=require("path"),m=require("fs"),f=require("readline");function a(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const s=a(u),l=a(m),w=a(f);function r(n,...e){console.log(n,...e)}async function g(n){return new Promise(e=>{const t=w.createInterface({input:process.stdin,output:process.stdout});t.question(n,i=>{t.close(),e(i)})})}async function p(n){return new Promise((e,t)=>{l.mkdir(n,i=>{i?(i.code==="EEXIST"&&t(new Error(`Directory '${n}' already exists.`)),t(i)):e()})})}async function o(n,e,t){return Object.keys(t).forEach(i=>{e=e.replace(new RegExp(`{{\\s*${i}\\s*}}`,"g"),t[i])}),new Promise((i,d)=>{l.writeFile(n,e,c=>{c?d(c):i()})})}const h=`{
3
+ "name": "{{ projectName }}",
4
+ "version": "1.0.0",
5
+ "description": "A Presenter.js presentation",
6
+ "scripts": {
7
+ "build": "vite build",
8
+ "dev": "vite",
9
+ "serve": "vite"
10
+ },
11
+ "devDependencies": {
12
+ "typescript": "^5.7.2",
13
+ "vite": "^6.1.0"
14
+ },
15
+ "dependencies": {
16
+ "presenter": "^0.7.0"
17
+ }
18
+ }
19
+ `,j=`<!doctype html>
20
+ <html lang="en">
21
+ <head>
22
+ <title>Presenter.js</title>
23
+ </head>
24
+ <body>
25
+ <script type="module" src="/src/index.ts"><\/script>
26
+ </body>
27
+ </html>
28
+ `,y=`import { Anchor, BrowserCanvasRenderer, Presentation, Slide, Text } from "presenter";
29
+
30
+ const presentationSize = { width: 3840, height: 2160 };
31
+
32
+ const text = Text("Welcome to Presenter.js!", {
33
+ x: presentationSize.width / 2,
34
+ y: presentationSize.height / 2,
35
+ anchor: Anchor.CENTER,
36
+ fontSize: 150,
37
+ });
38
+
39
+ const slide = Slide({
40
+ objects: [text],
41
+ });
42
+
43
+ document.addEventListener("DOMContentLoaded", () => {
44
+ const presentation = Presentation({
45
+ size: presentationSize,
46
+ slides: [slide],
47
+ });
48
+
49
+ const renderer = new BrowserCanvasRenderer({ presentation });
50
+ renderer.present();
51
+ });
52
+ `,v=`{
53
+ "compilerOptions": {
54
+ "moduleResolution": "node16",
55
+ "module": "node16",
56
+ "outDir": "./dist/",
57
+ "noImplicitAny": true,
58
+ "target": "es5",
59
+ "allowJs": true
60
+ }
61
+ }
62
+ `,x=`import { defineConfig } from "vite";
63
+
64
+ export default defineConfig({});
65
+ `;async function b(){try{const n=process.cwd();r(`This utility will help you create a new Presenter.js presentation.
66
+ `);let e=(await g("presentation name: (presentation) ")).replace(/\s+/g,"-").toLowerCase();e===""&&(e="presentation"),r(`Creating a new Presenter.js presentation in ${e}...`),await p(e),await p(s.join(e,"src")),await o(s.join(n,e,"package.json"),h,{projectName:e}),await o(s.join(n,e,"tsconfig.json"),v,{}),await o(s.join(n,e,"vite.config.ts"),x,{}),await o(s.join(n,e,"index.html"),j,{}),await o(s.join(n,e,"src","index.ts"),y,{}),r("Installing dependencies..."),await require("child_process").execSync(`cd ${e} && npm install`,{stdio:"inherit"}),r(`
67
+ \x1B[32mSuccess! Created project "${e}" at ${s.join(n,e)}\x1B[0m`),r(`
68
+ To run your presentation, run:`),r(`
69
+ $ cd ${e}`),r(`
70
+ $ npm run serve`),r(`
71
+ `)}catch(n){console.error(),console.error(n)}}b();
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "create-presenter",
3
- "version": "0.6.4",
3
+ "version": "0.7.0",
4
4
  "description": "Create a Presenter.js presentation",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "build": "NODE_ENV=production webpack",
7
+ "build": "vite build",
8
8
  "start": "node dist/index.js",
9
9
  "dev": "NODE_ENV=production webpack && node dist/index.js"
10
10
  },
@@ -26,9 +26,7 @@
26
26
  },
27
27
  "homepage": "https://github.com/brianyu28/presenter#readme",
28
28
  "devDependencies": {
29
- "ts-loader": "^9.5.1",
30
29
  "typescript": "^5.7.2",
31
- "webpack": "^5.97.1",
32
- "webpack-cli": "^5.1.4"
30
+ "vite": "^6.1.0"
33
31
  }
34
32
  }