@spidunno/desmos-types 1.13.7 → 1.13.9

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
@@ -6,11 +6,11 @@ the graphing calculator, geometry tool, 3D calculator, and the four-function and
6
6
  ## Install
7
7
 
8
8
  ```sh
9
- npm install --save-dev @spidunno/desmos-types@~1.13.7
9
+ npm install --save-dev @spidunno/desmos-types@~1.13.9
10
10
  ```
11
11
 
12
12
  The package's major and minor version match the Desmos API version it describes; patch releases
13
- are fixes to the types. Use a tilde range (`~1.13.7`), not npm's default caret (`^`), so you only
13
+ are fixes to the types. Use a tilde range (`~1.13.9`), not npm's default caret (`^`), so you only
14
14
  get type fixes for the API version you load.
15
15
 
16
16
  ## Usage
@@ -366,10 +366,36 @@ g.events.unobserveEvent('.myMod');
366
366
  Moving the viewport this way doesn't add an undo step. Call
367
367
  `g.debounceUserRequestedViewportChange()` afterwards if you want one.
368
368
 
369
+ ### Which Desmos build a version matches
370
+
371
+ Desmos updates the v1.13 bundle without changing its version, so the internal types are
372
+ regenerated automatically whenever `Desmos.commit` changes, and each regeneration is published as a
373
+ new patch version. The `desmos` field in `package.json` records the commit a version was generated
374
+ from, and [CHANGELOG.md](CHANGELOG.md) lists every version's commit and what changed in the
375
+ internals:
376
+
377
+ ```sh
378
+ npm view @spidunno/desmos-types@1.13.9 desmos # { version: 'v1.13-prerelease', commit: '…' }
379
+ ```
380
+
381
+ ```js
382
+ // is the live bundle the one the installed types were generated from?
383
+ console.log(Desmos.commit);
384
+ ```
385
+
369
386
  ### Regenerating for a new bundle
370
387
 
