presenter 0.1.1 → 0.2.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.
Files changed (43) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +39 -1
  3. package/dist/presenter.js +1 -1
  4. package/dist/src/index.d.ts +15 -0
  5. package/dist/src/objects/arrow.d.ts +36 -0
  6. package/dist/src/objects/group.d.ts +16 -0
  7. package/dist/src/objects/image.d.ts +11 -0
  8. package/dist/src/objects/line.d.ts +13 -0
  9. package/dist/src/objects/paragraph.d.ts +17 -0
  10. package/dist/src/objects/polygon.d.ts +13 -0
  11. package/dist/src/objects/rectangle.d.ts +14 -0
  12. package/dist/src/objects/text.d.ts +29 -0
  13. package/dist/src/objects/vectorGraphic.d.ts +14 -0
  14. package/dist/src/presentation/object.d.ts +122 -0
  15. package/dist/src/presentation/presentation.d.ts +99 -0
  16. package/dist/src/presentation/slide.d.ts +23 -0
  17. package/dist/src/util/animation.d.ts +37 -0
  18. package/dist/src/util/position.d.ts +11 -0
  19. package/dist/src/util/richText.d.ts +18 -0
  20. package/dist/webpack.config.d.ts +22 -0
  21. package/package.json +8 -5
  22. package/.husky/pre-commit +0 -1
  23. package/.prettierrc +0 -1
  24. package/examples/README.md +0 -23
  25. package/examples/simple/dist/index.html +0 -8
  26. package/examples/simple/package-lock.json +0 -3754
  27. package/examples/simple/package.json +0 -18
  28. package/examples/simple/src/index.ts +0 -20
  29. package/examples/simple/tsconfig.json +0 -10
  30. package/examples/simple/webpack.config.js +0 -25
  31. package/src/index.ts +0 -16
  32. package/src/objects/image.ts +0 -55
  33. package/src/objects/rectangle.ts +0 -53
  34. package/src/objects/text.ts +0 -79
  35. package/src/presentation/object.ts +0 -190
  36. package/src/presentation/presentation.ts +0 -299
  37. package/src/presentation/slide.ts +0 -52
  38. package/src/presentation/theme.ts +0 -3
  39. package/src/themes/default.ts +0 -7
  40. package/src/themes/index.ts +0 -1
  41. package/src/util/position.ts +0 -21
  42. package/tsconfig.json +0 -12
  43. package/webpack.config.js +0 -32
