squiffy-runtime 7.0.0-beta.6 → 7.0.0-beta.8

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 (80) hide show
  1. package/dist/assets.d.ts +1 -0
  2. package/dist/classes.test.d.ts +1 -0
  3. package/dist/confirmDialog.d.ts +8 -0
  4. package/dist/events.d.ts +11 -0
  5. package/dist/every.d.ts +12 -0
  6. package/dist/every.test.d.ts +1 -0
  7. package/dist/paths.d.ts +15 -0
  8. package/dist/paths.test.d.ts +1 -0
  9. package/dist/playerSettings.d.ts +17 -0
  10. package/dist/preview-host.d.ts +2 -0
  11. package/dist/preview-host.js +10 -0
  12. package/dist/preview-host.js.map +2 -2
  13. package/dist/preview-html.js +1 -1
  14. package/dist/preview-protocol.d.ts +6 -0
  15. package/dist/settings.test.d.ts +1 -0
  16. package/dist/settingsDialog.d.ts +17 -0
  17. package/dist/skill.test.d.ts +1 -0
  18. package/dist/sound.d.ts +35 -0
  19. package/dist/sound.test.d.ts +1 -0
  20. package/dist/squiffy.page.css +14 -3
  21. package/dist/squiffy.preview.html +680 -82
  22. package/dist/squiffy.runtime.css +531 -1
  23. package/dist/squiffy.runtime.d.ts +5 -1
  24. package/dist/squiffy.runtime.global.js +117 -96
  25. package/dist/squiffy.runtime.global.js.map +1 -1
  26. package/dist/squiffy.runtime.js +5728 -4520
  27. package/dist/squiffy.runtime.js.map +1 -1
  28. package/dist/state.d.ts +4 -1
  29. package/dist/style.test.d.ts +1 -0
  30. package/dist/textProcessor.d.ts +16 -0
  31. package/dist/transitions.test.d.ts +1 -0
  32. package/dist/types.d.ts +54 -0
  33. package/dist/uiLinks.test.d.ts +1 -0
  34. package/dist/utils.d.ts +1 -0
  35. package/dist/utils.test.d.ts +1 -0
  36. package/package.json +3 -3
  37. package/src/__snapshots__/squiffy.runtime.test.ts.snap +10 -10
  38. package/src/animation.test.ts +44 -0
  39. package/src/animation.ts +9 -5
  40. package/src/assets.test.ts +1 -3
  41. package/src/assets.ts +1 -1
  42. package/src/classes.test.ts +201 -0
  43. package/src/confirmDialog.ts +66 -0
  44. package/src/events.ts +18 -0
  45. package/src/every.test.ts +25 -0
  46. package/src/every.ts +94 -0
  47. package/src/panels.test.ts +24 -0
  48. package/src/paths.test.ts +66 -0
  49. package/src/paths.ts +155 -0
  50. package/src/playerSettings.ts +128 -0
  51. package/src/plugins/animate.ts +16 -3
  52. package/src/plugins/live.ts +10 -4
  53. package/src/plugins/plugins.test.ts +51 -6
  54. package/src/preview-host.test.ts +22 -0
  55. package/src/preview-host.ts +15 -0
  56. package/src/preview-protocol.ts +9 -1
  57. package/src/preview.test.ts +114 -3
  58. package/src/preview.ts +97 -3
  59. package/src/settings.test.ts +233 -0
  60. package/src/settingsDialog.ts +160 -0
  61. package/src/skill.test.ts +67 -0
  62. package/src/sound.test.ts +273 -0
  63. package/src/sound.ts +207 -0
  64. package/src/squiffy.page.css +14 -3
  65. package/src/squiffy.runtime.css +531 -1
  66. package/src/squiffy.runtime.test.ts +1130 -17
  67. package/src/squiffy.runtime.ts +600 -38
  68. package/src/state.ts +45 -10
  69. package/src/style.test.ts +89 -0
  70. package/src/textProcessor.ts +484 -35
  71. package/src/transitions.test.ts +302 -0
  72. package/src/types.ts +79 -0
  73. package/src/uiLinks.test.ts +156 -0
  74. package/src/updater.ts +26 -8
  75. package/src/utils.test.ts +60 -0
  76. package/src/utils.ts +44 -14
  77. package/dist/infixExpressions.d.ts +0 -6
  78. package/src/infixExpressions.test.ts +0 -379
  79. package/src/infixExpressions.ts +0 -488
  80. /package/dist/{infixExpressions.test.d.ts → animation.test.d.ts} +0 -0
