squiffy-runtime 6.0.0-alpha.15 → 6.0.0-alpha.18
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/animation.d.ts +11 -0
- package/dist/events.d.ts +8 -3
- package/dist/import.d.ts +4 -0
- package/dist/linkHandler.d.ts +8 -0
- package/dist/pluginManager.d.ts +23 -0
- package/dist/squiffy.runtime.d.ts +2 -2
- package/dist/squiffy.runtime.global.js +126 -0
- package/dist/squiffy.runtime.global.js.map +1 -0
- package/dist/squiffy.runtime.js +8785 -487
- package/dist/squiffy.runtime.js.map +1 -0
- package/dist/state.d.ts +19 -0
- package/dist/textProcessor.d.ts +8 -13
- package/dist/types.d.ts +5 -2
- package/dist/types.plugins.d.ts +27 -0
- package/dist/updater.d.ts +2 -0
- package/dist/utils.d.ts +1 -2
- package/package.json +12 -5
- package/src/__snapshots__/squiffy.runtime.test.ts.snap +53 -19
- package/src/animation.ts +68 -0
- package/src/events.ts +9 -10
- package/src/import.ts +5 -0
- package/src/linkHandler.ts +18 -0
- package/src/pluginManager.ts +74 -0
- package/src/plugins/animate.ts +97 -0
- package/src/plugins/index.ts +13 -0
- package/src/plugins/live.ts +83 -0
- package/src/plugins/random.ts +22 -0
- package/src/plugins/replaceLabel.ts +22 -0
- package/src/plugins/rotateSequence.ts +61 -0
- package/src/squiffy.runtime.test.ts +306 -134
- package/src/squiffy.runtime.ts +460 -332
- package/src/state.ts +106 -0
- package/src/textProcessor.ts +61 -164
- package/src/types.plugins.ts +41 -0
- package/src/types.ts +5 -2
- package/src/updater.ts +77 -0
- package/src/utils.ts +15 -12
- package/vite.config.ts +36 -0
- package/vitest.config.ts +9 -0
- package/vitest.setup.ts +16 -0
- package/dist/events.js +0 -35
- package/dist/squiffy.runtime.test.js +0 -394
- package/dist/textProcessor.js +0 -166
- package/dist/types.js +0 -1
- 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:
|
|
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 {};
|
package/dist/import.d.ts
ADDED
|
@@ -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
|
|
3
|
-
export declare const init: (options: SquiffyInitOptions) => SquiffyApi
|
|
2
|
+
export type { SquiffyApi } from './types.js';
|
|
3
|
+
export declare const init: (options: SquiffyInitOptions) => Promise<SquiffyApi>;
|