squiffy-runtime 6.0.0-alpha.15 → 6.0.0-alpha.17

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 (45) hide show
  1. package/dist/animation.d.ts +11 -0
  2. package/dist/events.d.ts +8 -3
  3. package/dist/import.d.ts +4 -0
  4. package/dist/linkHandler.d.ts +8 -0
  5. package/dist/pluginManager.d.ts +23 -0
  6. package/dist/squiffy.runtime.d.ts +2 -2
  7. package/dist/squiffy.runtime.global.js +126 -0
  8. package/dist/squiffy.runtime.global.js.map +1 -0
  9. package/dist/squiffy.runtime.js +8785 -487
  10. package/dist/squiffy.runtime.js.map +1 -0
  11. package/dist/state.d.ts +19 -0
  12. package/dist/textProcessor.d.ts +8 -13
  13. package/dist/types.d.ts +5 -2
  14. package/dist/types.plugins.d.ts +27 -0
  15. package/dist/updater.d.ts +2 -0
  16. package/dist/utils.d.ts +1 -2
  17. package/package.json +12 -5
  18. package/src/__snapshots__/squiffy.runtime.test.ts.snap +53 -19
  19. package/src/animation.ts +68 -0
  20. package/src/events.ts +9 -10
  21. package/src/import.ts +5 -0
  22. package/src/linkHandler.ts +18 -0
  23. package/src/pluginManager.ts +74 -0
  24. package/src/plugins/animate.ts +97 -0
  25. package/src/plugins/index.ts +13 -0
  26. package/src/plugins/live.ts +83 -0
  27. package/src/plugins/random.ts +22 -0
  28. package/src/plugins/replaceLabel.ts +22 -0
  29. package/src/plugins/rotateSequence.ts +61 -0
  30. package/src/squiffy.runtime.test.ts +306 -134
  31. package/src/squiffy.runtime.ts +460 -332
  32. package/src/state.ts +106 -0
  33. package/src/textProcessor.ts +61 -164
  34. package/src/types.plugins.ts +41 -0
  35. package/src/types.ts +5 -2
  36. package/src/updater.ts +77 -0
  37. package/src/utils.ts +15 -12
  38. package/vite.config.ts +36 -0
  39. package/vitest.config.ts +9 -0
  40. package/vitest.setup.ts +16 -0
  41. package/dist/events.js +0 -35
  42. package/dist/squiffy.runtime.test.js +0 -394
  43. package/dist/textProcessor.js +0 -166
  44. package/dist/types.js +0 -1
  45. package/dist/utils.js +0 -14
@@ -0,0 +1,11 @@
1
+ export declare class Animation {
2
+ animations: {
3
+ [name: string]: (el: HTMLElement, params: Record<string, any>, onComplete: () => void, loop: boolean) => void;
4
+ };
5
+ linkAnimations: Map<HTMLElement, () => void>;
6
+ registerAnimation(name: string, handler: (el: HTMLElement, params: Record<string, any>, onComplete: () => void, loop: boolean) => void): void;
7
+ runAnimation(name: string, el: HTMLElement, params: Record<string, any>, onComplete: () => void, loop: boolean): void;
8
+ addLinkAnimation(link: HTMLElement, fn: () => void): void;
9
+ runLinkAnimation(link: HTMLElement): void;
10
+ constructor();
11
+ }
package/dist/events.d.ts CHANGED
@@ -1,7 +1,13 @@
1
- type LinkType = 'section' | 'passage' | 'rotate' | 'sequence';
2
1
  export type SquiffyEventMap = {
3
2
  linkClick: {
4
- linkType: LinkType;
3
+ linkType: string;
4
+ };
5
+ set: {
6
+ attribute: string;
7
+ value: any;
8
+ };
9
+ canGoBackChanged: {
10
+ canGoBack: boolean;
5
11
  };
6
12
  };
7
13
  export type SquiffyEventHandler<E extends keyof SquiffyEventMap> = (payload: SquiffyEventMap[E]) => void;
@@ -12,4 +18,3 @@ export declare class Emitter<Events extends Record<string, any>> {
12
18
  once<E extends keyof Events>(event: E, handler: (p: Events[E]) => void): () => void;
13
19
  emit<E extends keyof Events>(event: E, payload: Events[E]): void;
14
20
  }
15
- export {};
@@ -0,0 +1,4 @@
1
+ import * as animejs from "animejs";
2
+ export declare const imports: {
3
+ animejs: typeof animejs;
4
+ };
@@ -0,0 +1,8 @@
1
+ import { HandleLinkResult } from './types.plugins.js';
2
+ export declare class LinkHandler {
3
+ linkHandlers: {
4
+ [type: string]: (el: HTMLElement) => HandleLinkResult;
5
+ };
6
+ registerLinkHandler(type: string, handler: (el: HTMLElement) => HandleLinkResult): void;
7
+ handleLink(link: HTMLElement): [found: boolean, type: string, result: HandleLinkResult];
8
+ }
@@ -0,0 +1,23 @@
1
+ import { TextProcessor } from './textProcessor.js';
2
+ import { SquiffyPlugin } from './types.plugins.js';
3
+ import { State } from './state.js';
4
+ import { LinkHandler } from './linkHandler.js';
5
+ import { Emitter, SquiffyEventMap } from './events.js';
6
+ import { Animation } from './animation.js';
7
+ export declare class PluginManager {
8
+ outputElement: HTMLElement;
9
+ textProcessor: TextProcessor;
10
+ state: State;
11
+ linkHandler: LinkHandler;
12
+ getSectionText: (name: string) => string | null;
13
+ getPassageText: (name: string) => string | null;
14
+ processText: (text: string, inline: boolean) => string;
15
+ addTransition: (fn: () => Promise<void>) => void;
16
+ emitter: Emitter<SquiffyEventMap>;
17
+ plugins: SquiffyPlugin[];
18
+ animation: Animation;
19
+ constructor(outputElement: HTMLElement, textProcessor: TextProcessor, state: State, linkHandler: LinkHandler, getSectionText: (name: string) => string | null, getPassageText: (name: string) => string | null, processText: (text: string, inline: boolean) => string, addTransition: (fn: () => Promise<void>) => void, animation: Animation, emitter: Emitter<SquiffyEventMap>);
20
+ add(plugin: SquiffyPlugin): void | Promise<void>;
21
+ onWrite(el: HTMLElement): void;
22
+ onLoad(): void;
23
+ }
@@ -1,3 +1,3 @@
1
1
  import { SquiffyApi, SquiffyInitOptions } from './types.js';
2
- export type { SquiffyApi } from "./types.js";
3
- export declare const init: (options: SquiffyInitOptions) => SquiffyApi;
2
+ export type { SquiffyApi } from './types.js';
3
+ export declare const init: (options: SquiffyInitOptions) => Promise<SquiffyApi>;