create-presenter 0.7.2 → 0.7.3

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 +150 -47
  2. package/package.json +2 -3
package/dist/index.js CHANGED
@@ -1,71 +1,174 @@
1
1
  #!/usr/bin/env node
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=`{
2
+ "use strict";const u=require("path"),m=require("fs"),_=require("readline");function l(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,s.get?s:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const c=l(u),a=l(m),f=l(_),b=`<!doctype html>
3
+ <html lang="en">
4
+ <head>
5
+ <title>Presentation</title>
6
+ </head>
7
+ <body>
8
+ <script type="module" src="/src/main.ts"><\/script>
9
+ </body>
10
+ </html>
11
+ `,g=`{
3
12
  "name": "{{ projectName }}",
4
- "version": "1.0.0",
13
+ "version": "0.1.0",
5
14
  "description": "A Presenter.js presentation",
6
15
  "scripts": {
7
- "build": "vite build",
8
- "dev": "vite",
9
- "serve": "vite"
16
+ "serve": "vite",
17
+ "build": "tsc && vite build"
10
18
  },
11
19
  "devDependencies": {
12
- "typescript": "^5.7.2",
13
- "vite": "^6.1.0"
20
+ "typescript": "^6.0.2",
21
+ "vite": "^7.3.1"
14
22
  },
15
23
  "dependencies": {
16
- "presenter": "^0.7.2"
24
+ "presenter": "^0.7.3"
17
25
  }
18
26
  }
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";
27
+ `,v=`import { BrowserCanvasRenderer } from "presenter";
28
+ import { presentation } from "./presentation";
29
29
 
30
- const presentationSize = { width: 3840, height: 2160 };
30
+ document.addEventListener("DOMContentLoaded", () => {
31
+ const renderer = new BrowserCanvasRenderer({
32
+ presentation,
33
+ });
34
+ renderer.present();
35
+ });
36
+ `,y=`import { Presentation } from "presenter";
37
+ import { TitleSlide } from "./slides/TitleSlide";
31
38
 
