squiffy-runtime 7.0.0-beta.1 → 7.0.0-beta.11
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/assets.d.ts +1 -0
- package/dist/classes.test.d.ts +1 -0
- package/dist/confirmDialog.d.ts +8 -0
- package/dist/events.d.ts +12 -0
- package/dist/every.d.ts +12 -0
- package/dist/every.test.d.ts +1 -0
- package/dist/helpers.test.d.ts +1 -0
- package/dist/numbers.d.ts +3 -0
- package/dist/panels.d.ts +14 -0
- package/dist/panels.test.d.ts +1 -0
- package/dist/paths.d.ts +15 -0
- package/dist/paths.test.d.ts +1 -0
- package/dist/persistent.test.d.ts +1 -0
- package/dist/playerSettings.d.ts +17 -0
- package/dist/preview-host.d.ts +7 -3
- package/dist/preview-host.js +47 -5
- package/dist/preview-host.js.map +2 -2
- package/dist/preview-html.js +1 -1
- package/dist/preview-protocol.d.ts +16 -0
- package/dist/preview.d.ts +1 -0
- package/dist/saveSlots.d.ts +16 -0
- package/dist/saves.test.d.ts +1 -0
- package/dist/savesDialog.d.ts +43 -0
- package/dist/savesDialog.test.d.ts +1 -0
- package/dist/scripts.test.d.ts +1 -0
- package/dist/settings.test.d.ts +1 -0
- package/dist/settingsDialog.d.ts +17 -0
- package/dist/skill.test.d.ts +1 -0
- package/dist/sound.d.ts +35 -0
- package/dist/sound.test.d.ts +1 -0
- package/dist/squiffy.page.css +155 -0
- package/dist/squiffy.preview.html +1469 -136
- package/dist/squiffy.runtime.css +1123 -20
- package/dist/squiffy.runtime.d.ts +13 -1
- package/dist/squiffy.runtime.global.js +144 -79
- package/dist/squiffy.runtime.global.js.map +1 -1
- package/dist/squiffy.runtime.js +6771 -4424
- package/dist/squiffy.runtime.js.map +1 -1
- package/dist/state.d.ts +17 -0
- package/dist/storyLists.d.ts +4 -0
- package/dist/storyLists.test.d.ts +1 -0
- package/dist/style.test.d.ts +1 -0
- package/dist/textProcessor.d.ts +27 -0
- package/dist/transitions.test.d.ts +1 -0
- package/dist/types.d.ts +125 -0
- package/dist/types.plugins.d.ts +1 -0
- package/dist/uiLinks.test.d.ts +1 -0
- package/dist/utils.d.ts +2 -1
- package/dist/utils.test.d.ts +1 -0
- package/package.json +11 -6
- package/src/__snapshots__/squiffy.runtime.test.ts.snap +22 -22
- package/src/animation.test.ts +44 -0
- package/src/animation.ts +9 -5
- package/src/assets.test.ts +1 -3
- package/src/assets.ts +1 -1
- package/src/classes.test.ts +201 -0
- package/src/confirmDialog.ts +66 -0
- package/src/events.ts +19 -0
- package/src/every.test.ts +25 -0
- package/src/every.ts +94 -0
- package/src/helpers.test.ts +34 -0
- package/src/numbers.ts +21 -0
- package/src/panels.test.ts +225 -0
- package/src/panels.ts +187 -0
- package/src/paths.test.ts +66 -0
- package/src/paths.ts +155 -0
- package/src/persistent.test.ts +155 -0
- package/src/playerSettings.ts +128 -0
- package/src/pluginManager.ts +1 -0
- package/src/plugins/animate.ts +28 -4
- package/src/plugins/live.ts +18 -5
- package/src/plugins/plugins.test.ts +93 -6
- package/src/plugins/replaceLabel.ts +7 -3
- package/src/preview-host.test.ts +97 -1
- package/src/preview-host.ts +71 -10
- package/src/preview-protocol.ts +25 -3
- package/src/preview.main.ts +1 -0
- package/src/preview.test.ts +203 -4
- package/src/preview.ts +178 -12
- package/src/saveSlots.ts +159 -0
- package/src/saves.test.ts +199 -0
- package/src/savesDialog.test.ts +290 -0
- package/src/savesDialog.ts +499 -0
- package/src/scripts.test.ts +130 -0
- package/src/settings.test.ts +233 -0
- package/src/settingsDialog.ts +160 -0
- package/src/skill.test.ts +67 -0
- package/src/sound.test.ts +273 -0
- package/src/sound.ts +207 -0
- package/src/squiffy.page.css +155 -0
- package/src/squiffy.runtime.css +1123 -20
- package/src/squiffy.runtime.test.ts +2806 -44
- package/src/squiffy.runtime.ts +1111 -64
- package/src/state.ts +172 -11
- package/src/storyLists.test.ts +134 -0
- package/src/storyLists.ts +57 -0
- package/src/style.test.ts +89 -0
- package/src/textProcessor.ts +739 -58
- package/src/transitions.test.ts +343 -0
- package/src/types.plugins.ts +3 -0
- package/src/types.ts +209 -1
- package/src/uiLinks.test.ts +156 -0
- package/src/updater.ts +26 -8
- package/src/utils.test.ts +60 -0
- package/src/utils.ts +46 -14
- package/vite.config.ts +3 -4
- package/vite.preview.config.ts +16 -5
- package/dist/infixExpressions.d.ts +0 -2
- package/src/infixExpressions.test.ts +0 -187
- package/src/infixExpressions.ts +0 -323
- /package/dist/{infixExpressions.test.d.ts → animation.test.d.ts} +0 -0
package/dist/state.d.ts
CHANGED
|
@@ -8,12 +8,29 @@ export declare class State {
|
|
|
8
8
|
emitter: Emitter<SquiffyEventMap>;
|
|
9
9
|
constructor(persist: boolean, storyId: string, onSet: (attribute: string, value: any) => void, emitter: Emitter<SquiffyEventMap>, onSetInternal?: (attribute: string, oldValue: any, newValue: any) => void);
|
|
10
10
|
private usePersistentStorage;
|
|
11
|
+
playerSettings: () => Record<string, unknown> | null;
|
|
12
|
+
persistentNames: () => string[];
|
|
13
|
+
persistentValues: Record<string, any>;
|
|
14
|
+
private persistentKey?;
|
|
15
|
+
initPersistent(key: string | undefined, values?: Record<string, unknown>): void;
|
|
16
|
+
isPersistent(attribute: string): boolean;
|
|
17
|
+
getPersistent(): Record<string, any>;
|
|
18
|
+
forget(names?: string[]): void;
|
|
19
|
+
private storePersistent;
|
|
20
|
+
private valuesFor;
|
|
21
|
+
readOnly: boolean;
|
|
11
22
|
set(attribute: string, value: any): void;
|
|
23
|
+
setAt(segments: string[], value: any): void;
|
|
12
24
|
setInternal(attribute: string, value: any, raiseEvents: boolean): void;
|
|
25
|
+
has(attribute: string): boolean;
|
|
13
26
|
get(attribute: string): any;
|
|
27
|
+
getAt(segments: string[]): any;
|
|
14
28
|
getStore(): Record<string, any>;
|
|
15
29
|
load(): void;
|
|
16
30
|
reset(): void;
|
|
17
31
|
setSeen(sectionName: string): void;
|
|
18
32
|
getSeen(sectionName: string): boolean;
|
|
33
|
+
getVisits(sectionName: string): number;
|
|
34
|
+
getLastVisited(sectionName: string): number;
|
|
35
|
+
private getVisitsFrom;
|
|
19
36
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Story, TagFilter } from './types.js';
|
|
2
|
+
export declare function listPassages(story: Story, sectionName: string | undefined, currentSection: string, filter?: TagFilter): string[];
|
|
3
|
+
export declare function listSections(story: Story, filter?: TagFilter): string[];
|
|
4
|
+
export declare function tagsOf(story: Story, name: string, currentSection: string): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/textProcessor.d.ts
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
import { default as Handlebars } from 'handlebars';
|
|
2
2
|
import { Section, Story } from './types.js';
|
|
3
3
|
import { State } from './state.js';
|
|
4
|
+
export declare const CLEAR_MARKER = "squiffy-clear";
|
|
5
|
+
export declare function afterClear(html: string): string | null;
|
|
4
6
|
export declare class TextProcessor {
|
|
5
7
|
getStory: () => Story;
|
|
6
8
|
state: State;
|
|
7
9
|
getCurrentSection: () => Section;
|
|
8
10
|
handlebars: typeof Handlebars;
|
|
9
11
|
constructor(story: () => Story, state: State, currentSection: () => Section);
|
|
12
|
+
strings: {
|
|
13
|
+
restart: string;
|
|
14
|
+
saves: string;
|
|
15
|
+
settings: string;
|
|
16
|
+
};
|
|
17
|
+
evaluate(expression: string): unknown;
|
|
18
|
+
goto: {
|
|
19
|
+
section: string;
|
|
20
|
+
after: number;
|
|
21
|
+
} | null;
|
|
22
|
+
deactivate: Set<string>;
|
|
23
|
+
stopEvery: boolean;
|
|
24
|
+
private scopes;
|
|
25
|
+
private embeddedText;
|
|
26
|
+
private get params();
|
|
27
|
+
private isParam;
|
|
28
|
+
hasAttribute(attribute: string): boolean;
|
|
29
|
+
getAttribute(attribute: string): any;
|
|
30
|
+
setAttribute(attribute: string, value: any): void;
|
|
31
|
+
private context;
|
|
32
|
+
private processing;
|
|
33
|
+
private positionKey;
|
|
34
|
+
private expressionCache;
|
|
35
|
+
private evaluated;
|
|
10
36
|
process(text: string, inline: boolean): string;
|
|
11
37
|
}
|
|
38
|
+
export declare function errorHtml(label: string, message: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -13,6 +13,18 @@ export interface SquiffyInitOptions {
|
|
|
13
13
|
* left alone. When not provided, paths are used as they are.
|
|
14
14
|
*/
|
|
15
15
|
resolveAssetUrl?: (path: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* The page's text, for a story in another language: squiffy.json's "strings", by the same
|
|
18
|
+
* names. Used for the text of {{restart}} and {{saves}} links (#452), and the dialogs they
|
|
19
|
+
* open when the page doesn't handle them itself. Anything left out is in English.
|
|
20
|
+
*/
|
|
21
|
+
strings?: Partial<Record<string, string>>;
|
|
22
|
+
/**
|
|
23
|
+
* The values of the story's persistent attributes (squiffy.json's "persistent", #539) to start
|
|
24
|
+
* with, in place of those kept in the browser: e.g. the CLI's --play carrying them from one run
|
|
25
|
+
* to the next. getPersistent() gives them back.
|
|
26
|
+
*/
|
|
27
|
+
persistent?: Record<string, unknown>;
|
|
16
28
|
}
|
|
17
29
|
export interface SquiffySettings {
|
|
18
30
|
scroll: string;
|
|
@@ -31,10 +43,43 @@ export interface SquiffyApi {
|
|
|
31
43
|
clickLink: (link: HTMLElement) => Promise<boolean>;
|
|
32
44
|
update: (story: Story) => void;
|
|
33
45
|
goBack: () => void;
|
|
46
|
+
canGoBack: () => boolean;
|
|
47
|
+
getSave: () => SavedGame;
|
|
48
|
+
loadSave: (save: SavedGame) => Promise<LoadSaveResult>;
|
|
49
|
+
renderPassage: (name: string) => string;
|
|
50
|
+
isMuted: () => boolean;
|
|
51
|
+
setMuted: (muted: boolean) => void;
|
|
52
|
+
usesSound: () => boolean;
|
|
53
|
+
getSettings: () => PlayerSetting[];
|
|
54
|
+
getSetting: (name: string) => SettingValue | null;
|
|
55
|
+
setSetting: (name: string, value: SettingValue) => void;
|
|
56
|
+
resetSettings: () => void;
|
|
57
|
+
getPersistent: () => Record<string, unknown>;
|
|
58
|
+
forget: (names?: string[]) => void;
|
|
59
|
+
dispose: () => void;
|
|
34
60
|
on<E extends keyof SquiffyEventMap>(event: E, handler: SquiffyEventHandler<E>): () => void;
|
|
35
61
|
off<E extends keyof SquiffyEventMap>(event: E, handler: SquiffyEventHandler<E>): void;
|
|
36
62
|
once<E extends keyof SquiffyEventMap>(event: E, handler: SquiffyEventHandler<E>): () => void;
|
|
37
63
|
}
|
|
64
|
+
export type SquiffyScriptEvent = "navigated" | "set" | "settingChanged";
|
|
65
|
+
export interface SquiffyScriptApi {
|
|
66
|
+
get: (attribute: string) => any;
|
|
67
|
+
set: (attribute: string, value: any) => void;
|
|
68
|
+
story: {
|
|
69
|
+
go: (section: string) => Promise<void>;
|
|
70
|
+
seen: (sectionOrPassage: string) => boolean;
|
|
71
|
+
visits: (sectionOrPassage: string) => number;
|
|
72
|
+
lastVisited: (sectionOrPassage: string) => number;
|
|
73
|
+
passages: (section?: string, filter?: TagFilter) => string[];
|
|
74
|
+
sections: (filter?: TagFilter) => string[];
|
|
75
|
+
tags: (name?: string) => string[];
|
|
76
|
+
};
|
|
77
|
+
getSetting: (name: string) => SettingValue | null;
|
|
78
|
+
element: HTMLElement;
|
|
79
|
+
on<E extends SquiffyScriptEvent>(event: E, handler: SquiffyEventHandler<E>): () => void;
|
|
80
|
+
off<E extends SquiffyScriptEvent>(event: E, handler: SquiffyEventHandler<E>): void;
|
|
81
|
+
once<E extends SquiffyScriptEvent>(event: E, handler: SquiffyEventHandler<E>): () => void;
|
|
82
|
+
}
|
|
38
83
|
interface SquiffyJsFunctionApi {
|
|
39
84
|
get: (attribute: string) => any;
|
|
40
85
|
set: (attribute: string, value: any) => void;
|
|
@@ -44,18 +89,73 @@ interface SquiffyJsFunctionApi {
|
|
|
44
89
|
story: {
|
|
45
90
|
go: (section: string) => void;
|
|
46
91
|
seen: (sectionOrPassage: string) => boolean;
|
|
92
|
+
visits: (sectionOrPassage: string) => number;
|
|
93
|
+
lastVisited: (sectionOrPassage: string) => number;
|
|
94
|
+
passages: (section?: string, filter?: TagFilter) => string[];
|
|
95
|
+
sections: (filter?: TagFilter) => string[];
|
|
96
|
+
tags: (name?: string) => string[];
|
|
47
97
|
};
|
|
48
98
|
}
|
|
99
|
+
export interface TagFilter {
|
|
100
|
+
tagged?: string | string[];
|
|
101
|
+
untagged?: string | string[];
|
|
102
|
+
}
|
|
49
103
|
export interface Story {
|
|
50
104
|
js: ((squiffy: SquiffyJsFunctionApi, get: (attribute: string) => any, set: (attribute: string, value: any) => void) => void)[];
|
|
51
105
|
start: string;
|
|
52
106
|
id?: string | null;
|
|
107
|
+
projectId?: string;
|
|
53
108
|
uiJsIndex?: number;
|
|
109
|
+
audio?: string[];
|
|
110
|
+
expressions?: boolean;
|
|
111
|
+
panels?: Panel[];
|
|
112
|
+
settings?: PlayerSetting[];
|
|
113
|
+
persistent?: string[];
|
|
54
114
|
sections: Record<string, Section>;
|
|
55
115
|
}
|
|
116
|
+
export declare const PANEL_ICONS: readonly ["bag", "person", "map", "help", "info", "list", "book", "star", "heart"];
|
|
117
|
+
export type PanelIcon = typeof PANEL_ICONS[number];
|
|
118
|
+
export interface Panel {
|
|
119
|
+
passage: string;
|
|
120
|
+
label: string;
|
|
121
|
+
position?: "side" | "button";
|
|
122
|
+
icon?: PanelIcon;
|
|
123
|
+
}
|
|
124
|
+
export type PlayerSetting = PlayerSettingBase & {
|
|
125
|
+
type: "toggle";
|
|
126
|
+
default?: boolean;
|
|
127
|
+
} | PlayerSettingBase & {
|
|
128
|
+
type: "list";
|
|
129
|
+
options: PlayerSettingOption[];
|
|
130
|
+
default?: string;
|
|
131
|
+
} | PlayerSettingBase & {
|
|
132
|
+
type: "range";
|
|
133
|
+
min: number;
|
|
134
|
+
max: number;
|
|
135
|
+
step?: number;
|
|
136
|
+
default?: number;
|
|
137
|
+
};
|
|
138
|
+
interface PlayerSettingBase {
|
|
139
|
+
name: string;
|
|
140
|
+
label: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface PlayerSettingOption {
|
|
144
|
+
value: string;
|
|
145
|
+
label: string;
|
|
146
|
+
}
|
|
147
|
+
export type SettingValue = boolean | string | number;
|
|
56
148
|
export interface Section {
|
|
57
149
|
text?: string;
|
|
58
150
|
clear?: boolean;
|
|
151
|
+
music?: string | null;
|
|
152
|
+
sounds?: string[];
|
|
153
|
+
classes?: string[];
|
|
154
|
+
tags?: string[];
|
|
155
|
+
transition?: string;
|
|
156
|
+
transitionTime?: number;
|
|
157
|
+
leave?: string;
|
|
158
|
+
leaveTime?: number;
|
|
59
159
|
attributes?: string[];
|
|
60
160
|
jsIndex?: number;
|
|
61
161
|
passages?: Record<string, Passage>;
|
|
@@ -64,7 +164,32 @@ export interface Section {
|
|
|
64
164
|
export interface Passage {
|
|
65
165
|
text?: string;
|
|
66
166
|
clear?: boolean;
|
|
167
|
+
music?: string | null;
|
|
168
|
+
sounds?: string[];
|
|
169
|
+
classes?: string[];
|
|
170
|
+
tags?: string[];
|
|
171
|
+
transition?: string;
|
|
172
|
+
transitionTime?: number;
|
|
173
|
+
leave?: string;
|
|
174
|
+
leaveTime?: number;
|
|
175
|
+
repeat?: boolean;
|
|
67
176
|
attributes?: string[];
|
|
68
177
|
jsIndex?: number;
|
|
69
178
|
}
|
|
179
|
+
export interface SavedGame {
|
|
180
|
+
format: "squiffy-save";
|
|
181
|
+
version: 1;
|
|
182
|
+
storyId: string | null;
|
|
183
|
+
section: string | null;
|
|
184
|
+
passage: string | null;
|
|
185
|
+
summary: string;
|
|
186
|
+
savedAt: string;
|
|
187
|
+
state: Record<string, unknown>;
|
|
188
|
+
}
|
|
189
|
+
export type LoadSaveResult = {
|
|
190
|
+
success: true;
|
|
191
|
+
} | {
|
|
192
|
+
success: false;
|
|
193
|
+
error: "notASave" | "wrongStory";
|
|
194
|
+
};
|
|
70
195
|
export {};
|
package/dist/types.plugins.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface PluginHost {
|
|
|
21
21
|
processText: (text: string, inline: boolean) => string;
|
|
22
22
|
resolveAssetsInHtml: (html: string) => string;
|
|
23
23
|
addTransition: (fn: () => Promise<void>) => void;
|
|
24
|
+
written: (el: HTMLElement) => void;
|
|
24
25
|
animation: Animation;
|
|
25
26
|
on<E extends keyof SquiffyEventMap>(event: E, handler: SquiffyEventHandler<E>): () => void;
|
|
26
27
|
off<E extends keyof SquiffyEventMap>(event: E, handler: SquiffyEventHandler<E>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare function fadeReplace(element: HTMLElement, text: string): Promise<void>;
|
|
1
|
+
export declare function fadeReplace(element: HTMLElement, text: string, written?: (el: HTMLElement) => void): Promise<void>;
|
|
2
|
+
export declare function parseDelay(value: unknown): number | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squiffy-runtime",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.11",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/textadventures/squiffy.git",
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"./squiffy.runtime.css": "./dist/squiffy.runtime.css",
|
|
18
18
|
"./dist/squiffy.runtime.global.js": "./dist/squiffy.runtime.global.js",
|
|
19
19
|
"./dist/squiffy.runtime.css": "./dist/squiffy.runtime.css",
|
|
20
|
+
"./squiffy.page.css": "./dist/squiffy.page.css",
|
|
21
|
+
"./dist/squiffy.page.css": "./dist/squiffy.page.css",
|
|
20
22
|
"./preview-host": {
|
|
21
23
|
"types": "./dist/preview-host.d.ts",
|
|
22
24
|
"default": "./dist/preview-host.js"
|
|
@@ -46,16 +48,19 @@
|
|
|
46
48
|
"css.escape": "^1.5.1",
|
|
47
49
|
"esbuild": "^0.28.2",
|
|
48
50
|
"global-jsdom": "^31.0.0",
|
|
49
|
-
"jsdom": "^31.0.
|
|
50
|
-
"squiffy-compiler": "^7.0.0-beta.
|
|
51
|
+
"jsdom": "^31.0.1",
|
|
52
|
+
"squiffy-compiler": "^7.0.0-beta.11",
|
|
51
53
|
"typescript": "^6.0.3",
|
|
52
|
-
"vite": "^8.3.
|
|
54
|
+
"vite": "^8.3.8",
|
|
53
55
|
"vite-plugin-dts": "^5.1.2"
|
|
54
56
|
},
|
|
55
57
|
"dependencies": {
|
|
56
58
|
"animejs": "^4.5.0",
|
|
57
59
|
"handlebars": "^4.7.10",
|
|
58
|
-
"marked": "^18.
|
|
60
|
+
"marked": "^18.2.0"
|
|
59
61
|
},
|
|
60
|
-
"
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"timeout": 60000
|
|
64
|
+
},
|
|
65
|
+
"gitHead": "9a48f5a597ef295d90aa5371e1f06f297547df85"
|
|
61
66
|
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`"Hello world" script should run 1`] = `
|
|
4
4
|
"
|
|
5
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div></div>"
|
|
5
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div></div>"
|
|
6
6
|
`;
|
|
7
7
|
|
|
8
8
|
exports[`Click a passage link 1`] = `
|
|
9
9
|
"
|
|
10
|
-
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
10
|
+
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
11
11
|
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
12
12
|
<p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
13
13
|
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
@@ -19,21 +19,21 @@ exports[`Click a passage link 1`] = `
|
|
|
19
19
|
|
|
20
20
|
exports[`Click a passage link 2`] = `
|
|
21
21
|
"
|
|
22
|
-
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
22
|
+
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
23
23
|
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
24
|
-
<p>This should be <a class="squiffy-link link-passage disabled" data-passage="passage" role="link" tabindex="-1">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
24
|
+
<p>This should be <a class="squiffy-link link-passage disabled" data-passage="passage" role="link" tabindex="-1" data-clicked="1">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
25
25
|
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
26
26
|
<p>And this goes to the <a class="squiffy-link link-section" data-section="section2" role="link" tabindex="0">next section</a>.</p>
|
|
27
27
|
<p>This line has links to <a class="squiffy-link link-section" data-section="section 3" role="link" tabindex="0">section 3</a> and <a class="squiffy-link link-section" data-section="section four" role="link" tabindex="0">section 4</a>.</p>
|
|
28
28
|
<p>This line has links to <a class="squiffy-link link-passage" data-passage="passage 3" role="link" tabindex="0">passage 3</a> and <a class="squiffy-link link-passage" data-passage="passage four" role="link" tabindex="0">passage 4</a>.</p>
|
|
29
|
-
<p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div><div class="squiffy-output-passage" data-passage="passage" data-undo="{"_turncount":0,"_seen_sections":["Introduction"]}"><div class="squiffy-output-block"><div data-source="[[Introduction]][passage]"><p>Here's some text for the passage.</p>
|
|
29
|
+
<p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div><div class="squiffy-output-passage" data-passage="passage" data-clicked-link="1" data-undo="{"turns":0,"_turncount":0,"previous":null,"_passage":null,"_visits":{"Introduction":1},"_lastvisit":{"Introduction":0},"_seen_sections":["Introduction"]}"><div class="squiffy-output-block"><div data-source="[[Introduction]][passage]"><p>Here's some text for the passage.</p>
|
|
30
30
|
<p>This passage has a picture in it. It's by <a href="https://unsplash.com/@lmablankers?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Lars Blankers</a> on <a href="https://unsplash.com/photos/brown-potato-lot-B0s3Xndk6tw?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>.</p>
|
|
31
31
|
<p><img src="lars-blankers-B0s3Xndk6tw-unsplash.jpg" alt=""></p></div></div></div></div></div>"
|
|
32
32
|
`;
|
|
33
33
|
|
|
34
34
|
exports[`Click a passage link and go back 1`] = `
|
|
35
35
|
"
|
|
36
|
-
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
36
|
+
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
37
37
|
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
38
38
|
<p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
39
39
|
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
@@ -45,7 +45,7 @@ exports[`Click a passage link and go back 1`] = `
|
|
|
45
45
|
|
|
46
46
|
exports[`Click a section link 1`] = `
|
|
47
47
|
"
|
|
48
|
-
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
48
|
+
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
49
49
|
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
50
50
|
<p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
51
51
|
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
@@ -57,19 +57,19 @@ exports[`Click a section link 1`] = `
|
|
|
57
57
|
|
|
58
58
|
exports[`Click a section link 2`] = `
|
|
59
59
|
"
|
|
60
|
-
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
60
|
+
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
61
61
|
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
62
62
|
<p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
63
63
|
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
64
64
|
<p>And this goes to the <a class="squiffy-link link-section" data-section="section2" role="link" tabindex="0">next section</a>.</p>
|
|
65
65
|
<p>This line has links to <a class="squiffy-link link-section" data-section="section 3" role="link" tabindex="0">section 3</a> and <a class="squiffy-link link-section" data-section="section four" role="link" tabindex="0">section 4</a>.</p>
|
|
66
66
|
<p>This line has links to <a class="squiffy-link link-passage" data-passage="passage 3" role="link" tabindex="0">passage 3</a> and <a class="squiffy-link link-passage" data-passage="passage four" role="link" tabindex="0">passage 4</a>.</p>
|
|
67
|
-
<p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div></div><div class="squiffy-output-section" data-section="section 3" data-undo="{"_section":"Introduction","_seen_sections":["Introduction"],"_turncount":0}"><div class="squiffy-output-block"><div data-source="[[section 3]]"><p>Another section is here, with passages <a class="squiffy-link link-passage" data-passage="a" role="link" tabindex="0">a</a> and <a class="squiffy-link link-passage" data-passage="b" role="link" tabindex="0">b</a>.</p></div></div></div></div>"
|
|
67
|
+
<p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div></div><div class="squiffy-output-section" data-section="section 3" data-undo="{"turns":0,"previous":null,"previous_section":null,"_section":"Introduction","_visits":{"Introduction":1},"_lastvisit":{"Introduction":0},"_seen_sections":["Introduction"],"_turncount":0}"><div class="squiffy-output-block"><div data-source="[[section 3]]"><p>Another section is here, with passages <a class="squiffy-link link-passage" data-passage="a" role="link" tabindex="0">a</a> and <a class="squiffy-link link-passage" data-passage="b" role="link" tabindex="0">b</a>.</p></div></div></div></div>"
|
|
68
68
|
`;
|
|
69
69
|
|
|
70
70
|
exports[`Click a section link and go back 1`] = `
|
|
71
71
|
"
|
|
72
|
-
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
72
|
+
<div><div class="squiffy-output-section" data-section="Introduction" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
73
73
|
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
74
74
|
<p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
75
75
|
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
@@ -81,60 +81,60 @@ exports[`Click a section link and go back 1`] = `
|
|
|
81
81
|
|
|
82
82
|
exports[`Delete passage 1`] = `
|
|
83
83
|
"
|
|
84
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-undo="{"_turncount":0,"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>New passage</p></div></div></div></div></div>"
|
|
84
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1" data-clicked="1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-clicked-link="1" data-undo="{"turns":0,"_turncount":0,"previous":null,"_passage":null,"_visits":{"_default":1},"_lastvisit":{"_default":0},"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>New passage</p></div></div></div></div></div>"
|
|
85
85
|
`;
|
|
86
86
|
|
|
87
87
|
exports[`Delete passage 2`] = `
|
|
88
88
|
"
|
|
89
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div></div></div>"
|
|
89
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1" data-clicked="1">a</a></p></div></div></div></div>"
|
|
90
90
|
`;
|
|
91
91
|
|
|
92
92
|
exports[`Delete section 1`] = `
|
|
93
93
|
"
|
|
94
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div><div class="squiffy-output-section" data-section="a" data-undo="{"_section":"_default","_seen_sections":["_default"],"_turncount":0}"><div class="squiffy-output-block"><div data-source="[[a]]"><p>New section</p></div></div></div></div>"
|
|
94
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div><div class="squiffy-output-section" data-section="a" data-undo="{"turns":0,"previous":null,"previous_section":null,"_section":"_default","_visits":{"_default":1},"_lastvisit":{"_default":0},"_seen_sections":["_default"],"_turncount":0}"><div class="squiffy-output-block"><div data-source="[[a]]"><p>New section</p></div></div></div></div>"
|
|
95
95
|
`;
|
|
96
96
|
|
|
97
97
|
exports[`Delete section 2`] = `
|
|
98
98
|
"
|
|
99
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div></div>"
|
|
99
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div></div>"
|
|
100
100
|
`;
|
|
101
101
|
|
|
102
102
|
exports[`Going back handling @clear and attribute changes 1`] = `
|
|
103
103
|
"
|
|
104
|
-
<div><div class="squiffy-clear-stack" style="display: none;"><div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Choose: <a class="squiffy-link link-passage" data-passage="a" role="link">a</a>, <a class="squiffy-link link-passage disabled" data-passage="b" role="link" tabindex="-1">b</a></p></div></div><div class="squiffy-output-passage" data-passage="b" data-undo="{"_turncount":0,"_seen_sections":["_default"],"test":null}"><div class="squiffy-output-block"><div data-source="[[_default]][b]"><p>You chose b. Now <a class="squiffy-link link-section" data-section="continue" role="link" tabindex="0">continue</a></p></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-undo="{"_section":"_default","_seen_sections":["_default","b"],"test":456,"_turncount":1}"><div class="squiffy-output-block"><div data-source="[[continue]]"><p>Now choose: <a class="squiffy-link link-passage disabled" data-passage="c" role="link" tabindex="-1">c</a>, <a class="squiffy-link link-passage" data-passage="d" role="link" tabindex="0">d</a></p></div></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-clear="true"><div class="squiffy-output-passage" data-passage="c" data-undo="{"_turncount":0,"_seen_sections":["_default","b","continue"],"test":789}"><div class="squiffy-output-block"><div data-source="[[continue]][c]"><p>You chose c. Now <a class="squiffy-link link-section" data-section="finish" role="link" tabindex="0">finish</a></p></div></div></div></div></div>"
|
|
104
|
+
<div><div class="squiffy-clear-stack" style="display: none;"><div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Choose: <a class="squiffy-link link-passage" data-passage="a" role="link">a</a>, <a class="squiffy-link link-passage disabled" data-passage="b" role="link" tabindex="-1" data-clicked="1">b</a></p></div></div><div class="squiffy-output-passage" data-passage="b" data-clicked-link="1" data-undo="{"turns":0,"_turncount":0,"previous":null,"_passage":null,"_visits":{"_default":1},"_lastvisit":{"_default":0},"_seen_sections":["_default"],"test":null}"><div class="squiffy-output-block"><div data-source="[[_default]][b]"><p>You chose b. Now <a class="squiffy-link link-section" data-section="continue" role="link" tabindex="0">continue</a></p></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-undo="{"turns":1,"previous":"_default","previous_section":null,"_passage":"b","_section":"_default","_visits":{"_default":1,"b":1},"_lastvisit":{"_default":0,"b":1},"_seen_sections":["_default","b"],"test":456,"_turncount":1}"><div class="squiffy-output-block"><div data-source="[[continue]]"><p>Now choose: <a class="squiffy-link link-passage disabled" data-passage="c" role="link" tabindex="-1" data-clicked="2">c</a>, <a class="squiffy-link link-passage" data-passage="d" role="link" tabindex="0">d</a></p></div></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-clear="true"><div class="squiffy-output-passage" data-passage="c" data-clicked-link="2" data-undo="{"turns":2,"_turncount":0,"previous":"b","_passage":null,"_visits":{"_default":1,"b":1,"continue":1},"_lastvisit":{"_default":0,"b":1,"continue":2},"_seen_sections":["_default","b","continue"],"test":789}"><div class="squiffy-output-block"><div data-source="[[continue]][c]"><p>You chose c. Now <a class="squiffy-link link-section" data-section="finish" role="link" tabindex="0">finish</a></p></div></div></div></div></div>"
|
|
105
105
|
`;
|
|
106
106
|
|
|
107
107
|
exports[`Going back handling @clear and attribute changes 2`] = `
|
|
108
108
|
"
|
|
109
|
-
<div><div class="squiffy-clear-stack" style="display: none;"></div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Choose: <a class="squiffy-link link-passage" data-passage="a" role="link">a</a>, <a class="squiffy-link link-passage disabled" data-passage="b" role="link" tabindex="-1">b</a></p></div></div><div class="squiffy-output-passage" data-passage="b" data-undo="{"_turncount":0,"_seen_sections":["_default"],"test":null}"><div class="squiffy-output-block"><div data-source="[[_default]][b]"><p>You chose b. Now <a class="squiffy-link link-section" data-section="continue" role="link" tabindex="0">continue</a></p></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-undo="{"_section":"_default","_seen_sections":["_default","b"],"test":456,"_turncount":1}"><div class="squiffy-output-block"><div data-source="[[continue]]"><p>Now choose: <a class="squiffy-link link-passage" data-passage="c" role="link">c</a>, <a class="squiffy-link link-passage" data-passage="d" role="link" tabindex="0">d</a></p></div></div></div></div>"
|
|
109
|
+
<div><div class="squiffy-clear-stack" style="display: none;"></div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Choose: <a class="squiffy-link link-passage" data-passage="a" role="link">a</a>, <a class="squiffy-link link-passage disabled" data-passage="b" role="link" tabindex="-1" data-clicked="1">b</a></p></div></div><div class="squiffy-output-passage" data-passage="b" data-clicked-link="1" data-undo="{"turns":0,"_turncount":0,"previous":null,"_passage":null,"_visits":{"_default":1},"_lastvisit":{"_default":0},"_seen_sections":["_default"],"test":null}"><div class="squiffy-output-block"><div data-source="[[_default]][b]"><p>You chose b. Now <a class="squiffy-link link-section" data-section="continue" role="link" tabindex="0">continue</a></p></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-undo="{"turns":1,"previous":"_default","previous_section":null,"_passage":"b","_section":"_default","_visits":{"_default":1,"b":1},"_lastvisit":{"_default":0,"b":1},"_seen_sections":["_default","b"],"test":456,"_turncount":1}"><div class="squiffy-output-block"><div data-source="[[continue]]"><p>Now choose: <a class="squiffy-link link-passage" data-passage="c" role="link">c</a>, <a class="squiffy-link link-passage" data-passage="d" role="link" tabindex="0">d</a></p></div></div></div></div>"
|
|
110
110
|
`;
|
|
111
111
|
|
|
112
112
|
exports[`Update default section output 1`] = `
|
|
113
113
|
"
|
|
114
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div></div>"
|
|
114
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div></div>"
|
|
115
115
|
`;
|
|
116
116
|
|
|
117
117
|
exports[`Update default section output 2`] = `
|
|
118
118
|
"
|
|
119
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Updated content</p></div></div></div></div>"
|
|
119
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Updated content</p></div></div></div></div>"
|
|
120
120
|
`;
|
|
121
121
|
|
|
122
122
|
exports[`Update passage output - passage name "a" 1`] = `
|
|
123
123
|
"
|
|
124
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-undo="{"_turncount":0,"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Passage a content</p></div></div></div></div></div>"
|
|
124
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1" data-clicked="1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-clicked-link="1" data-undo="{"turns":0,"_turncount":0,"previous":null,"_passage":null,"_visits":{"_default":1},"_lastvisit":{"_default":0},"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Passage a content</p></div></div></div></div></div>"
|
|
125
125
|
`;
|
|
126
126
|
|
|
127
127
|
exports[`Update passage output - passage name "a" 2`] = `
|
|
128
128
|
"
|
|
129
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-undo="{"_turncount":0,"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Updated passage content</p></div></div></div></div></div>"
|
|
129
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1" data-clicked="1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-clicked-link="1" data-undo="{"turns":0,"_turncount":0,"previous":null,"_passage":null,"_visits":{"_default":1},"_lastvisit":{"_default":0},"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Updated passage content</p></div></div></div></div></div>"
|
|
130
130
|
`;
|
|
131
131
|
|
|
132
132
|
exports[`Update passage output - passage name "a'1" 1`] = `
|
|
133
133
|
"
|
|
134
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1">a'1</a></p></div></div><div class="squiffy-output-passage" data-passage="a'1" data-undo="{"_turncount":0,"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Passage a content</p></div></div></div></div></div>"
|
|
134
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1" data-clicked="1">a'1</a></p></div></div><div class="squiffy-output-passage" data-passage="a'1" data-clicked-link="1" data-undo="{"turns":0,"_turncount":0,"previous":null,"_passage":null,"_visits":{"_default":1},"_lastvisit":{"_default":0},"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Passage a content</p></div></div></div></div></div>"
|
|
135
135
|
`;
|
|
136
136
|
|
|
137
137
|
exports[`Update passage output - passage name "a'1" 2`] = `
|
|
138
138
|
"
|
|
139
|
-
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1">a'1</a></p></div></div><div class="squiffy-output-passage" data-passage="a'1" data-undo="{"_turncount":0,"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Updated passage content</p></div></div></div></div></div>"
|
|
139
|
+
<div><div class="squiffy-output-section" data-section="_default" data-undo="{"_section":null,"_visits":null,"_lastvisit":null,"_seen_sections":null,"_turncount":null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1" data-clicked="1">a'1</a></p></div></div><div class="squiffy-output-passage" data-passage="a'1" data-clicked-link="1" data-undo="{"turns":0,"_turncount":0,"previous":null,"_passage":null,"_visits":{"_default":1},"_lastvisit":{"_default":0},"_seen_sections":["_default"]}"><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Updated passage content</p></div></div></div></div></div>"
|
|
140
140
|
`;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The built-in animations in animation.ts
|
|
2
|
+
import { afterAll, beforeAll, expect, test } from "vitest";
|
|
3
|
+
import globalJsdom from "global-jsdom";
|
|
4
|
+
import type { Animation as AnimationClass } from "./animation.js";
|
|
5
|
+
|
|
6
|
+
let cleanup: () => void;
|
|
7
|
+
let Animation: typeof AnimationClass;
|
|
8
|
+
|
|
9
|
+
// anime.js keeps the document it finds when it's first imported, so there's one DOM for the
|
|
10
|
+
// whole file, made before it's imported
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
cleanup = globalJsdom("<!DOCTYPE html><html><body></body></html>");
|
|
13
|
+
// jsdom has no ResizeObserver or document.fonts, which anime.js's splitText uses to split text
|
|
14
|
+
// into lines again when it's resized, and once the fonts have loaded
|
|
15
|
+
(globalThis as any).ResizeObserver ??= class { observe() {} unobserve() {} disconnect() {} };
|
|
16
|
+
Object.defineProperty(document, "fonts", { value: { status: "loaded", ready: Promise.resolve() } });
|
|
17
|
+
({ Animation } = await import("./animation.js"));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterAll(() => {
|
|
21
|
+
cleanup();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// The characters the animation split the text into, grouped by the element that holds them
|
|
25
|
+
const charsByParent = (el: HTMLElement) => {
|
|
26
|
+
const groups = new Map<Element, string>();
|
|
27
|
+
for (const char of el.querySelectorAll("[data-char]")) {
|
|
28
|
+
groups.set(char.parentElement!, (groups.get(char.parentElement!) ?? "") + char.textContent);
|
|
29
|
+
}
|
|
30
|
+
return [...groups.values()];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
test.each([
|
|
34
|
+
["typewriter", {}],
|
|
35
|
+
["continue", { style: "wave" }],
|
|
36
|
+
])("%s keeps each word's characters together, so a line can't break inside a word", (name, params) => {
|
|
37
|
+
const el = document.createElement("span");
|
|
38
|
+
el.textContent = "Now, let's spin...";
|
|
39
|
+
document.body.appendChild(el);
|
|
40
|
+
|
|
41
|
+
new Animation().runAnimation(name, el, params, () => {}, false);
|
|
42
|
+
|
|
43
|
+
expect(charsByParent(el)).toEqual(["Now,", "let's", "spin..."]);
|
|
44
|
+
});
|
package/src/animation.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { animate,
|
|
1
|
+
import { animate, splitText, stagger } from "animejs";
|
|
2
2
|
|
|
3
3
|
export type AnimationHandler = (el: HTMLElement, params: Record<string, any>, onComplete: () => void, loop: boolean) => void;
|
|
4
4
|
|
|
@@ -50,7 +50,10 @@ export class Animation {
|
|
|
50
50
|
|
|
51
51
|
constructor() {
|
|
52
52
|
this.registerAnimation("typewriter", function(el, params, onComplete, loop) {
|
|
53
|
-
|
|
53
|
+
// Each character in a span, inside a span for its word, so a line only breaks
|
|
54
|
+
// between words: without the words, it could break anywhere, e.g. at the
|
|
55
|
+
// apostrophe in "let's"
|
|
56
|
+
const { chars } = splitText(el, { words: true, chars: true });
|
|
54
57
|
|
|
55
58
|
const fadeDuration = params.fadeDuration || 100; // ms fade-in per character
|
|
56
59
|
const interval = params.interval || 100; // ms between each character appearing
|
|
@@ -66,7 +69,7 @@ export class Animation {
|
|
|
66
69
|
}, { initiallyHidden: true });
|
|
67
70
|
|
|
68
71
|
this.registerAnimation("toast", function(el, params, onComplete, loop) {
|
|
69
|
-
const { words } =
|
|
72
|
+
const { words } = splitText(el, { words: true, chars: false });
|
|
70
73
|
|
|
71
74
|
const fadeDuration = params.fadeDuration || 100; // ms fade-in per word
|
|
72
75
|
const interval = params.interval || 200; // ms between each word appearing
|
|
@@ -106,9 +109,10 @@ export class Animation {
|
|
|
106
109
|
let chars: HTMLElement[] | null = null;
|
|
107
110
|
|
|
108
111
|
if (style === "wave") {
|
|
109
|
-
// Wave style needs JS animation - split into chars and animate opacity
|
|
112
|
+
// Wave style needs JS animation - split into chars and animate opacity. Words too,
|
|
113
|
+
// so a line only breaks between words, as with typewriter.
|
|
110
114
|
el.classList.add("squiffy-continue-wave");
|
|
111
|
-
const split =
|
|
115
|
+
const split = splitText(el, { words: true, chars: true });
|
|
112
116
|
chars = split.chars as HTMLElement[];
|
|
113
117
|
|
|
114
118
|
waveAnimation = animate(chars, {
|