@@ -0,0 +1,99 @@
1
+ import { BoundingBox } from "../util/position";
2
+ import { Slide } from "./slide";
3
+ export interface PresentationOptions {
4
+ /**
5
+ * Width of the presentation.
6
+ */
7
+ width: number;
8
+ /**
9
+ * Height of the presentation.
10
+ */
11
+ height: number;
12
+ /**
13
+ * Slide color for the presentation.
14
+ */
15
+ backgroundColor: string;
16
+ }
17
+ interface PresentationState {
18
+ currentSlide: number;
19
+ }
20
+ export declare class Presentation {
21
+ /**
22
+ * Title of the presentation.
23
+ */
24
+ title: string;
25
+ /**
26
+ * Element where presentation should be mounted.
27
+ */
28
+ element: HTMLElement;
29
+ /**
30
+ * SVG container element.
31
+ */
32
+ container: HTMLElement;
33
+ /**
34
+ * Parent SVG element of presentation.
35
+ */
36
+ svg: SVGSVGElement | null;
37
+ /**
38
+ * Shadow SVG element, not displayed and used for calculating sizes.
39
+ */
40
+ shadow: SVGSVGElement | null;
41
+ /**
42
+ * Presentation settings.
43
+ */
44
+ options: PresentationOptions;
45
+ /**
46
+ * Bounds of presentation.
47
+ */
48
+ boundingBox: BoundingBox;
49
+ /**
50
+ * Presentation slides.
51
+ */
52
+ slides: Slide[];
53
+ /**
54
+ * Presentation state.
55
+ */
56
+ presentationState: PresentationState;
57
+ /**
58
+ *
59
+ * @param title Title of the presentation.
60
+ */
61
+ constructor(title: string, slides: Slide[], element: HTMLElement, options?: Partial<PresentationOptions>);
62
+ present(): void;
63
+ /**
64
+ * Sets up keyboard commands for the presentation.
65
+ */
66
+ setupKeyboardCommands(): void;
67
+ /**
68
+ * Updates the size of the parent SVG element.
69
+ *
70
+ * The size of the parent SVG element needs to be updated.
71
+ */
72
+ updateSVGContainerSize(): void;
73
+ /**
74
+ * Advances to next animation in slide, or next slide if there is no next animation.
75
+ * Returns true if we were able to successfully advance.
76
+ * @param includeIntermediateBuilds Determines whether to progress through builds.
77
+ */
78
+ next(includeIntermediateBuilds: boolean): boolean;
79
+ /**
80
+ * Goes back to the previous slide.
81
+ * @param includeIntermediateBuilds Determines whether to progress through builds.
82
+ */
83
+ previous(includeIntermediateBuilds: boolean): void;
84
+ /**
85
+ * Checks if the presentation takes the entire document body.
86
+ * @returns True if the presentation takes the entire document body.
87
+ */
88
+ isFullBodyPresentation(): boolean;
89
+ /**
90
+ * Computes the current size of an element in the DOM.
91
+ * Optionally accepts a custom list of children to see what the size of an
92
+ * element would be with different children.
93
+ * @param element Element to compute size of.
94
+ * @param children Custom children to use for element.
95
+ * @returns BoundingBox
96
+ */
97
+ computeRenderedBoundingBox(element: SVGGraphicsElement, children?: Node[] | null): BoundingBox;
98
+ }
99
+ export {};
@@ -0,0 +1,23 @@
1
+ import { BuildFunction } from "../util/animation";
2
+ import { SlideObject } from "./object";
3
+ import { Presentation } from "./presentation";
4
+ export interface SlideProps {
5
+ }
6
+ export declare class Slide {
7
+ objects: SlideObject<any>[];
8
+ animations: BuildFunction[];
9
+ animationIndex: number;
10
+ /**
11
+ * Property for use during development/debugging only.
12
+ * Manually set this property to a build function index
13
+ * to debug a specific animation.
14
+ */
15
+ debugAnimation: number | null;
16
+ constructor(objects: SlideObject<any>[], animations?: BuildFunction[]);
17
+ render(presentation: Presentation, animationIndex?: number): void;
18
+ nextAnimation(presentation: Presentation): boolean;
19
+ /**
20
+ * Sleep for a specified number of milliseconds in an animation.
21
+ */
22
+ sleep(ms: number): Promise<unknown>;
23
+ }
@@ -0,0 +1,37 @@
1
+ import anime from "animejs/lib/anime.es.js";
2
+ /**
3
+ * Data needed to process an animation.
4
+ */
5
+ export interface AnimationProps {
6
+ /**
7
+ * Whether to animate the change.
8
+ */
9
+ animate?: boolean;
10
+ element?: HTMLElement | SVGElement;
11
+ attributes?: Record<string, string>;
12
+ styles?: Record<string, string>;
13
+ animationParams?: anime.AnimeParams;
14
+ children?: Node[];
15
+ /**
16
+ * Delay, in milliseconds.
17
+ */
18
+ delay?: number;
19
+ }
20
+ /**
21
+ * Function that performs an animation on an element.
22
+ */
23
+ export type Animator = (props: AnimationProps | AnimationProps[]) => Promise<void>;
24
+ /**
25
+ * Function that possibly applies a sequence of animations.
26
+ */
27
+ export type BuildFunction = (animate: Animator) => void;
28
+ /**
29
+ * Perform an animation on an element.
30
+ * @param props Animation properties.
31
+ */
32
+ export declare const performAnimation: Animator;
33
+ /**
34
+ * Performs animations by skipping the animation duration and jumping to end of animation.
35
+ * @param props Animation properties.
36
+ */
37
+ export declare const skipAnimation: Animator;
@@ -0,0 +1,11 @@
1
+ export interface Position {
2
+ x: number;
3
+ y: number;
4
+ }
5
+ export declare class BoundingBox {
6
+ origin: Position;
7
+ width: number;
8
+ height: number;
9
+ constructor(origin: Position, width: number, height: number);
10
+ static fromElement(element: SVGGraphicsElement): BoundingBox;
11
+ }
@@ -0,0 +1,18 @@
1
+ export interface RichTextProps {
2
+ fontStyle?: string;
3
+ fontWeight?: string | number;
4
+ fontSize?: number;
5
+ fontFamily?: string;
6
+ textDecoration?: string;
7
+ color?: string;
8
+ dy?: number;
9
+ }
10
+ export type RichTextSpan = string | [string, RichTextProps];
11
+ /**
12
+ * Creates a text node with spaces replaced by non-breaking spaces.
13
+ */
14
+ export declare function createSpacePreservingTextNode(text: string): Text;
15
+ /**
16
+ * Given rich text configuration, returns the corresponding tspan nodes.
17
+ */
18
+ export declare function generateTextNodes(lines: (string | RichTextSpan[])[], lineSpacing?: string, anchor?: "start" | "middle" | "end"): Node[];
@@ -0,0 +1,22 @@
1
+ export let mode: string;
2
+ export let entry: string;
3
+ export namespace output {
4
+ let filename: string;
5
+ let path: string;
6
+ let library: string;
7
+ let libraryTarget: string;
8
+ let globalObject: string;
9
+ }
10
+ export namespace watchOptions {
11
+ let ignored: string[];
12
+ }
13
+ export namespace resolve {
14
+ let extensions: string[];
15
+ }
16
+ export namespace module {
17
+ let rules: {
18
+ test: RegExp;
19
+ use: string;
20
+ exclude: RegExp;
21
+ }[];
22
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "presenter",
3
- "version": "0.1.1",
4
- "description": "A JavaScript-based presentation library",
3
+ "version": "0.2.2",
4
+ "description": "A JavaScript presentation library",
5
5
  "main": "dist/presenter.js",
6
6
  "types": "dist/src/index.d.ts",
7
7
  "scripts": {
@@ -19,6 +19,12 @@
19
19
  "url": "https://github.com/brianyu28/presenter/issues"
20
20
  },
21
21
  "homepage": "https://github.com/brianyu28/presenter#readme",
22
+ "files": [
23
+ "./dist/"
24
+ ],
25
+ "dependencies": {
26
+ "animejs": "^3.2.2"
27
+ },
22
28
  "devDependencies": {
23
29
  "@types/animejs": "^3.1.12",
24
30
  "husky": "^9.1.7",
@@ -31,8 +37,5 @@
31
37
  },
32
38
  "lint-staged": {
33
39
  "**/*": "prettier --write --ignore-unknown"
34
- },
35
- "dependencies": {
36
- "animejs": "^3.2.2"
37
40
  }
38
41
  }
package/.husky/pre-commit DELETED
@@ -1 +0,0 @@
1
- npx lint-staged
package/.prettierrc DELETED
@@ -1 +0,0 @@
1
- {}
@@ -1,23 +0,0 @@
1
- # Examples
2
-
3
- Example Presenter.js presentations.
4
-
5
- ## Usage
6
-
7
- The examples currently require [symlinking the Presenter.js package](https://docs.npmjs.com/cli/v9/commands/npm-link).
8
-
9
- In the root of this repository, run:
10
-
11
- ```
12
- $ npm link
13
- ```
14
-
15
- Then, in each of the examples, e.g. `examples/simple`, run:
16
-
17
- ```
18
- $ npm link presenter
19
- ```
20
-
21
- This symlinks the local version of the `presenter` package into the example presentation.
22
-
23
- Then, run the development server with `npm run serve` or build the production version with `npm run build`.
@@ -1,8 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <title>Simple Example</title>
5
- <script src="main.js"></script>
6
- </head>
7
- <body></body>
8
- </html>