@bangerpage/core 0.1.2 → 0.2.0-rc.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.
package/README.md CHANGED
@@ -5,7 +5,7 @@ The runtime for [Banger](https://github.com/bangerpage/banger): presentations wr
5
5
  Load it from a CDN with the exact version, then write the deck with `bang-*` elements:
6
6
 
7
7
  ```html
8
- <script type="module" src="https://cdn.jsdelivr.net/npm/@bangerpage/core@0.1.2/dist/index.js"></script>
8
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@bangerpage/core@0.2.0-rc.1/dist/index.js"></script>
9
9
  <bang-root theme="light">
10
10
  <bang-frame id="intro" at="0,0"><bang-title>Hello</bang-title></bang-frame>
11
11
  <bang-path>
@@ -237,6 +237,24 @@
237
237
  "kind": "javascript-module",
238
238
  "path": "src/base-style.ts",
239
239
  "declarations": [
240
+ {
241
+ "kind": "function",
242
+ "name": "ensureLanguageStyle",
243
+ "return": {
244
+ "type": {
245
+ "text": "void"
246
+ }
247
+ },
248
+ "parameters": [
249
+ {
250
+ "name": "languages",
251
+ "type": {
252
+ "text": "readonly string[]"
253
+ }
254
+ }
255
+ ],
256
+ "description": "Adds or refreshes `<style id=\"bang-lang\">`, which hides every element whose `lang` is not the root's current language."
257
+ },
240
258
  {
241
259
  "kind": "function",
242
260
  "name": "ensureBaseStyle",
@@ -316,6 +334,14 @@
316
334
  }
317
335
  ],
318
336
  "exports": [
337
+ {
338
+ "kind": "js",
339
+ "name": "ensureLanguageStyle",
340
+ "declaration": {
341
+ "name": "ensureLanguageStyle",
342
+ "module": "src/base-style.ts"
343
+ }
344
+ },
319
345
  {
320
346
  "kind": "js",
321
347
  "name": "ensureBaseStyle",
@@ -1136,6 +1162,30 @@
1136
1162
  }
1137
1163
  ],
1138
1164
  "description": "Content that reaches past a frame's inner margin (the frame clips at its edge, so it is cut off or crowds the edge),\nand content that sticks out of a `bang-card`, which does not clip and lets it run over what is below."
1165
+ },
1166
+ {
1167
+ "kind": "function",
1168
+ "name": "translationWarnings",
1169
+ "return": {
1170
+ "type": {
1171
+ "text": "string[]"
1172
+ }
1173
+ },
1174
+ "parameters": [
1175
+ {
1176
+ "name": "root",
1177
+ "type": {
1178
+ "text": "Element"
1179
+ }
1180
+ },
1181
+ {
1182
+ "name": "languages",
1183
+ "type": {
1184
+ "text": "readonly string[]"
1185
+ }
1186
+ }
1187
+ ],
1188
+ "description": "Mistakes in how a multilingual deck is written, independent of which language is shown: untranslated siblings,\n`lang` in places that cannot vary, layouts that move between languages, and `crumb`/`label` without a translation."
1139
1189
  }
1140
1190
  ],
1141
1191
  "exports": [
@@ -1162,6 +1212,14 @@
1162
1212
  "name": "frameOverflowWarnings",
1163
1213
  "module": "src/deck-check.ts"
1164
1214
  }
1215
+ },
1216
+ {
1217
+ "kind": "js",
1218
+ "name": "translationWarnings",
1219
+ "declaration": {
1220
+ "name": "translationWarnings",
1221
+ "module": "src/deck-check.ts"
1222
+ }
1165
1223
  }
1166
1224
  ]
1167
1225
  },
@@ -1419,7 +1477,7 @@
1419
1477
  "type": {
1420
1478
  "text": "string | undefined"
1421
1479
  },
1422
- "description": "A bold heading-size line (36px) at the top left, inside the top margin. It does not move the content and is cut to one line.",
1480
+ "description": "A bold heading-size line (36px) at the top left, inside the top margin. It does not move the content and is cut to one line.\nIn a deck with `languages`, write `crumb-<language>` (for example `crumb-en`) for each other language; a language without one shows `crumb`.",
1423
1481
  "attribute": "crumb"
1424
1482
  },
