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

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 (47) hide show
  1. package/dist/events.d.ts +1 -0
  2. package/dist/panels.d.ts +14 -0
  3. package/dist/panels.test.d.ts +1 -0
  4. package/dist/preview-host.d.ts +2 -1
  5. package/dist/preview-host.js +4 -1
  6. package/dist/preview-host.js.map +2 -2
  7. package/dist/preview-html.js +1 -1
  8. package/dist/preview-protocol.d.ts +4 -0
  9. package/dist/saveSlots.d.ts +16 -0
  10. package/dist/saves.test.d.ts +1 -0
  11. package/dist/savesDialog.d.ts +43 -0
  12. package/dist/savesDialog.test.d.ts +1 -0
  13. package/dist/squiffy.page.css +46 -22
  14. package/dist/squiffy.preview.html +612 -109
  15. package/dist/squiffy.runtime.css +476 -9
  16. package/dist/squiffy.runtime.d.ts +9 -1
  17. package/dist/squiffy.runtime.global.js +113 -72
  18. package/dist/squiffy.runtime.global.js.map +1 -1
  19. package/dist/squiffy.runtime.js +4146 -3460
  20. package/dist/squiffy.runtime.js.map +1 -1
  21. package/dist/state.d.ts +4 -0
  22. package/dist/textProcessor.d.ts +5 -0
  23. package/dist/types.d.ts +32 -0
  24. package/package.json +3 -3
  25. package/src/__snapshots__/squiffy.runtime.test.ts.snap +21 -21
  26. package/src/events.ts +1 -0
  27. package/src/panels.test.ts +201 -0
  28. package/src/panels.ts +187 -0
  29. package/src/plugins/plugins.test.ts +42 -0
  30. package/src/plugins/replaceLabel.ts +6 -2
  31. package/src/preview-host.test.ts +5 -1
  32. package/src/preview-host.ts +9 -3
  33. package/src/preview-protocol.ts +6 -2
  34. package/src/preview.test.ts +71 -3
  35. package/src/preview.ts +74 -13
  36. package/src/saveSlots.ts +159 -0
  37. package/src/saves.test.ts +199 -0
  38. package/src/savesDialog.test.ts +290 -0
  39. package/src/savesDialog.ts +499 -0
  40. package/src/squiffy.page.css +46 -22
  41. package/src/squiffy.runtime.css +476 -9
  42. package/src/squiffy.runtime.test.ts +890 -4
  43. package/src/squiffy.runtime.ts +322 -17
  44. package/src/state.ts +34 -4
  45. package/src/textProcessor.ts +76 -9
  46. package/src/types.ts +57 -1
  47. package/vite.preview.config.ts +7 -0