371
388
  ```sh
372
389
  curl -o calculator.js "https://www.desmos.com/api/v1.13/calculator.js?apiKey=YOUR_API_KEY"
390
+ npm run update:bundle -- calculator.js
391
+ ```
392
+
393
+ `update:bundle` does the whole update: it reads the bundle's commit (stopping if it's the one in
394
+ `package.json`, unless you pass `--force`), runs both generators, runs `npm test`, bumps the patch
395
+ version, records the commit and adds a CHANGELOG entry. It doesn't commit or publish. The
396
+ generators can also be run on their own:
397
+
398
+ ```sh
373
399
  npm run generate:internals -- calculator.js
374
400
  npm run snapshot:sketches -- calculator.js
375
401
  npm test
@@ -225,7 +225,63 @@ declare namespace Desmos.Internals {
225
225
  controller: Controller;
226
226
  }
227
227
 
228
- interface Grapher3D extends Generated.Grapher3D {}
228
+ /** A point in 3D math coordinates. */
229
+ interface Point3D {
230
+ x: number;
231
+ y: number;
232
+ z: number;
233
+ }
234
+
235
+ /** What the 3D grapher's worker found under the mouse. */
236
+ interface PickResult3D {
237
+ /** Where the ray from the mouse hit, in math coordinates. */
238
+ point: Point3D;
239
+ }
240
+
241
+ /** `grapher3d.controls`: mouse, touch and keyboard handling for the 3D graph paper. */
242
+ interface Grapher3DControls {
243
+ grapher3d: Grapher3D;
244
+ /** The graph paper element (`grapher3d.elt`). Desmos's wheel handler is attached here. */
245
+ domElement: HTMLElement;
246
+ /** -1 when idle, 0 while rotating with the mouse. */
247
+ state: -1 | 0;
248
+ /** Rotation speed while the graph is spinning, 0 when it isn't. */
249
+ speed3D: number;
250
+ /**
251
+ * `performance.now()` of the last wheel zoom, or 0. The tick calls
252
+ * `grapher3d.endZoom()` and resets it 100ms after the last one.
253
+ */
254
+ lastWheelEventTime: number;
255
+ /** Whether zoom and pan are disabled. */
256
+ isLocked(): boolean;
257
+ /** Whether rotating is disabled (the user lock, or the page is pinch zoomed). */
258
+ isRotationLocked(): boolean;
259
+ /** Set the viewport and commit it to history after a short delay. */
260
+ updateViewport(viewport: ViewportObject): void;
261
+ }
262
+
263
+ /** `grapher3d.viewportController`. */
264
+ interface Grapher3DViewportController {
265
+ getViewport(): Viewport;
266
+ /**
267
+ * Jump to a viewport. Invalid axes keep their current bounds, and each
268
+ * axis is clamped to a width between 1.34e-4 × its largest bound (at
269
+ * least 1.34e-4) and 134000, within ±67000.
270
+ */
271
+ setCurrentViewport(viewport: ViewportObject): void;
272
+ }
273
+
274
+ interface Grapher3D extends Generated.Grapher3D {
275
+ controls: Grapher3DControls;
276
+ viewportController: Grapher3DViewportController;
277
+ /** The 3D viewport always has z bounds (Desmos fills in defaults). */
278
+ getProjection(): { viewport: Viewport & { zmin: number; zmax: number } };
279
+ /**
280
+ * What's under the mouse, used as the center when zooming in with the
281
+ * scroll wheel. Undefined while the graph is spinning, or over nothing.
282
+ */
283
+ getZoomScrollWheelPickResult(): PickResult3D | null | undefined;
284
+ }
229
285
 
230
286
  interface Evaluator extends Generated.Evaluator {}
231
287
 
@@ -168,6 +168,17 @@ declare namespace Desmos.Internals {
168
168
 
169
169
  type FragileViewClass<P, Members> = DCGView.ViewClass<P, FragileView<P, Members>>;
170
170
 
171
+ /** Static helpers on `Fragile.MathquillView`. */
172
+ interface MathquillViewStatics {
173
+ /** The math field containing `document.activeElement`, if it's in one. */
174
+ getFocusedMathquill(): Desmos.MathQuillMathField | undefined;
175
+ /**
176
+ * Apply an arrow key to a math field. Returns true if the cursor was
177
+ * already at that edge (so focus should move to the next item).
178
+ */
179
+ applyArrowKeyAndReturnIfWasAtBounds(mathField: Desmos.MathQuillMathField, key: string, event: KeyboardEvent): boolean;
180
+ }
181
+
171
182
  /** The view classes on `Private.Fragile`. */
172
183
  interface FragileViews {
173
184
  ExpressionView: FragileViewClass<ExpressionViewProps, Generated.ExpressionViewMembers>;
@@ -176,7 +187,7 @@ declare namespace Desmos.Internals {
176
187
  ExpressionOptionsMenuView: FragileViewClass<ExpressionOptionsMenuViewProps, Generated.ExpressionOptionsMenuViewMembers>;
177
188
  ImageIconView: FragileViewClass<ImageIconViewProps, Generated.ImageIconViewMembers>;
178
189
  PromptSliderView: FragileViewClass<PromptSliderViewProps, Generated.PromptSliderViewMembers>;
179
- MathquillView: FragileViewClass<MathquillViewProps, Generated.MathquillViewMembers>;
190
+ MathquillView: FragileViewClass<MathquillViewProps, Generated.MathquillViewMembers> & MathquillViewStatics;
180
191
  InlineMathInputView: FragileViewClass<InlineMathInputViewProps, Generated.InlineMathInputViewMembers>;
181
192
  StaticMathquillView: FragileViewClass<StaticMathquillViewProps, Generated.StaticMathquillViewMembers>;
182
193
  Checkbox: FragileViewClass<CheckboxProps, Generated.CheckboxMembers>;
@@ -1,6 +1,6 @@
1
1
  // AUTO-GENERATED by scripts/extract-internals.cjs. Do not edit by hand:
2
2
  // put precise types in the hand-written files in internals/ instead.
3
- // Source: Desmos v1.13-prerelease (commit c2616b6762c586165f75e322fbc6c7b6ab56b394).
3
+ // Source: Desmos v1.13-prerelease (commit 7f0bcd732b59def63b568d6e527e004258e53995).
4
4
  // Actions accepted by each dispatch domain, from static analysis.
5
5
  declare namespace Desmos.Internals.Generated {
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  // AUTO-GENERATED by scripts/extract-internals.cjs. Do not edit by hand:
2
2
  // put precise types in the hand-written files in internals/ instead.
3
- // Source: Desmos v1.13-prerelease (commit c2616b6762c586165f75e322fbc6c7b6ab56b394).
3
+ // Source: Desmos v1.13-prerelease (commit 7f0bcd732b59def63b568d6e527e004258e53995).
4
4
  // Runtime shapes of internal objects.
5
5
  declare namespace Desmos.Internals.Generated {
6
6
  interface Controller {
@@ -1,6 +1,6 @@
1
1
  // AUTO-GENERATED by scripts/extract-internals.cjs. Do not edit by hand:
2
2
  // put precise types in the hand-written files in internals/ instead.
3
- // Source: Desmos v1.13-prerelease (commit c2616b6762c586165f75e322fbc6c7b6ab56b394).
3
+ // Source: Desmos v1.13-prerelease (commit 7f0bcd732b59def63b568d6e527e004258e53995).
4
4
  // Props and instance members of the views on Private.Fragile.
5
5
  declare namespace Desmos.Internals.Generated {
6
6
  /**