32
- const text = Text("Welcome to Presenter.js!", {
33
- x: presentationSize.width / 2,
34
- y: presentationSize.height / 2,
39
+ export const presentation = Presentation({
40
+ title: "Presentation",
41
+ slides: [TitleSlide],
42
+ });
43
+ `,h=`import { getSizingFunctions } from "presenter";
44
+
45
+ export const { position, scaleX, scaleY } = getSizingFunctions({ width: 3840, height: 2160 });
46
+ `,x=`import { Anchor, Slide, Text } from "presenter";
47
+ import { position } from "../size";
48
+
49
+ const title = Text("Welcome to Presenter.js!", {
35
50
  anchor: Anchor.CENTER,
36
51
  fontSize: 150,
52
+ ...position(0.5, 0.5),
37
53
  });
38
54
 
39
- const slide = Slide({
40
- objects: [text],
55
+ export const TitleSlide = Slide({
56
+ objects: [title],
41
57
  });
58
+ `,j=`{
59
+ "compilerOptions": {
60
+ "target": "ES2022",
61
+ "useDefineForClassFields": true,
62
+ "module": "ESNext",
63
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
64
+ "types": ["vite/client"],
65
+ "skipLibCheck": true,
42
66
 
43
- document.addEventListener("DOMContentLoaded", () => {
44
- const presentation = Presentation({
45
- size: presentationSize,
46
- slides: [slide],
47
- });
67
+ /* Bundler mode */
68
+ "allowImportingTsExtensions": true,
69
+ "moduleDetection": "force",
70
+ "moduleResolution": "bundler",
71
+ "noEmit": true,
72
+ "resolveJsonModule": true,
73
+ "verbatimModuleSyntax": true,
48
74
 
49
- const renderer = new BrowserCanvasRenderer({ presentation });
50
- renderer.present();
75
+ /* Linting */
76
+ "strict": true,
77
+ "erasableSyntaxOnly": true,
78
+ "exactOptionalPropertyTypes": true,
79
+ "noFallthroughCasesInSwitch": true,
80
+ "noUncheckedIndexedAccess": true,
81
+ "noUncheckedSideEffectImports": true,
82
+ "noUnusedLocals": true,
83
+ "noUnusedParameters": true
84
+ },
85
+ "include": ["src"]
86
+ }
87
+ `,S=`import { defineConfig } from "vite";
88
+
89
+ export default defineConfig({
90
+ server: {
91
+ port: 8080,
92
+ },
51
93
  });
52
- `,v=`{
53
- "compilerOptions": {
54
- "moduleResolution": "node16",
55
- "module": "node16",
56
- "outDir": "./dist/",
57
- "noImplicitAny": true,
58
- "target": "es5",
59
- "allowJs": true
94
+ `,w=`{
95
+ "name": "{{ projectName }}",
96
+ "version": "1.0.0",
97
+ "description": "A Presenter.js library",
98
+ "main": "dist/index.cjs",
99
+ "module": "dist/index.js",
100
+ "types": "dist/src/index.d.ts",
101
+ "exports": {
102
+ ".": {
103
+ "types": "./dist/src/index.d.ts",
104
+ "import": "./dist/index.js",
105
+ "require": "./dist/index.cjs"
106
+ }
107
+ },
108
+ "scripts": {
109
+ "build": "vite build",
110
+ "watch": "vite build --watch"
111
+ },
112
+ "devDependencies": {
113
+ "presenter": "^0.7.2",
114
+ "typescript": "^6.0.2",
115
+ "vite": "^7.3.0",
116
+ "vite-plugin-dts": "^4.5.0"
117
+ },
118
+ "peerDependencies": {
119
+ "presenter": "^0.7.3"
60
120
  }
61
121
  }
62
- `,x=`import { defineConfig } from "vite";
122
+ `,O=`// Add your exports here.
123
+ `,P=`{
124
+ "compilerOptions": {
125
+ "target": "ES2022",
126
+ "useDefineForClassFields": true,
127
+ "module": "ESNext",
128
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
129
+ "skipLibCheck": true,
130
+
131
+ /* Bundler mode */
132
+ "allowImportingTsExtensions": true,
133
+ "moduleDetection": "force",
134
+ "moduleResolution": "bundler",
135
+ "noEmit": true,
136
+ "resolveJsonModule": true,
137
+ "verbatimModuleSyntax": true,
63
138
 
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(`
139
+ /* Linting */
140
+ "strict": true,
141
+ "erasableSyntaxOnly": true,
142
+ "exactOptionalPropertyTypes": true,
143
+ "noFallthroughCasesInSwitch": true,
144
+ "noUncheckedIndexedAccess": true,
145
+ "noUncheckedSideEffectImports": true,
146
+ "noUnusedLocals": true,
147
+ "noUnusedParameters": true
148
+ },
149
+ "include": ["src"]
150
+ }
151
+ `,T=`import { defineConfig } from "vite";
152
+ import dts from "vite-plugin-dts";
153
+
154
+ export default defineConfig({
155
+ build: {
156
+ lib: {
157
+ entry: "src/index.ts",
158
+ formats: ["es", "cjs"],
159
+ fileName: (format) => \`index.\${format === "es" ? "js" : "cjs"}\`,
160
+ },
161
+ rollupOptions: {
162
+ external: ["presenter"],
163
+ },
164
+ },
165
+ plugins: [dts({ compilerOptions: { declarationMap: true } })],
166
+ });
167
+ `;function r(t,...n){console.log(t,...n)}async function E(t){return new Promise(n=>{const e=f.createInterface({input:process.stdin,output:process.stdout});e.question(t,s=>{e.close(),n(s)})})}async function C(t,n,e){return Object.keys(e).forEach(s=>{n=n.replace(new RegExp(`{{\\s*${s}\\s*}}`,"g"),e[s])}),new Promise((s,i)=>{a.writeFile(t,n,o=>{o?i(o):s()})})}const $=Object.assign({"./templates/presentation/index.html":b,"./templates/presentation/package.json":g,"./templates/presentation/src/main.ts":v,"./templates/presentation/src/presentation.ts":y,"./templates/presentation/src/size.ts":h,"./templates/presentation/src/slides/TitleSlide.ts":x,"./templates/presentation/tsconfig.json":j,"./templates/presentation/vite.config.ts":S}),D=Object.assign({"./templates/lib/package.json":w,"./templates/lib/src/index.ts":O,"./templates/lib/tsconfig.json":P,"./templates/lib/vite.config.ts":T});async function k(t,n,e,s){for(const[i,o]of Object.entries(t)){const p=i.slice(n.length+1),d=c.join(e,p);a.mkdirSync(c.dirname(d),{recursive:!0}),await C(d,o,s)}}async function I(){try{const t=process.argv.includes("--lib"),n=t?"library":"presentation";r(`This utility will help you create a new Presenter.js ${n}.
168
+ `);let e=(await E(`${n} name: (${n}) `)).replace(/\s+/g,"-").toLowerCase();e===""&&(e=n);const s=process.cwd(),i=c.join(s,e);if(a.existsSync(i))throw new Error(`Directory '${e}' already exists.`);r(`Creating a new Presenter.js ${n} in ${e}...`),await k(t?D:$,t?"./templates/lib":"./templates/presentation",i,{projectName:e}),r("Installing dependencies..."),require("child_process").execSync(`cd ${e} && npm install`,{stdio:"inherit"}),r(`
169
+ \x1B[32mSuccess! Created ${n} "${e}" at ${i}\x1B[0m`),r(`
170
+ To run your ${n}, run:`),r(`
171
+ $ cd ${e}`),r(t?`
172
+ $ npm run build`:`
70
173
  $ npm run serve`),r(`
71
- `)}catch(n){console.error(),console.error(n)}}b();
174
+ `)}catch(t){console.error(),console.error(t)}}I();
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "create-presenter",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Create a Presenter.js presentation",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "vite build",
8
- "start": "node dist/index.js",
9
- "dev": "NODE_ENV=production webpack && node dist/index.js"
8
+ "create": "node dist/index.js"
10
9
  },
11
10
  "bin": {
12
11
  "create-presenter": "dist/index.js"