1425
1483
  {
@@ -1428,7 +1486,7 @@
1428
1486
  "type": {
1429
1487
  "text": "string | undefined"
1430
1488
  },
1431
- "description": "A large name shown over the frame when the camera is far away (the overview, or a stop on another frame), with the\ncontent faded behind it. It fades out as the camera comes close. Use it to name a place on a map or a chapter.\nExperimental, made for `format=\"map\"`; it may change in any release.",
1489
+ "description": "A large name shown over the frame when the camera is far away (the overview, or a stop on another frame), with the\ncontent faded behind it. It fades out as the camera comes close. Use it to name a place on a map or a chapter.\nExperimental, made for `format=\"map\"`; it may change in any release.\nIn a deck with `languages`, write `label-<language>` (for example `label-en`) for each other language; a language without one shows `label`.",
1432
1490
  "attribute": "label"
1433
1491
  },
1434
1492
  {
@@ -1450,6 +1508,25 @@
1450
1508
  "default": "0",
1451
1509
  "description": "The step shown in this frame. Set by `bang-root`."
1452
1510
  },
1511
+ {
1512
+ "kind": "method",
1513
+ "name": "frameText",
1514
+ "privacy": "private",
1515
+ "return": {
1516
+ "type": {
1517
+ "text": "string"
1518
+ }
1519
+ },
1520
+ "parameters": [
1521
+ {
1522
+ "name": "name",
1523
+ "type": {
1524
+ "text": "\"crumb\" | \"label\""
1525
+ }
1526
+ }
1527
+ ],
1528
+ "description": "The text for `crumb` or `label` in the root's current language: `crumb-<language>` when set, else the plain attribute."
1529
+ },
1453
1530
  {
1454
1531
  "kind": "field",
1455
1532
  "name": "renderDone",
@@ -1519,7 +1596,7 @@
1519
1596
  "type": {
1520
1597
  "text": "string | undefined"
1521
1598
  },
1522
- "description": "A bold heading-size line (36px) at the top left, inside the top margin. It does not move the content and is cut to one line.",
1599
+ "description": "A bold heading-size line (36px) at the top left, inside the top margin. It does not move the content and is cut to one line.\nIn a deck with `languages`, write `crumb-<language>` (for example `crumb-en`) for each other language; a language without one shows `crumb`.",
1523
1600
  "fieldName": "crumb"
1524
1601
  },
1525
1602
  {
@@ -1527,7 +1604,7 @@
1527
1604
  "type": {
1528
1605
  "text": "string | undefined"
1529
1606
  },
1530
- "description": "A large name shown over the frame when the camera is far away (the overview, or a stop on another frame), with the\ncontent faded behind it. It fades out as the camera comes close. Use it to name a place on a map or a chapter.\nExperimental, made for `format=\"map\"`; it may change in any release.",
1607
+ "description": "A large name shown over the frame when the camera is far away (the overview, or a stop on another frame), with the\ncontent faded behind it. It fades out as the camera comes close. Use it to name a place on a map or a chapter.\nExperimental, made for `format=\"map\"`; it may change in any release.\nIn a deck with `languages`, write `label-<language>` (for example `label-en`) for each other language; a language without one shows `label`.",
1531
1608
  "fieldName": "label"
1532
1609
  },
1533
1610
  {
@@ -2066,6 +2143,221 @@
2066
2143
  }
2067
2144
  ]
2068
2145
  },
