create-presenter 0.7.2 → 0.7.4
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/dist/index.js +149 -47
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1,71 +1,173 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";const u=require("path"),m=require("fs"),
|
|
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
|
|
13
|
+
"version": "0.1.0",
|
|
5
14
|
"description": "A Presenter.js presentation",
|
|
6
15
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"serve": "vite"
|
|
16
|
+
"serve": "vite",
|
|
17
|
+
"build": "tsc && vite build"
|
|
10
18
|
},
|
|
11
19
|
"devDependencies": {
|
|
12
|
-
"typescript": "^
|
|
13
|
-
"vite": "^
|
|
20
|
+
"typescript": "^6.0.2",
|
|
21
|
+
"vite": "^7.3.1"
|
|
14
22
|
},
|
|
15
23
|
"dependencies": {
|
|
16
|
-
"presenter": "^0.7.
|
|
24
|
+
"presenter": "^0.7.4"
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
|
-
`,
|
|
20
|
-
|
|
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
|
-
|
|
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
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
40
|
-
objects: [
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
50
|
-
|
|
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
|
-
`,
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
+
"typescript": "^6.0.2",
|
|
114
|
+
"vite": "^7.3.0",
|
|
115
|
+
"vite-plugin-dts": "^4.5.0"
|
|
116
|
+
},
|
|
117
|
+
"peerDependencies": {
|
|
118
|
+
"presenter": "^0.7.4"
|
|
60
119
|
}
|
|
61
120
|
}
|
|
62
|
-
`,
|
|
121
|
+
`,O=`// Add your exports here.
|
|
122
|
+
`,P=`{
|
|
123
|
+
"compilerOptions": {
|
|
124
|
+
"target": "ES2022",
|
|
125
|
+
"useDefineForClassFields": true,
|
|
126
|
+
"module": "ESNext",
|
|
127
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
128
|
+
"skipLibCheck": true,
|
|
129
|
+
|
|
130
|
+
/* Bundler mode */
|
|
131
|
+
"allowImportingTsExtensions": true,
|
|
132
|
+
"moduleDetection": "force",
|
|
133
|
+
"moduleResolution": "bundler",
|
|
134
|
+
"noEmit": true,
|
|
135
|
+
"resolveJsonModule": true,
|
|
136
|
+
"verbatimModuleSyntax": true,
|
|
63
137
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
138
|
+
/* Linting */
|
|
139
|
+
"strict": true,
|
|
140
|
+
"erasableSyntaxOnly": true,
|
|
141
|
+
"exactOptionalPropertyTypes": true,
|
|
142
|
+
"noFallthroughCasesInSwitch": true,
|
|
143
|
+
"noUncheckedIndexedAccess": true,
|
|
144
|
+
"noUncheckedSideEffectImports": true,
|
|
145
|
+
"noUnusedLocals": true,
|
|
146
|
+
"noUnusedParameters": true
|
|
147
|
+
},
|
|
148
|
+
"include": ["src"]
|
|
149
|
+
}
|
|
150
|
+
`,T=`import { defineConfig } from "vite";
|
|
151
|
+
import dts from "vite-plugin-dts";
|
|
152
|
+
|
|
153
|
+
export default defineConfig({
|
|
154
|
+
build: {
|
|
155
|
+
lib: {
|
|
156
|
+
entry: "src/index.ts",
|
|
157
|
+
formats: ["es", "cjs"],
|
|
158
|
+
fileName: (format) => \`index.\${format === "es" ? "js" : "cjs"}\`,
|
|
159
|
+
},
|
|
160
|
+
rollupOptions: {
|
|
161
|
+
external: ["presenter"],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
plugins: [dts({ compilerOptions: { declarationMap: true } })],
|
|
165
|
+
});
|
|
166
|
+
`;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}.
|
|
167
|
+
`);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(`
|
|
168
|
+
\x1B[32mSuccess! Created ${n} "${e}" at ${i}\x1B[0m`),r(`
|
|
169
|
+
To run your ${n}, run:`),r(`
|
|
170
|
+
$ cd ${e}`),r(t?`
|
|
171
|
+
$ npm run build`:`
|
|
70
172
|
$ npm run serve`),r(`
|
|
71
|
-
`)}catch(
|
|
173
|
+
`)}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.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Create a Presenter.js presentation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "vite build",
|
|
8
|
-
"
|
|
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"
|