@abreen/tada 1.8.1 → 1.10.1

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 (79) hide show
  1. package/README.md +24 -34
  2. package/bin/tada.ts +1 -1
  3. package/bin/validators.ts +1 -1
  4. package/build/apply-base-path-plugin.ts +79 -17
  5. package/build/bundle.ts +9 -1
  6. package/build/content-watch.ts +3 -3
  7. package/build/copy.ts +30 -0
  8. package/build/generate-content-assets.ts +45 -59
  9. package/build/pagefind.ts +0 -7
  10. package/build/serve.ts +4 -0
  11. package/build/templates.ts +0 -2
  12. package/build/types.d.ts +19 -1
  13. package/build/util.ts +3 -0
  14. package/build/utils/content-files.ts +98 -0
  15. package/build/utils/include.ts +4 -0
  16. package/build/utils/python-runner/trace_runner.py +272 -0
  17. package/build/utils/render.ts +47 -15
  18. package/build/utils/source-template.ts +27 -0
  19. package/build/utils/trace-core.ts +203 -0
  20. package/build/utils/trace-java.ts +132 -0
  21. package/build/utils/trace-layout.ts +31 -3
  22. package/build/utils/trace-python.ts +26 -0
  23. package/build/utils/trace.ts +174 -294
  24. package/build/validate-internal-links-plugin.ts +16 -4
  25. package/build/watch/assets.ts +111 -0
  26. package/build/watch/build-full.ts +124 -0
  27. package/build/watch/build-incremental.ts +139 -0
  28. package/build/watch/compiler-types.d.ts +19 -0
  29. package/build/watch/compiler.ts +112 -0
  30. package/build/watch/index.ts +22 -0
  31. package/build/watch/mutations.ts +75 -0
  32. package/build/watch/planner.ts +230 -0
  33. package/build/watch/records.ts +190 -0
  34. package/build/watch/runtime.ts +143 -0
  35. package/build/watch/snapshot.ts +602 -0
  36. package/build/watch/validation.ts +36 -0
  37. package/build/watch-reload-client.ts +10 -5
  38. package/init/content/labs/01/index.md +6 -0
  39. package/init/content/labs/01/trace_demo.py +16 -0
  40. package/init/content/lectures/01/Rectangle.java +2 -0
  41. package/init/content/lectures/01/index.md +6 -0
  42. package/init/content/lectures/01/rectangle.py +5 -0
  43. package/package.json +42 -23
  44. package/python/command.ts +95 -0
  45. package/python/module.ts +18 -0
  46. package/src/_alerts.scss +11 -8
  47. package/src/_base.scss +25 -29
  48. package/src/_layout.scss +17 -14
  49. package/src/_mixins.scss +10 -9
  50. package/src/anchor/style.scss +4 -2
  51. package/src/code/index.ts +9 -2
  52. package/src/code/style.scss +14 -13
  53. package/src/code.scss +14 -13
  54. package/src/header/_base.scss +21 -24
  55. package/src/header/style.scss +16 -12
  56. package/src/index.ts +3 -0
  57. package/src/literate/style.scss +4 -4
  58. package/src/navigate/index.ts +43 -279
  59. package/src/navigate/lifecycle.ts +1 -1
  60. package/src/navigate/runtime.ts +341 -0
  61. package/src/page-update/README.md +4 -0
  62. package/src/page-update/index.ts +280 -0
  63. package/src/page-update/style.scss +53 -0
  64. package/src/print/style.scss +4 -4
  65. package/src/question/style.scss +10 -6
  66. package/src/search/index.ts +9 -12
  67. package/src/search/style.scss +44 -42
  68. package/src/style.scss +63 -58
  69. package/src/timezone/style.scss +5 -5
  70. package/src/toc/style.scss +17 -16
  71. package/src/trace/style.scss +27 -27
  72. package/src/validators.ts +45 -0
  73. package/templates/_footer.html +1 -1
  74. package/templates/_theme.scss +8 -19
  75. package/watch/engine.ts +296 -0
  76. package/watch/events.ts +10 -0
  77. package/watch/fs-commit.ts +102 -0
  78. package/watch/types.d.ts +103 -0
  79. package/build/watch.ts +0 -493
@@ -17,21 +17,23 @@
17
17
 
18
18
  .question-label,
19
19
  .question-a-label {
20
- color: var(--theme-color-text);
21
- font-weight: 700;
22
20
  flex-shrink: 0;
23
21
  margin: 0;
22
+ font-weight: 700;
23
+ color: var(--theme-color-text);
24
+
24
25
  @include user-select(none);
25
26
  }
26
27
 
27
28
  .question-q > span:last-child {
28
- color: var(--fg-color);
29
29
  font-weight: var(--font-weight);
30
+ color: var(--fg-color);
30
31
  }
31
32
 
32
33
  .question-a-body {
33
34
  flex: 1;
34
35
  cursor: pointer;
36
+
35
37
  @include user-select(none);
36
38
  }
37
39
 
@@ -68,10 +70,10 @@
68
70
 