2146
+ {
2147
+ "kind": "javascript-module",
2148
+ "path": "src/language.ts",
2149
+ "declarations": [
2150
+ {
2151
+ "kind": "variable",
2152
+ "name": "LANGUAGE_TAG",
2153
+ "default": "/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/"
2154
+ },
2155
+ {
2156
+ "kind": "function",
2157
+ "name": "foldTag",
2158
+ "return": {
2159
+ "type": {
2160
+ "text": "string"
2161
+ }
2162
+ },
2163
+ "parameters": [
2164
+ {
2165
+ "name": "tag",
2166
+ "type": {
2167
+ "text": "string"
2168
+ }
2169
+ }
2170
+ ],
2171
+ "description": "Lower-cases ASCII letters only, so the comparison matches CSS's `i` flag."
2172
+ },
2173
+ {
2174
+ "kind": "function",
2175
+ "name": "parseLanguages",
2176
+ "return": {
2177
+ "type": {
2178
+ "text": "{ languages: string[]; invalid: string[] }"
2179
+ }
2180
+ },
2181
+ "parameters": [
2182
+ {
2183
+ "name": "raw",
2184
+ "type": {
2185
+ "text": "string | null"
2186
+ }
2187
+ }
2188
+ ],
2189
+ "description": "Splits on whitespace; keeps tags that match `LANGUAGE_TAG` once each (ignoring case), in order."
2190
+ },
2191
+ {
2192
+ "kind": "function",
2193
+ "name": "canonicalLanguage",
2194
+ "return": {
2195
+ "type": {
2196
+ "text": "string | undefined"
2197
+ }
2198
+ },
2199
+ "parameters": [
2200
+ {
2201
+ "name": "tag",
2202
+ "type": {
2203
+ "text": "string | null"
2204
+ }
2205
+ },
2206
+ {
2207
+ "name": "languages",
2208
+ "type": {
2209
+ "text": "readonly string[]"
2210
+ }
2211
+ }
2212
+ ],
2213
+ "description": "The spelling in `languages` of the tag that equals `tag` ignoring case, or undefined."
2214
+ },
2215
+ {
2216
+ "kind": "function",
2217
+ "name": "resolveLanguage",
2218
+ "return": {
2219
+ "type": {
2220
+ "text": "{ language: string; queryIgnored: boolean }"
2221
+ }
2222
+ },
2223
+ "parameters": [
2224
+ {
2225
+ "name": "input",
2226
+ "type": {
2227
+ "text": "{\n languages: readonly string[];\n query: string | null;\n navigatorLanguages: readonly string[];\n useNavigator: boolean;\n}"
2228
+ }
2229
+ }
2230
+ ],
2231
+ "description": "Picks the language: `?lang=`, then the browser's languages, then the first. `languages` has at least one."
2232
+ },
2233
+ {
2234
+ "kind": "function",
2235
+ "name": "nextLanguage",
2236
+ "return": {
2237
+ "type": {
2238
+ "text": "string"
2239
+ }
2240
+ },
2241
+ "parameters": [
2242
+ {
2243
+ "name": "languages",
2244
+ "type": {
2245
+ "text": "readonly string[]"
2246
+ }
2247
+ },
2248
+ {
2249
+ "name": "current",
2250
+ "type": {
2251
+ "text": "string"
2252
+ }
2253
+ }
2254
+ ],
2255
+ "description": "The language after `current` in `languages`; the first after the last."
2256
+ },
2257
+ {
2258
+ "kind": "function",
2259
+ "name": "languageCss",
2260
+ "return": {
2261
+ "type": {
2262
+ "text": "string"
2263
+ }
2264
+ },
2265
+ "parameters": [
2266
+ {
2267
+ "name": "languages",
2268
+ "type": {
2269
+ "text": "readonly string[]"
2270
+ }
2271
+ }
2272
+ ],
2273
+ "description": "Per language, a rule hiding the other languages' elements inside frames, and one removing the group space from the\nfirst shown item of a grouped list (the list's own `:first-child` rule would pick a hidden item); \"\" for fewer than\ntwo languages."
2274
+ },
2275
+ {
2276
+ "kind": "function",
2277
+ "name": "inLanguage",
2278
+ "return": {
2279
+ "type": {
2280
+ "text": "boolean"
2281
+ }
2282
+ },
2283
+ "parameters": [
2284
+ {
2285
+ "name": "el",
2286
+ "type": {
2287
+ "text": "LanguageNode"
2288
+ }
2289
+ }
2290
+ ],
2291
+ "description": "False when `el` is inside a frame under a `lang` that is one of the deck's languages but not the current one. Same definition as `languageCss`."
2292
+ }
2293
+ ],
2294
+ "exports": [
2295
+ {
2296
+ "kind": "js",
2297
+ "name": "LANGUAGE_TAG",
2298
+ "declaration": {
2299
+ "name": "LANGUAGE_TAG",
2300
+ "module": "src/language.ts"
2301
+ }
2302
+ },
2303
+ {
2304
+ "kind": "js",
2305
+ "name": "foldTag",
2306
+ "declaration": {
2307
+ "name": "foldTag",
2308
+ "module": "src/language.ts"
2309
+ }
2310
+ },
2311
+ {
2312
+ "kind": "js",
2313
+ "name": "parseLanguages",
2314
+ "declaration": {
2315
+ "name": "parseLanguages",
2316
+ "module": "src/language.ts"
2317
+ }
2318
+ },
2319
+ {
2320
+ "kind": "js",
2321
+ "name": "canonicalLanguage",
2322
+ "declaration": {
2323
+ "name": "canonicalLanguage",
2324
+ "module": "src/language.ts"
2325
+ }
2326
+ },
2327
+ {
2328
+ "kind": "js",
2329
+ "name": "resolveLanguage",
2330
+ "declaration": {
2331
+ "name": "resolveLanguage",
2332
+ "module": "src/language.ts"
2333
+ }
2334
+ },
2335
+ {
2336
+ "kind": "js",
2337
+ "name": "nextLanguage",
2338
+ "declaration": {
2339
+ "name": "nextLanguage",
2340
+ "module": "src/language.ts"
2341
+ }
2342
+ },
2343
+ {
2344
+ "kind": "js",
2345
+ "name": "languageCss",
2346
+ "declaration": {
2347
+ "name": "languageCss",
2348
+ "module": "src/language.ts"
2349
+ }
2350
+ },
2351
+ {
2352
+ "kind": "js",
2353
+ "name": "inLanguage",
2354
+ "declaration": {
2355
+ "name": "inLanguage",
2356
+ "module": "src/language.ts"
2357
+ }
2358
+ }
2359
+ ]
2360
+ },
2069
2361
  {
2070
2362
  "kind": "javascript-module",
2071
2363
  "path": "src/notes.ts",
@@ -2256,6 +2548,40 @@
2256
2548
  }