@@ -29,6 +29,9 @@ export type HostMessage = {
29
29
  } | {
30
30
  type: "theme";
31
31
  theme: PreviewTheme;
32
+ } | {
33
+ type: "muted";
34
+ muted: boolean;
32
35
  };
33
36
  export type PreviewMessage = {
34
37
  type: "ready";
@@ -44,6 +47,9 @@ export type PreviewMessage = {
44
47
  } | {
45
48
  type: "canGoBackChanged";
46
49
  canGoBack: boolean;
50
+ } | {
51
+ type: "usesSound";
52
+ usesSound: boolean;
47
53
  } | {
48
54
  type: "navigated";
49
55
  section: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { SquiffyApi } from './types.js';
2
+ export declare const SETTINGS_STRINGS: {
3
+ settings: string;
4
+ resetSettings: string;
5
+ close: string;
6
+ };
7
+ export interface SettingsDialogOptions {
8
+ strings?: Partial<Record<string, string>>;
9
+ container?: HTMLElement;
10
+ }
11
+ export interface SettingsDialog {
12
+ element: HTMLDialogElement;
13
+ open: () => void;
14
+ close: () => void;
15
+ }
16
+ export declare const SETTINGS_ICON = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z\"/><circle cx=\"12\" cy=\"12\" r=\"3\"/></svg>";
17
+ export declare function createSettingsDialog(api: SquiffyApi, options?: SettingsDialogOptions): SettingsDialog;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ export type AudioUrlResolver = (path: string) => string;
2
+ export interface SoundOptions {
3
+ resolveUrl: AudioUrlResolver;
4
+ getMusic: () => string | null;
5
+ mutedKey?: string;
6
+ onPlay?: () => void;
7
+ }
8
+ export declare const DEFAULT_FADE = 1;
9
+ export declare class Sound {
10
+ private options;
11
+ private music;
12
+ private effects;
13
+ private preloaded;
14
+ private muted;
15
+ private waitingForGesture;
16
+ private disposed;
17
+ constructor(options: SoundOptions);
18
+ preload(files: string[]): void;
19
+ sync(fade?: number): void;
20
+ play(file: string, volume?: number): void;
21
+ stopSounds(): void;
22
+ isMuted(): boolean;
23
+ setMuted(muted: boolean): void;
24
+ dispose(): void;
25
+ private newAudio;
26
+ private startMusic;
27
+ private playTrack;
28
+ private stopMusic;
29
+ private fade;
30
+ private readonly onGesture;
31
+ private waitForGesture;
32
+ private removeGestureListeners;
33
+ private readMuted;
34
+ private writeMuted;
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -4,8 +4,8 @@
4
4
  {
5
5
  /* The width of the story text */
6
6
  --squiffy-max-width: 42rem;
7
- /* The story's font. Charter, Sitka Text, Cambria or Georgia, whichever the reader has */
8
- --squiffy-font-family: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
7
+ /* The story's font. Charter, or Georgia if the reader doesn't have it */
8
+ --squiffy-font-family: Charter, "Bitstream Charter", Georgia, serif;
9
9
  /* The size of the story text. The header's buttons are smaller, and don't change with it */
10
10
  --squiffy-font-size: 1.125rem;
11
11
  /* The space between lines of text */
@@ -90,6 +90,14 @@ button#squiffy-theme[data-next="light"] .squiffy-icon-dark
90
90
  display: none;
91
91
  }
92
92
 
93
+ /* The mute button (#444), for a story with music or sounds. It shows a speaker, crossed out
94
+ when the story is muted. */
95
+ button#squiffy-mute.squiffy-muted .squiffy-icon-sound,
96
+ button#squiffy-mute:not(.squiffy-muted) .squiffy-icon-muted
97
+ {
98
+ display: none;
99
+ }
100
+
93
101
  /* With a side panel (squiffy.json's "panels"), the page is wider, with the panel to the right of
94
102
  the story. It stays in view as the story scrolls, under the header. On a narrower screen, it's a
95
103
  button in the header instead. */
@@ -109,7 +117,10 @@ button#squiffy-theme[data-next="light"] .squiffy-icon-dark
109
117
  grid-column: 1 / -1;
110
118
  }
111
119
 
112
- div#squiffy-container.squiffy-has-side > aside.squiffy-panels-side
120
+ /* :where() takes the container's id out of the selector's specificity, so a story's own
121
+ aside.squiffy-panels-side { ... } rule, which comes after this, changes the border and the
122
+ padding too */
123
+ :where(div#squiffy-container.squiffy-has-side) > aside.squiffy-panels-side
113
124
  {
114
125
  position: sticky;
115
126
  top: 3.5rem;