69
71
  .question-a-body:not([data-revealed]) > * {
70
72
  color: transparent;
73
+ pointer-events: none;
71
74
  background-color: var(--bg2-color);
72
75
  border-color: transparent;
73
76
  box-shadow: none;
74
- pointer-events: none;
75
77
  }
76
78
 
77
79
  .question-a-body:not([data-revealed]) > * * {
@@ -82,13 +84,13 @@
82
84
  }
83
85
 
84
86
  .question-a-body::after {
85
- content: 'Click to reveal';
86
87
  display: block;
87
88
  font-size: var(--font-size-small);
88
89
  font-style: italic;
89
90
  color: var(--fg2-color);
90
91
  text-align: center;
91
92
  pointer-events: none;
93
+ content: 'Click to reveal';
92
94
 
93
95
  @media (prefers-reduced-motion: no-preference) {
94
96
  transition: opacity 0.25s;
@@ -107,18 +109,20 @@
107
109
 
108
110
  .question-a-body[data-revealed] {
109
111
  cursor: unset;
112
+
110
113
  @include user-select(text);
111
114
  }
112
115
 
113
116
  @media print {
114
117
  .question-a-body {
115
118
  cursor: default;
119
+
116
120
  @include user-select(text);
117
121
 
118
122
  &:not([data-revealed]) > * {
119
123
  color: inherit;
120
- background-color: transparent;
121
124
  pointer-events: auto;
125
+ background-color: transparent;
122
126
  }
123
127
 
124
128
  &:not([data-revealed]) > * * {
@@ -1,6 +1,11 @@
1
1
  import { getElement, applyBasePath } from '../util';
2
2
  import { getPdfPageNumber, groupPdfResults } from './pdf-utils';
3
3
  import type { Result } from './pdf-utils';
4
+ import {
5
+ getResponseValidators,
6
+ hasResponseValidatorsChanged,
7
+ type ResponseValidators,
8
+ } from '../validators';
4
9
 
5
10
  const MAX_RESULTS = 24;
6
11
 
@@ -281,8 +286,7 @@ export default (window: Window) => {
281
286
  // Unhide (hidden via inline style in template to prevent FOUC)
282
287
  resultsDiv.style.display = '';
283
288
 
284
- let entryETag: string | null = null;
285
- let entryLastModified: string | null = null;
289
+ let entryValidators: ResponseValidators = { etag: null, lastModified: null };
286
290
  let lastIndexCheck = 0;
287
291
  let indexCheckInFlight = false;
288
292
 
@@ -302,8 +306,7 @@ export default (window: Window) => {
302
306
  });
303
307
 
304
308
  if (res.ok) {
305
- entryETag = res.headers.get('ETag');
306
- entryLastModified = res.headers.get('Last-Modified');
309
+ entryValidators = getResponseValidators(res);
307
310
  }
308
311
  }
309
312
 
@@ -321,14 +324,8 @@ export default (window: Window) => {
321
324
  if (!res.ok) {
322
325
  return;
323
326
  }
324
- const newETag = res.headers.get('ETag');
325
- const newLastModified = res.headers.get('Last-Modified');
326
- const changed =
327
- (newETag !== null && newETag !== entryETag) ||
328
- (newETag === null &&
329
- newLastModified !== null &&
330
- newLastModified !== entryLastModified);
331
- if (changed) {
327
+ const newValidators = getResponseValidators(res);
328
+ if (hasResponseValidatorsChanged(entryValidators, newValidators)) {
332
329
  pagefind = null;
333
330
  await loadPagefind();
334
331
  await update();
@@ -4,8 +4,8 @@ header {
4
4
  .search-controls {
5
5
  display: flex;
6
6
  flex-wrap: wrap;
7
- align-items: center;
8
7
  gap: 0.5rem;
8
+ align-items: center;
9
9
 
10
10
  input.search {
11
11
  flex: 1;
@@ -13,8 +13,8 @@ header {
13
13
  }
14
14
 
15
15
  .results-container.is-showing .results {
16
- opacity: 1;
17
16
  pointer-events: all;
17
+ opacity: 1;
18
18
  }
19
19
 
20
20
  @media (hover: hover) {
@@ -25,45 +25,47 @@ header {
25
25
  }
26
26
 
27
27
  .results {
28
- opacity: 0;
29
- pointer-events: none;
28
+ display: flex;
29
+ flex-direction: column;
30
+ min-height: 80px;
31
+ max-height: 66vh;
30
32
  margin: 0 auto;
31
- background: var(--bg-color);
33
+ overflow: hidden;
32
34
  color: var(--fg-color);
35
+ pointer-events: none;
36
+ background: var(--bg-color);
33
37
  border: var(--control-border-width) solid var(--fg2-color);
34
- box-shadow: var(--box-shadow);
35
38
  border-radius: var(--border-radius);
36
- overflow: hidden;
37
- display: flex;
38
- flex-direction: column;
39
- max-height: 66vh;
40
- min-height: 80px;
39
+ box-shadow: var(--box-shadow);
40
+ opacity: 0;
41
+
41
42
  @include user-select(none);
42
43
 
43
44
  .results-info {
45
+ position: relative;
44
46
  display: flex;
45
47
  align-items: center;
46
48
  justify-content: space-between;
49
+ padding: 8px;
47
50
  color: var(--fg2-color);
51
+
48
52
  @include user-select(none);
49
- padding: 8px 8px 8px 8px;
50
- position: relative;
51
53
 
52
54
  &.loading::after {
53
- content: '';
54
55
  position: absolute;
56
+ right: 0;
55
57
  bottom: 0;
56
58
  left: 0;
57
- right: 0;
58
59
  height: 2px;
60
+ content: '';
59
61
  background-image: linear-gradient(
60
62
  90deg,
61
63
  transparent 25%,
62
64
  var(--theme-color) 50%,
63
65
  transparent 75%
64
66
  );
65
- background-size: 200% 100%;
66
67
  background-repeat: no-repeat;
68
+ background-size: 200% 100%;
67
69
  animation: shimmer 3s ease-in-out infinite;
68
70
  }
69
71
 
@@ -72,25 +74,25 @@ header {
72
74
  color: var(--fg2-color);
73
75
 
74
76
  kbd {
77
+ line-height: 1.4;
75
78
  border-color: var(--fg2-color);
76
79
  box-shadow: 0 2px 0 var(--fg2-color);
77
- line-height: 1.4;
78
80
  }
79
81
  }
80
82
  }
81
83
 
82
84
  ol {
83
- margin: 0;
84
- padding: 0;
85
- list-style-type: none;
86
85
  display: grid;
86
+ flex: 1;
87
87
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
88
88
  gap: 0;
89
- overflow-y: auto;
90
- flex: 1;
91
89
  min-height: 0;
90
+ padding: 0;
91
+ margin: 0;
92
+ overflow-y: auto;
93
+ list-style-type: none;
92
94
 
93
- @media (max-width: 580px) {
95
+ @media (width <= 580px) {
94
96
  grid-template-columns: minmax(0, 1fr);
95
97
  }
96
98
 
@@ -101,18 +103,18 @@ header {
101
103
  }
102
104
 
103
105
  a.result:focus {
104
- background: var(--bg2-color);
105
106
  outline-offset: -2px;
107
+ background: var(--bg2-color);
106
108
  }
107
109
  }
108
110
 
109
111
  ol a {
110
- text-decoration: none;
111
- display: grid;
112
- border: none;
113
112
  position: relative;
114
- color: var(--fg-color);
113
+ display: grid;
115
114
  padding: 8px;
115
+ color: var(--fg-color);
116
+ text-decoration: none;
117
+ border: none;
116
118
 
117
119
  &:focus {
118
120
  outline-offset: -2px;
@@ -130,38 +132,38 @@ header {
130
132
  }
131
133
 
132
134
  ol a .title.code-page code {
133
- background: none;
134
135
  padding: 0;
136
+ background: none;
135
137
  }
136
138
 
137
139
  ol li .excerpt {
138
140
  grid-row-start: 3;
139
- font-size: var(--font-size-small);
140
- color: var(--fg2-color);
141
- line-height: 2.5ex;
142
141
  height: 7.5ex;
143
142
  overflow: hidden;
143
+ font-size: var(--font-size-small);
144
+ line-height: 2.5ex;
145
+ color: var(--fg2-color);
144
146
 
145
147
  mark {
146
- background: transparent;
147
148
  font-weight: 600;
148
149
  color: var(--theme-color-text);
150
+ background: transparent;
149
151
  }
150
152
  }
151
153
 
152
154
  ol li .sub-results {
153
- list-style-type: none;
154
- margin: 0;
155
- padding: 0 8px 6px 8px;
156
155
  display: flex;
157
156
  flex-direction: column;
158
157
  gap: 2px;
158
+ padding: 0 8px 6px;
159
+ margin: 0;
160
+ list-style-type: none;
159
161
 
160
162
  a.sub-result {
161
163
  display: block;
162
164
  padding: 4px 8px;
163
- text-decoration: none;
164
165
  color: var(--fg2-color);
166
+ text-decoration: none;
165
167
  border-left: 2px solid var(--bg2-color);
166
168
 
167
169
  &:hover {
@@ -169,8 +171,8 @@ header {
169
171
  }
170
172
 
171
173
  &:focus {
172
- background: var(--bg2-color);
173
174
  outline-offset: -2px;
175
+ background: var(--bg2-color);
174
176
  }
175
177
 
176
178
  .title {
@@ -180,16 +182,16 @@ header {
180
182
  }
181
183
 
182
184
  .excerpt {
183
- font-size: var(--font-size-small);
184
- color: var(--fg2-color);
185
- line-height: 2.5ex;
186
185
  height: 2.5ex;
187
186
  overflow: hidden;
187
+ font-size: var(--font-size-small);
188
+ line-height: 2.5ex;
189
+ color: var(--fg2-color);
188
190
 
189
191
  mark {
190
- background: transparent;
191
192
  font-weight: 600;
192
193
  color: var(--theme-color-text);
194
+ background: transparent;
193
195
  }
194
196
  }
195
197
  }