2257
2549
  ]
2258
2550
  },
2551
+ {
2552
+ "kind": "method",
2553
+ "name": "sendLanguage",
2554
+ "return": {
2555
+ "type": {
2556
+ "text": "void"
2557
+ }
2558
+ },
2559
+ "parameters": [
2560
+ {
2561
+ "name": "lang",
2562
+ "type": {
2563
+ "text": "string"
2564
+ }
2565
+ }
2566
+ ]
2567
+ },
2568
+ {
2569
+ "kind": "method",
2570
+ "name": "onRemoteLanguage",
2571
+ "return": {
2572
+ "type": {
2573
+ "text": "void"
2574
+ }
2575
+ },
2576
+ "parameters": [
2577
+ {
2578
+ "name": "callback",
2579
+ "type": {
2580
+ "text": "(lang: string) => void"
2581
+ }
2582
+ }
2583
+ ]
2584
+ },
2259
2585
  {
2260
2586
  "kind": "method",
2261
2587
  "name": "onRemote",
@@ -2556,6 +2882,15 @@
2556
2882
  "attribute": "format",
2557
2883
  "reflects": true
2558
2884
  },
2885
+ {
2886
+ "kind": "field",
2887
+ "name": "languages",
2888
+ "type": {
2889
+ "text": "string | undefined"
2890
+ },
2891
+ "description": "The languages of the deck as BCP 47 tags separated by spaces, for example `ja en`; the first is the author's language.\nAn element inside a frame (and a `bang-notes`) with a `lang` of one of them shows only while that language is selected;\nelements without `lang` show in every language. The language comes from `?lang=`, then the browser's languages, then the first.\nThe root writes the selected language to its own `lang` attribute. Read once when the root connects; changing it later has no effect.",
2892
+ "attribute": "languages"
2893
+ },
2559
2894
  {
2560
2895
  "kind": "field",
2561
2896
  "name": "ground",
@@ -2750,6 +3085,39 @@
2750
3085
  "privacy": "private",
2751
3086
  "default": "null"
2752
3087
  },
3088
+ {
3089
+ "kind": "field",
3090
+ "name": "languageList",
3091
+ "type": {
3092
+ "text": "string[]"
3093
+ },
3094
+ "privacy": "private",
3095
+ "default": "[]"
3096
+ },
3097
+ {
3098
+ "kind": "field",
3099
+ "name": "currentLanguage",
3100
+ "type": {
3101
+ "text": "string"
3102
+ },
3103
+ "privacy": "private",
3104
+ "default": "\"\""
3105
+ },
3106
+ {
3107
+ "kind": "field",
3108
+ "name": "multilingual",
3109
+ "type": {
3110
+ "text": "boolean"
3111
+ },
3112
+ "privacy": "private",
3113
+ "readonly": true
3114
+ },
3115
+ {
3116
+ "kind": "field",
3117
+ "name": "onFontsLoaded",
3118
+ "privacy": "private",
3119
+ "readonly": true
3120
+ },
2753
3121
  {
2754
3122
  "kind": "field",
2755
3123
  "name": "resizeObserver",
@@ -2905,6 +3273,60 @@
2905
3273
  "privacy": "private",
2906
3274
  "readonly": true
2907
3275
  },