@@ -18,6 +18,7 @@ export type HostMessage = {
18
18
  } | {
19
19
  type: "update";
20
20
  js: string;
21
+ css?: string[];
21
22
  } | {
22
23
  type: "restart";
23
24
  } | {
@@ -33,6 +34,9 @@ export type PreviewMessage = {
33
34
  type: "ready";
34
35
  } | {
35
36
  type: "loaded";
37
+ } | {
38
+ type: "themeFixed";
39
+ fixed: boolean;
36
40
  } | {
37
41
  type: "attributeSet";
38
42
  name: string;
@@ -0,0 +1,16 @@
1
+ import { SavedGame } from './types.js';
2
+ export interface SaveSlot {
3
+ id: number;
4
+ name: string | null;
5
+ save: SavedGame;
6
+ }
7
+ export interface SaveSlots {
8
+ list(): Promise<SaveSlot[]>;
9
+ get(id: number): Promise<SaveSlot | null>;
10
+ add(save: SavedGame, name: string | null): Promise<SaveSlot>;
11
+ overwrite(id: number, save: SavedGame): Promise<void>;
12
+ rename(id: number, name: string | null): Promise<void>;
13
+ delete(id: number): Promise<void>;
14
+ }
15
+ export declare function indexedDbSaveSlots(key: string): SaveSlots;
16
+ export declare function memorySaveSlots(): SaveSlots;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ import { SquiffyApi } from './types.js';
2
+ import { SaveSlots } from './saveSlots.js';
3
+ export declare const SAVES_STRINGS: {
4
+ saves: string;
5
+ saveName: string;
6
+ save: string;
7
+ noSaves: string;
8
+ savedGame: string;
9
+ savedToday: string;
10
+ savedYesterday: string;
11
+ load: string;
12
+ loadConfirm: string;
13
+ saveOptions: string;
14
+ overwrite: string;
15
+ overwriteConfirm: string;
16
+ rename: string;
17
+ newName: string;
18
+ saveToFile: string;
19
+ loadFromFile: string;
20
+ delete: string;
21
+ deleteConfirm: string;
22
+ cancel: string;
23
+ close: string;
24
+ wrongStory: string;
25
+ notASave: string;
26
+ cantSave: string;
27
+ };
28
+ export type SavesStringName = keyof typeof SAVES_STRINGS;
29
+ export interface SavesDialogOptions {
30
+ slots?: SaveSlots;
31
+ key?: string;
32
+ strings?: Partial<Record<string, string>>;
33
+ fileName?: string;
34
+ container?: HTMLElement;
35
+ }
36
+ export interface SavesDialog {
37
+ element: HTMLDialogElement;
38
+ open: () => Promise<void>;
39
+ close: () => void;
40
+ }
41
+ export declare const SAVE_FILE_EXTENSION = ".squiffy-save";
42
+ export declare function formatSaveTime(savedAt: string, strings?: Record<SavesStringName, string>, now?: Date): string;
43
+ export declare function createSavesDialog(api: SquiffyApi, options?: SavesDialogOptions): SavesDialog;
@@ -0,0 +1 @@
1
+ export {};
@@ -4,6 +4,12 @@
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;
9
+ /* The size of the story text. The header's buttons are smaller, and don't change with it */
10
+ --squiffy-font-size: 1.125rem;
11
+ /* The space between lines of text */
12
+ --squiffy-line-height: 1.6;
7
13
  }
8
14
 
9
15
  /* Follow the reader's light or dark system setting, or what they chose with the theme button.
@@ -39,12 +45,12 @@ div#squiffy-container
39
45
  margin-left: auto;
40
46
  margin-right: auto;
41
47
  padding: 0 1.25rem 3rem;
42
- font-family: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
43
- line-height: 1.6;
48
+ font-family: var(--squiffy-font-family);
49
+ line-height: var(--squiffy-line-height);
44
50
  }
45
51
 
46
- /* The bar above the story containing the Restart and light/dark buttons. It stays at the top of
47
- the window as the story scrolls under it. */
52
+ /* The bar above the story containing the Back, Restart and light/dark buttons. It stays at the
53
+ top of the window as the story scrolls under it. */
48
54
  div#squiffy-header
49
55
  {
50
56
  position: sticky;
@@ -70,36 +76,54 @@ div#squiffy-header::after
70
76
  pointer-events: none;
71
77
  }
72
78
 
73
- /* The button that switches between light and dark mode. It shows a moon in light mode and a sun
74
- in dark mode. */
75
- button#squiffy-theme
76
- {
77
- margin-left: 0.75em;
78
- }
79
-
80
- /* Centred on the capital letters of "Restart", rather than on the line, which looks too low */
81
- button#squiffy-theme svg
79
+ /* Space between the Back, Restart and light/dark buttons */
80
+ button.squiffy-header-button + button.squiffy-header-button
82
81
  {
83
- width: 1.1em;
84
- height: 1.1em;
85
- vertical-align: -0.25em;
86
- fill: none;
87
- stroke: currentColor;
88
- stroke-width: 2;
89
- stroke-linecap: round;
90
- stroke-linejoin: round;
82
+ margin-left: 0.25em;
91
83
  }
92
84
 
85
+ /* The button that switches between light and dark mode. It shows a moon in light mode and a sun
86
+ in dark mode. */
93
87
  button#squiffy-theme:not([data-next="light"]) .squiffy-icon-light,
94
88
  button#squiffy-theme[data-next="light"] .squiffy-icon-dark
95
89
  {
96
90
  display: none;
97
91
  }
98
92
 
93
+ /* With a side panel (squiffy.json's "panels"), the page is wider, with the panel to the right of
94
+ the story. It stays in view as the story scrolls, under the header. On a narrower screen, it's a
95
+ button in the header instead. */
96
+ @media (min-width: 64rem)
97
+ {
98
+ div#squiffy-container.squiffy-has-side
99
+ {
100
+ display: grid;
101
+ grid-template-columns: minmax(0, 1fr) var(--squiffy-side-width);
102
+ column-gap: 2.5rem;
103
+ align-items: start;
104
+ max-width: calc(var(--squiffy-max-width) + var(--squiffy-side-width) + 2.5rem);
105
+ }
106
+
107
+ div#squiffy-container.squiffy-has-side > div#squiffy-header
108
+ {
109
+ grid-column: 1 / -1;
110
+ }
111
+
112
+ div#squiffy-container.squiffy-has-side > aside.squiffy-panels-side
113
+ {
114
+ position: sticky;
115
+ top: 3.5rem;
116
+ padding-left: 1.25rem;
117
+ border-left: 1px solid var(--squiffy-border);
118
+ max-height: calc(100vh - 4.5rem);
119
+ overflow-y: auto;
120
+ }
121
+ }
122
+
99
123
  /* The story text */
100
124
  div#squiffy
101
125
  {
102
- font-size: 1.125rem;
126
+ font-size: var(--squiffy-font-size);
103
127
  }
104
128
 
105
129
  div#squiffy :is(h1, h2, h3, h4, h5, h6)