3276
+ {
3277
+ "kind": "method",
3278
+ "name": "initLanguage",
3279
+ "privacy": "private",
3280
+ "return": {
3281
+ "type": {
3282
+ "text": "void"
3283
+ }
3284
+ }
3285
+ },
3286
+ {
3287
+ "kind": "method",
3288
+ "name": "getLanguages",
3289
+ "return": {
3290
+ "type": {
3291
+ "text": "string[]"
3292
+ }
3293
+ },
3294
+ "description": "The deck's languages from the `languages` attribute; empty for a deck without them."
3295
+ },
3296
+ {
3297
+ "kind": "method",
3298
+ "name": "getLanguage",
3299
+ "return": {
3300
+ "type": {
3301
+ "text": "string"
3302
+ }
3303
+ },
3304
+ "description": "The selected language; \"\" for a deck without languages."
3305
+ },
3306
+ {
3307
+ "kind": "method",
3308
+ "name": "setLanguage",
3309
+ "privacy": "private",
3310
+ "return": {
3311
+ "type": {
3312
+ "text": "boolean"
3313
+ }
3314
+ },
3315
+ "parameters": [
3316
+ {
3317
+ "name": "wanted",
3318
+ "type": {
3319
+ "text": "string"
3320
+ }
3321
+ },
3322
+ {
3323
+ "name": "broadcast",
3324
+ "type": {
3325
+ "text": "boolean"
3326
+ }
3327
+ }
3328
+ ]
3329
+ },
2908
3330
  {
2909
3331
  "kind": "method",
2910
3332
  "name": "renderHelp",
@@ -2931,6 +3353,17 @@
2931
3353
  },
2932
3354
  "description": "Overlays the colors and fonts of the bang-theme child as inline variables when theme=\"custom\"."
2933
3355
  },
3356
+ {
3357
+ "kind": "method",
3358
+ "name": "languageWarnings",
3359
+ "privacy": "private",
3360
+ "return": {
3361
+ "type": {
3362
+ "text": "string[]"
3363
+ }
3364
+ },
3365
+ "description": "Translation mistakes are the same in every language, so only the first language's pass reports them."
3366
+ },
2934
3367
  {
2935
3368
  "kind": "method",
2936
3369
  "name": "deckWarnings",
@@ -3513,6 +3946,14 @@
3513
3946
  "default": "\"slides\"",
3514
3947
  "description": "How the canvas is presented. `slides` (the default) is frames side by side. `map` draws the canvas as a map: a\nground with contour lines under the frames, roads for each frame's `link`, wider gaps, and fog over every frame the\ntalk has not reached yet. Export pages show what is around the stop instead of masking it.\n`map` is experimental: its look and behaviour may change in any release. Use `slides` unless the author asks for a map.",
3515
3948
  "fieldName": "format"
3949
+ },
3950
+ {
3951
+ "name": "languages",
3952
+ "type": {
3953
+ "text": "string | undefined"
3954
+ },
3955
+ "description": "The languages of the deck as BCP 47 tags separated by spaces, for example `ja en`; the first is the author's language.\nAn element inside a frame (and a `bang-notes`) with a `lang` of one of them shows only while that language is selected;\nelements without `lang` show in every language. The language comes from `?lang=`, then the browser's languages, then the first.\nThe root writes the selected language to its own `lang` attribute. Read once when the root connects; changing it later has no effect.",
3956
+ "fieldName": "languages"
3516
3957
  }
3517
3958
  ],
3518
3959
  "superclass": {
@@ -3956,6 +4397,10 @@
3956
4397
  "type": {
3957
4398
  "text": "Element"
3958
4399
  }
4400
+ },
4401
+ {
4402
+ "name": "language",
4403
+ "default": "\"\""
3959
4404
  }
3960
4405
  ],
3961
4406
  "description": "`auto` is true when the stop has no `steps` attribute; the root then fills `steps` in from the frame's content."
@@ -1,4 +1,6 @@
1
1
  import type { FontsRequest } from "./theme/custom.js";
2
+ /** Adds or refreshes `<style id="bang-lang">`, which hides every element whose `lang` is not the root's current language. */
3
+ export declare function ensureLanguageStyle(languages: readonly string[]): void;
2
4
  export declare function ensureBaseStyle(mode: "live" | "export" | "presenter"): void;
3
5
  /** Adds the theme's Google Fonts stylesheet; only the first `fontsHref` of a page is used. */
4
6
  export declare function ensureThemeFonts(request: FontsRequest): void;