cubing 0.54.5 → 0.55.0

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.
@@ -1,1389 +0,0 @@
1
- import { Texture, Object3D, Raycaster, PerspectiveCamera, Scene, WebGLRenderer } from 'three';
2
- import { P as PuzzleSpecificSimplifyOptions, b as AlgLeaf, M as Move, A as Alg, e as Pause, j as AlgLeaf$1, h as AppendCancelOptions, c as AppendOptions, a as AlgNode, I as IterationDirection } from './PuzzleLoader-Ft_XlaHS.js';
3
- import { P as Parsed } from './parseAlg.d-DgyP8Jpl.js';
4
- import { s as KPuzzle, d as PuzzleGeometry, K as KPattern, t as KTransformation, u as PuzzleDescriptionString } from './KPattern.d-tlN4iAuY.js';
5
-
6
- type FaceletMeshStickeringMask = "regular" | "dim" | "oriented" | "experimentalOriented2" | "ignored" | "invisible" | "mystery";
7
- type FaceletStickeringMask = {
8
- mask: FaceletMeshStickeringMask;
9
- hintMask?: FaceletMeshStickeringMask;
10
- };
11
- type PieceStickeringMask = {
12
- facelets: (FaceletMeshStickeringMask | FaceletStickeringMask | null)[];
13
- };
14
- type OrbitStickeringMask = {
15
- pieces: (PieceStickeringMask | null)[];
16
- };
17
- type StickeringMask = {
18
- specialBehaviour?: "picture";
19
- name?: string;
20
- orbits: Record<string, OrbitStickeringMask>;
21
- };
22
-
23
- type KeyMapping = {
24
- [keyCode: string]: AlgLeaf;
25
- };
26
- interface PuzzleLoader {
27
- id: string;
28
- fullName: string;
29
- inventedBy?: string[];
30
- inventionYear?: number;
31
- /** @deprecated */
32
- def?: never;
33
- kpuzzle: () => Promise<KPuzzle>;
34
- svg: () => Promise<string>;
35
- llSVG?: () => Promise<string>;
36
- llFaceSVG?: () => Promise<string>;
37
- pg?: () => Promise<PuzzleGeometry>;
38
- stickeringMask?: (stickering: ExperimentalStickering) => Promise<StickeringMask>;
39
- stickerings?: () => Promise<ExperimentalStickering[]>;
40
- puzzleSpecificSimplifyOptions?: PuzzleSpecificSimplifyOptions;
41
- puzzleSpecificSimplifyOptionsPromise?: Promise<PuzzleSpecificSimplifyOptions>;
42
- keyMapping?: () => Promise<KeyMapping>;
43
- }
44
-
45
- declare const experimentalStickerings: Record<string, {
46
- groups?: Partial<Record<PuzzleID, string>>;
47
- }>;
48
-
49
- type MillisecondTimestamp = number;
50
- type Duration = MillisecondTimestamp;
51
- type Timestamp = MillisecondTimestamp;
52
- declare enum Direction {
53
- Forwards = 1,
54
- Paused = 0,
55
- Backwards = -1
56
- }
57
- interface MoveInProgress {
58
- move: Move;
59
- direction: Direction;
60
- fraction: number;
61
- }
62
- type PuzzlePosition = {
63
- pattern: KPattern;
64
- movesInProgress: MoveInProgress[];
65
- };
66
- declare enum BoundaryType {
67
- Move = "move",
68
- EntireTimeline = "entire-timeline"
69
- }
70
- interface TimeRange {
71
- start: MillisecondTimestamp;
72
- end: MillisecondTimestamp;
73
- }
74
-
75
- interface UserVisibleError {
76
- errors: string[];
77
- }
78
- declare class UserVisibleErrorTracker extends SimpleTwistyPropSource<UserVisibleError> {
79
- getDefaultValue(): UserVisibleError;
80
- reset(): void;
81
- protected canReuseValue(_v1: UserVisibleError, _v2: UserVisibleError): boolean;
82
- }
83
-
84
- type InputRecord = Record<string, any>;
85
- type InputProps<T extends InputRecord> = {
86
- [s in keyof T]: TwistyPropParent<T[s]>;
87
- };
88
- interface SourceEventDetail<OutputType> {
89
- sourceProp: TwistyPropSource<OutputType, any>;
90
- value: Promise<OutputType>;
91
- generation: number;
92
- }
93
- type SourceEvent<T> = CustomEvent<SourceEventDetail<T>>;
94
- type PromiseOrValue<T> = T | Promise<T>;
95
- declare abstract class TwistyPropParent<T> {
96
- #private;
97
- abstract get(): Promise<T>;
98
- canReuse(v1: T, v2: T): boolean;
99
- protected canReuseValue(_v1: T, _v2: T): boolean;
100
- debugGetChildren(): TwistyPropDerived<any, any>[];
101
- protected addChild(child: TwistyPropDerived<any, any>): void;
102
- protected removeChild(child: TwistyPropDerived<any, any>): void;
103
- protected lastSourceGeneration: number;
104
- protected markStale(sourceEvent: SourceEvent<any>): void;
105
- /** @deprecated */
106
- addRawListener(listener: () => void, options?: {
107
- initial: boolean;
108
- }): void;
109
- /** @deprecated */
110
- removeRawListener(listener: () => void): void;
111
- addFreshListener(listener: (value: T) => void): void;
112
- removeFreshListener(listener: (value: T) => void): void;
113
- }
114
- declare abstract class TwistyPropSource<OutputType, InputType = OutputType> extends TwistyPropParent<OutputType> {
115
- #private;
116
- abstract getDefaultValue(): PromiseOrValue<OutputType>;
117
- constructor(initialValue?: PromiseOrValue<InputType>);
118
- set(input: PromiseOrValue<InputType>): void;
119
- get(): Promise<OutputType>;
120
- protected deriveFromPromiseOrValue(input: PromiseOrValue<InputType>, oldValuePromise: Promise<OutputType>): Promise<OutputType>;
121
- protected abstract derive(input: InputType, oldValuePromise: Promise<OutputType>): PromiseOrValue<OutputType>;
122
- }
123
- declare abstract class SimpleTwistyPropSource<SimpleType> extends TwistyPropSource<SimpleType> {
124
- protected derive(input: SimpleType): PromiseOrValue<SimpleType>;
125
- }
126
- declare const NO_VALUE: unique symbol;
127
- type NoValueType = typeof NO_VALUE;
128
- declare abstract class TwistyPropDerived<InputTypes extends InputRecord, OutputType> extends TwistyPropParent<OutputType> {
129
- #private;
130
- protected userVisibleErrorTracker?: UserVisibleErrorTracker | undefined;
131
- constructor(parents: InputProps<InputTypes>, userVisibleErrorTracker?: UserVisibleErrorTracker | undefined);
132
- get(): Promise<OutputType>;
133
- protected abstract derive(input: InputTypes): PromiseOrValue<OutputType>;
134
- }
135
-
136
- type SimpleDirection = Direction.Forwards | Direction.Backwards;
137
- interface PlayingInfo {
138
- playing: boolean;
139
- direction: SimpleDirection;
140
- untilBoundary: BoundaryType;
141
- loop: boolean;
142
- }
143
- declare class PlayingInfoProp extends TwistyPropSource<PlayingInfo, Partial<PlayingInfo>> {
144
- getDefaultValue(): Promise<PlayingInfo>;
145
- protected derive(newInfo: Partial<PlayingInfo>, oldValuePromise: Promise<PlayingInfo>): Promise<PlayingInfo>;
146
- protected canReuseValue(v1: PlayingInfo, v2: PlayingInfo): boolean;
147
- }
148
-
149
- declare class ArbitraryStringProp extends SimpleTwistyPropSource<string | null> {
150
- getDefaultValue(): string | null;
151
- }
152
-
153
- declare class URLProp extends TwistyPropSource<URL | null, URL | string | null> {
154
- getDefaultValue(): URL | null;
155
- derive(input: URL | string | null): URL | null;
156
- }
157
-
158
- declare class AlgIssues {
159
- readonly warnings: readonly string[];
160
- readonly errors: readonly string[];
161
- constructor(issues?: {
162
- warnings?: string[];
163
- errors?: string[];
164
- });
165
- add(issues?: {
166
- warnings?: string[];
167
- errors?: string[];
168
- }): AlgIssues;
169
- /** @deprecated */
170
- log(): void;
171
- }
172
- interface AlgWithIssues {
173
- alg: Alg;
174
- issues: AlgIssues;
175
- }
176
- declare class AlgProp extends TwistyPropSource<AlgWithIssues, Alg | string> {
177
- getDefaultValue(): AlgWithIssues;
178
- protected canReuseValue(v1: AlgWithIssues, v2: AlgWithIssues): boolean;
179
- protected derive(newAlg: Alg | string): Promise<AlgWithIssues>;
180
- }
181
-
182
- type AlgTransformationPropInputs = {
183
- setupAlg: AlgWithIssues;
184
- kpuzzle: KPuzzle;
185
- };
186
- declare class AlgTransformationProp extends TwistyPropDerived<AlgTransformationPropInputs, KTransformation> {
187
- derive(input: AlgTransformationPropInputs): KTransformation;
188
- }
189
-
190
- type AnimatedLeafAlgNode = Move | Pause;
191
-
192
- interface CurrentMove {
193
- move: Move;
194
- direction: Direction;
195
- fraction: number;
196
- startTimestamp: MillisecondTimestamp;
197
- endTimestamp: MillisecondTimestamp;
198
- }
199
- interface CurrentMoveInfo {
200
- patternIndex: number;
201
- currentMoves: CurrentMove[];
202
- movesFinishing: CurrentMove[];
203
- movesFinished: CurrentMove[];
204
- movesStarting: CurrentMove[];
205
- latestStart: number;
206
- earliestEnd: number;
207
- }
208
- interface AlgIndexer {
209
- getAnimLeaf(index: number): AnimatedLeafAlgNode | null;
210
- indexToMoveStartTimestamp(index: number): Timestamp;
211
- patternAtIndex(index: number, startPattern?: KPattern): KPattern;
212
- transformationAtIndex(index: number): KTransformation;
213
- numAnimatedLeaves(): number;
214
- timestampToIndex(timestamp: Timestamp): number;
215
- algDuration(): Duration;
216
- moveDuration(index: number): number;
217
- timestampToPosition?: (timestamp: Timestamp, startPattern?: KPattern) => PuzzlePosition;
218
- currentMoveInfo?: (timestamp: Timestamp) => CurrentMoveInfo;
219
- }
220
-
221
- declare const setupToLocations: {
222
- start: boolean;
223
- end: boolean;
224
- };
225
- type SetupToLocation = keyof typeof setupToLocations;
226
- declare class SetupAnchorProp extends SimpleTwistyPropSource<SetupToLocation> {
227
- getDefaultValue(): SetupToLocation;
228
- }
229
-
230
- interface AnchorTransformationPropInputs {
231
- setupTransformation: KTransformation | null;
232
- setupAnchor: SetupToLocation;
233
- setupAlgTransformation: KTransformation;
234
- indexer: AlgIndexer;
235
- }
236
- declare class AnchorTransformationProp extends TwistyPropDerived<AnchorTransformationPropInputs, KTransformation> {
237
- derive(inputs: AnchorTransformationPropInputs): KTransformation;
238
- }
239
-
240
- interface AnimationTimelineLeaf {
241
- animLeaf: AlgLeaf$1;
242
- start: number;
243
- end: number;
244
- }
245
- type AnimationTimelineLeaves = AnimationTimelineLeaf[];
246
- declare class AnimationTimelineLeavesRequestProp extends SimpleTwistyPropSource<AnimationTimelineLeaf[] | null> {
247
- getDefaultValue(): AnimationTimelineLeaf[] | null;
248
- }
249
-
250
- interface CatchUpMove {
251
- move: Move | null;
252
- amount: number;
253
- }
254
- declare class CatchUpMoveProp extends SimpleTwistyPropSource<CatchUpMove> {
255
- getDefaultValue(): CatchUpMove;
256
- protected canReuseValue(v1: CatchUpMove, v2: CatchUpMove): boolean;
257
- }
258
-
259
- interface CurrentLeavesSimplifiedPropInputs {
260
- currentMoveInfo: CurrentMoveInfo;
261
- }
262
- interface CurrentLeavesSimplified {
263
- patternIndex: number;
264
- movesFinishing: Move[];
265
- movesFinished: Move[];
266
- }
267
- declare class CurrentLeavesSimplifiedProp extends TwistyPropDerived<CurrentLeavesSimplifiedPropInputs, CurrentLeavesSimplified> {
268
- protected derive(inputs: CurrentLeavesSimplifiedPropInputs): CurrentLeavesSimplified;
269
- protected canReuseValue(v1: CurrentLeavesSimplified, v2: CurrentLeavesSimplified): boolean;
270
- }
271
-
272
- declare const smartTimestamps: {
273
- auto: boolean;
274
- start: boolean;
275
- end: boolean;
276
- anchor: boolean;
277
- "opposite-anchor": boolean;
278
- };
279
- type TimestampRequest = MillisecondTimestamp | keyof typeof smartTimestamps;
280
- declare class TimestampRequestProp extends SimpleTwistyPropSource<TimestampRequest> {
281
- getDefaultValue(): TimestampRequest;
282
- set(v: PromiseOrValue<TimestampRequest>): void;
283
- protected validInput(v: TimestampRequest): boolean;
284
- }
285
-
286
- interface DetailedTimelineInfoInputs {
287
- timestampRequest: TimestampRequest;
288
- timeRange: TimeRange;
289
- setupAnchor: SetupToLocation;
290
- setupAlg: AlgWithIssues;
291
- }
292
- interface DetailedTimelineInfo {
293
- timestamp: MillisecondTimestamp;
294
- timeRange: TimeRange;
295
- atStart: boolean;
296
- atEnd: boolean;
297
- }
298
- declare class DetailedTimelineInfoProp extends TwistyPropDerived<DetailedTimelineInfoInputs, DetailedTimelineInfo> {
299
- #private;
300
- protected derive(inputs: DetailedTimelineInfoInputs): DetailedTimelineInfo;
301
- protected canReuseValue(v1: DetailedTimelineInfo, v2: DetailedTimelineInfo): boolean;
302
- }
303
-
304
- interface PositionPropInputs {
305
- indexer: AlgIndexer;
306
- detailedTimelineInfo: DetailedTimelineInfo;
307
- catchUpMove: CatchUpMove;
308
- }
309
- declare class CurrentMoveInfoProp extends TwistyPropDerived<PositionPropInputs, CurrentMoveInfo> {
310
- derive(inputs: PositionPropInputs): CurrentMoveInfo;
311
- }
312
-
313
- interface CurrentTransformationPropInputs {
314
- anchoredStart: KTransformation;
315
- currentLeavesSimplified: CurrentLeavesSimplified;
316
- indexer: AlgIndexer;
317
- }
318
- declare class CurrentPatternProp extends TwistyPropDerived<CurrentTransformationPropInputs, KPattern> {
319
- derive(inputs: CurrentTransformationPropInputs): KPattern;
320
- }
321
-
322
- declare const visualizationFormats: {
323
- readonly "3D": true;
324
- readonly "2D": true;
325
- readonly "experimental-2D-LL": true;
326
- readonly "experimental-2D-LL-face": true;
327
- readonly PG3D: true;
328
- };
329
- type VisualizationFormat = keyof typeof visualizationFormats;
330
- type VisualizationFormatWithAuto = VisualizationFormat | "auto";
331
- declare class VisualizationFormatProp extends SimpleTwistyPropSource<VisualizationFormatWithAuto> {
332
- getDefaultValue(): VisualizationFormatWithAuto;
333
- }
334
-
335
- type VisualizationStrategyPropInputs = {
336
- visualizationRequest: VisualizationFormatWithAuto;
337
- puzzleID: PuzzleID;
338
- };
339
- type VisualizationStrategy = "Cube3D" | "2D" | "experimental-2D-LL" | "experimental-2D-LL-face" | "PG3D";
340
- declare class VisualizationStrategyProp extends TwistyPropDerived<VisualizationStrategyPropInputs, VisualizationStrategy> {
341
- derive(inputs: VisualizationStrategyPropInputs): VisualizationStrategy;
342
- }
343
-
344
- declare const puzzleIDs: {
345
- "3x3x3": boolean;
346
- custom: boolean;
347
- "2x2x2": boolean;
348
- "4x4x4": boolean;
349
- "5x5x5": boolean;
350
- "6x6x6": boolean;
351
- "7x7x7": boolean;
352
- "40x40x40": boolean;
353
- megaminx: boolean;
354
- pyraminx: boolean;
355
- square1: boolean;
356
- clock: boolean;
357
- skewb: boolean;
358
- fto: boolean;
359
- gigaminx: boolean;
360
- master_tetraminx: boolean;
361
- kilominx: boolean;
362
- redi_cube: boolean;
363
- baby_fto: boolean;
364
- melindas2x2x2x2: boolean;
365
- tri_quad: boolean;
366
- loopover: boolean;
367
- };
368
- type PuzzleID = keyof typeof puzzleIDs;
369
- declare class PuzzleIDRequestProp extends SimpleTwistyPropSource<PuzzleID | NoValueType> {
370
- getDefaultValue(): PuzzleID | NoValueType;
371
- }
372
-
373
- declare const indexerStrategyNames: {
374
- auto: boolean;
375
- simple: boolean;
376
- tree: boolean;
377
- simultaneous: boolean;
378
- };
379
- type IndexerStrategyName = keyof typeof indexerStrategyNames;
380
- declare class IndexerConstructorRequestProp extends SimpleTwistyPropSource<IndexerStrategyName> {
381
- getDefaultValue(): IndexerStrategyName;
382
- }
383
-
384
- type IndexerConstructor = new (kpuzzle: KPuzzle, alg: Alg, options?: {
385
- animationTimelineLeaves?: AnimationTimelineLeaves | null;
386
- }) => AlgIndexer;
387
- interface IndexerConstructorPropInputs {
388
- puzzle: PuzzleID;
389
- alg: AlgWithIssues;
390
- visualizationStrategy: VisualizationStrategy;
391
- indexerConstructorRequest: IndexerStrategyName;
392
- animationTimelineLeaves: AnimationTimelineLeaves | null;
393
- }
394
- declare class IndexerConstructorProp extends TwistyPropDerived<IndexerConstructorPropInputs, IndexerConstructor> {
395
- derive(inputs: IndexerConstructorPropInputs): IndexerConstructor;
396
- }
397
-
398
- type IndexerPropInputs = {
399
- indexerConstructor: IndexerConstructor;
400
- algWithIssues: AlgWithIssues;
401
- kpuzzle: KPuzzle;
402
- animationTimelineLeaves: AnimationTimelineLeaves | null;
403
- };
404
- declare class IndexerProp extends TwistyPropDerived<IndexerPropInputs, AlgIndexer> {
405
- derive(input: IndexerPropInputs): AlgIndexer;
406
- }
407
-
408
- interface LegacyPositionPropInputs {
409
- currentMoveInfo: CurrentMoveInfo;
410
- currentPattern: KPattern;
411
- }
412
- declare class LegacyPositionProp extends TwistyPropDerived<LegacyPositionPropInputs, PuzzlePosition> {
413
- derive(inputs: LegacyPositionPropInputs): PuzzlePosition;
414
- }
415
-
416
- declare class PuzzleAlgProp extends TwistyPropDerived<{
417
- algWithIssues: AlgWithIssues;
418
- kpuzzle: KPuzzle;
419
- }, AlgWithIssues> {
420
- derive(inputs: {
421
- algWithIssues: AlgWithIssues;
422
- kpuzzle: KPuzzle;
423
- }): Promise<AlgWithIssues>;
424
- }
425
-
426
- declare class SetupTransformationProp extends SimpleTwistyPropSource<KTransformation | null> {
427
- getDefaultValue(): KTransformation | null;
428
- }
429
-
430
- declare class KPuzzleProp extends TwistyPropDerived<{
431
- puzzleLoader: PuzzleLoader;
432
- }, KPuzzle> {
433
- derive(inputs: {
434
- puzzleLoader: PuzzleLoader;
435
- }): Promise<KPuzzle>;
436
- }
437
-
438
- declare class PGPuzzleDescriptionStringProp extends SimpleTwistyPropSource<PuzzleDescriptionString | NoValueType> {
439
- getDefaultValue(): PuzzleDescriptionString | NoValueType;
440
- }
441
-
442
- declare class PuzzleIDProp extends TwistyPropDerived<{
443
- puzzleLoader: PuzzleLoader;
444
- }, PuzzleID> {
445
- derive(inputs: {
446
- puzzleLoader: PuzzleLoader;
447
- }): Promise<PuzzleID>;
448
- }
449
-
450
- interface PuzzleLoaderPropInputs {
451
- puzzleIDRequest: PuzzleID | NoValueType;
452
- puzzleDescriptionRequest: PuzzleDescriptionString | NoValueType;
453
- }
454
- declare class PuzzleLoaderProp extends TwistyPropDerived<PuzzleLoaderPropInputs, PuzzleLoader> {
455
- derive(inputs: PuzzleLoaderPropInputs): PuzzleLoader;
456
- }
457
-
458
- declare let HTMLElementShim: typeof HTMLElement;
459
-
460
- declare class ManagedCustomElement extends HTMLElementShim {
461
- readonly shadow: ShadowRoot;
462
- readonly contentWrapper: HTMLDivElement;
463
- constructor(options?: {
464
- mode?: "open" | "closed";
465
- });
466
- protected addCSS(cssSource: CSSStyleSheet): void;
467
- protected removeCSS(cssSource: CSSStyleSheet): void;
468
- addElement<T extends Node>(element: T): T;
469
- prependElement<T extends Node>(element: T): void;
470
- removeElement<T extends Node>(element: T): T;
471
- }
472
-
473
- declare const viewerLinkPages: {
474
- twizzle: boolean;
475
- "experimental-twizzle-explorer": boolean;
476
- none: boolean;
477
- };
478
- type ViewerLinkPage = keyof typeof viewerLinkPages;
479
- type ViewerLinkPageWithAuto = ViewerLinkPage | "auto";
480
- declare class ViewerLinkProp extends SimpleTwistyPropSource<ViewerLinkPageWithAuto> {
481
- getDefaultValue(): ViewerLinkPageWithAuto;
482
- }
483
-
484
- declare const buttonIcons: string[];
485
- type ButtonIcon = (typeof buttonIcons)[number];
486
- interface ButtonAppearance {
487
- enabled: boolean;
488
- icon: ButtonIcon;
489
- title: string;
490
- hidden?: boolean;
491
- }
492
- type ButtonAppearances = Record<ButtonCommand, ButtonAppearance>;
493
- interface ButtonAppearancePropInputs {
494
- coarseTimelineInfo: CoarseTimelineInfo;
495
- viewerLink: ViewerLinkPageWithAuto;
496
- }
497
- declare class ButtonAppearanceProp extends TwistyPropDerived<ButtonAppearancePropInputs, ButtonAppearances> {
498
- derive(inputs: ButtonAppearancePropInputs): ButtonAppearances;
499
- }
500
-
501
- declare class TwistyPlayerController {
502
- private model;
503
- animationController: TwistyAnimationController;
504
- constructor(model: TwistyPlayerModel, delegate: TwistyAnimationControllerDelegate);
505
- jumpToStart(options?: {
506
- flash: boolean;
507
- }): void;
508
- jumpToEnd(options?: {
509
- flash: boolean;
510
- }): void;
511
- togglePlay(play?: boolean): void;
512
- visitTwizzleLink(): Promise<void>;
513
- }
514
-
515
- declare const colorSchemes: {
516
- light: boolean;
517
- dark: boolean;
518
- };
519
- type ColorScheme = keyof typeof colorSchemes;
520
- type ColorSchemeWithAuto = ColorScheme | "auto";
521
- declare class ColorSchemeRequestProp extends SimpleTwistyPropSource<ColorSchemeWithAuto> {
522
- getDefaultValue(): ColorSchemeWithAuto;
523
- }
524
-
525
- declare const buttonCommands: {
526
- fullscreen: boolean;
527
- "jump-to-start": boolean;
528
- "play-step-backwards": boolean;
529
- "play-pause": boolean;
530
- "play-step": boolean;
531
- "jump-to-end": boolean;
532
- "twizzle-link": boolean;
533
- };
534
- type ButtonCommand = keyof typeof buttonCommands;
535
- declare class TwistyButtons extends ManagedCustomElement {
536
- #private;
537
- model?: TwistyPlayerModel | undefined;
538
- controller?: TwistyPlayerController | undefined;
539
- private defaultFullscreenElement?;
540
- buttons: Record<ButtonCommand, TwistyButton> | null;
541
- constructor(model?: TwistyPlayerModel | undefined, controller?: TwistyPlayerController | undefined, defaultFullscreenElement?: HTMLElement | undefined);
542
- connectedCallback(): void;
543
- onFullscreenButton(): Promise<void>;
544
- update(buttonAppearances: ButtonAppearances): Promise<void>;
545
- updateColorScheme(colorScheme: ColorScheme): void;
546
- }
547
- declare class TwistyButton extends ManagedCustomElement {
548
- #private;
549
- htmlButton: HTMLButtonElement;
550
- updateColorScheme(colorScheme: ColorScheme): void;
551
- connectedCallback(): void;
552
- setIcon(iconName: ButtonIcon): void;
553
- }
554
-
555
- interface CoarseTimelineInfoInputs {
556
- playingInfo: PlayingInfo;
557
- detailedTimelineInfo: DetailedTimelineInfo;
558
- }
559
- interface CoarseTimelineInfo {
560
- playing: boolean;
561
- atStart: boolean;
562
- atEnd: boolean;
563
- }
564
- declare class CoarseTimelineInfoProp extends TwistyPropDerived<CoarseTimelineInfoInputs, CoarseTimelineInfo> {
565
- protected derive(inputs: CoarseTimelineInfoInputs): CoarseTimelineInfo;
566
- protected canReuseValue(v1: CoarseTimelineInfo, v2: CoarseTimelineInfo): boolean;
567
- }
568
-
569
- declare class TempoScaleProp extends TwistyPropSource<number, number> {
570
- getDefaultValue(): number;
571
- derive(v: number): number;
572
- }
573
-
574
- declare const backViewLayouts: {
575
- none: boolean;
576
- "side-by-side": boolean;
577
- "top-right": boolean;
578
- };
579
- type BackViewLayout = keyof typeof backViewLayouts;
580
- type BackViewLayoutWithAuto = BackViewLayout | "auto";
581
- declare class BackViewProp extends SimpleTwistyPropSource<BackViewLayoutWithAuto> {
582
- getDefaultValue(): BackViewLayoutWithAuto;
583
- }
584
-
585
- declare const controlsLocations: {
586
- "bottom-row": boolean;
587
- none: boolean;
588
- };
589
- type ControlsLocation = keyof typeof controlsLocations;
590
- type ControlPanelThemeWithAuto = ControlsLocation | "auto";
591
- declare class ControlPanelProp extends SimpleTwistyPropSource<ControlPanelThemeWithAuto> {
592
- getDefaultValue(): ControlPanelThemeWithAuto;
593
- }
594
-
595
- declare class TimeRangeProp extends TwistyPropDerived<{
596
- indexer: AlgIndexer;
597
- }, TimeRange> {
598
- derive(inputs: {
599
- indexer: AlgIndexer;
600
- }): TimeRange;
601
- }
602
-
603
- type FaceletScale = "auto" | number;
604
- declare class FaceletScaleProp extends SimpleTwistyPropSource<FaceletScale> {
605
- getDefaultValue(): FaceletScale;
606
- }
607
-
608
- type FoundationDisplay = "auto" | "opaque" | "none";
609
- declare class FoundationDisplayProp extends SimpleTwistyPropSource<FoundationDisplay> {
610
- getDefaultValue(): FoundationDisplay;
611
- }
612
-
613
- declare const hintFaceletStyles: {
614
- floating: boolean;
615
- none: boolean;
616
- };
617
- type HintFaceletStyle = keyof typeof hintFaceletStyles;
618
- type HintFaceletStyleWithAuto = HintFaceletStyle | "auto";
619
- declare class HintFaceletProp extends SimpleTwistyPropSource<HintFaceletStyleWithAuto> {
620
- getDefaultValue(): HintFaceletStyleWithAuto;
621
- }
622
-
623
- type InitialHintFaceletsAnimation = "auto" | "always" | "none";
624
- declare class InitialHintFaceletsAnimationProp extends SimpleTwistyPropSource<InitialHintFaceletsAnimation> {
625
- getDefaultValue(): InitialHintFaceletsAnimation;
626
- }
627
-
628
- type SpritePropInputs = {
629
- spriteURL: URL | null;
630
- };
631
- declare class SpriteProp extends TwistyPropDerived<SpritePropInputs, Texture | null> {
632
- derive(inputs: SpritePropInputs): Promise<Texture | null>;
633
- }
634
-
635
- type ExperimentalStickering = keyof typeof experimentalStickerings;
636
- declare class StickeringRequestProp extends SimpleTwistyPropSource<ExperimentalStickering | null> {
637
- getDefaultValue(): ExperimentalStickering | null;
638
- }
639
-
640
- interface StickeringMaskPropInputs {
641
- stickeringMaskRequest: StickeringMask | null;
642
- stickeringRequest: ExperimentalStickering | null;
643
- puzzleLoader: PuzzleLoader;
644
- }
645
- declare class StickeringMaskProp extends TwistyPropDerived<StickeringMaskPropInputs, StickeringMask> {
646
- getDefaultValue(): StickeringMask;
647
- derive(inputs: StickeringMaskPropInputs): Promise<StickeringMask>;
648
- }
649
-
650
- declare class StickeringMaskRequestProp extends TwistyPropSource<StickeringMask | null, string | StickeringMask | null> {
651
- getDefaultValue(): StickeringMask | null;
652
- derive(input: string | StickeringMask | null): StickeringMask | null;
653
- }
654
-
655
- declare const dragInputModes: {
656
- auto: boolean;
657
- none: boolean;
658
- };
659
- type DragInputMode = keyof typeof dragInputModes;
660
- declare class DragInputProp extends SimpleTwistyPropSource<DragInputMode> {
661
- getDefaultValue(): DragInputMode;
662
- }
663
-
664
- declare class MovePressCancelOptions extends SimpleTwistyPropSource<AppendCancelOptions> {
665
- getDefaultValue(): AppendCancelOptions;
666
- }
667
-
668
- declare const movePressInputNames: {
669
- auto: boolean;
670
- none: boolean;
671
- basic: boolean;
672
- };
673
- type MovePressInput = keyof typeof movePressInputNames;
674
- declare class MovePressInputProp extends SimpleTwistyPropSource<MovePressInput> {
675
- getDefaultValue(): MovePressInput;
676
- }
677
-
678
- declare const backgroundThemes: {
679
- checkered: boolean;
680
- "checkered-transparent": boolean;
681
- none: boolean;
682
- };
683
- type BackgroundTheme = keyof typeof backgroundThemes;
684
- type BackgroundThemeWithAuto = BackgroundTheme | "auto";
685
- declare class BackgroundProp extends SimpleTwistyPropSource<BackgroundThemeWithAuto> {
686
- getDefaultValue(): BackgroundThemeWithAuto;
687
- }
688
-
689
- interface ColorSchemePropInputs {
690
- colorSchemeRequest: ColorSchemeWithAuto;
691
- }
692
- declare class ColorSchemeProp extends TwistyPropDerived<ColorSchemePropInputs, ColorScheme> {
693
- protected derive(inputs: ColorSchemePropInputs): ColorScheme;
694
- }
695
-
696
- declare class DOMElementReferenceProp extends SimpleTwistyPropSource<Element | null> {
697
- getDefaultValue(): Element | null;
698
- }
699
-
700
- type CoordinateDegrees = number;
701
- interface OrbitCoordinates {
702
- latitude: CoordinateDegrees;
703
- longitude: CoordinateDegrees;
704
- distance: number;
705
- }
706
- type OrbitCoordinatesRequest = Partial<OrbitCoordinates> | "auto";
707
- declare class OrbitCoordinatesRequestProp extends TwistyPropSource<OrbitCoordinatesRequest, Partial<OrbitCoordinates> | "auto"> {
708
- getDefaultValue(): OrbitCoordinatesRequest;
709
- protected canReuseValue(v1: OrbitCoordinates, v2: OrbitCoordinates): boolean;
710
- protected derive(newCoordinates: Partial<OrbitCoordinates> | "auto", oldValuePromise: Promise<OrbitCoordinatesRequest>): Promise<OrbitCoordinatesRequest>;
711
- }
712
-
713
- declare class LatitudeLimitProp extends SimpleTwistyPropSource<CoordinateDegrees> {
714
- getDefaultValue(): CoordinateDegrees;
715
- }
716
-
717
- interface OrbitCoordinatesPropInputs {
718
- orbitCoordinatesRequest: OrbitCoordinatesRequest;
719
- latitudeLimit: CoordinateDegrees;
720
- puzzleID: PuzzleID;
721
- strategy: VisualizationStrategy;
722
- }
723
- declare class OrbitCoordinatesProp extends TwistyPropDerived<OrbitCoordinatesPropInputs, OrbitCoordinates> {
724
- canReuseValue(v1: OrbitCoordinates, v2: OrbitCoordinates): boolean;
725
- derive(inputs: OrbitCoordinatesPropInputs): Promise<OrbitCoordinates>;
726
- }
727
-
728
- declare class TwistySceneModel {
729
- twistyPlayerModel: TwistyPlayerModel;
730
- background: BackgroundProp;
731
- colorSchemeRequest: ColorSchemeRequestProp;
732
- dragInput: DragInputProp;
733
- foundationDisplay: FoundationDisplayProp;
734
- foundationStickerSpriteURL: URLProp;
735
- fullscreenElement: DOMElementReferenceProp;
736
- hintFacelet: HintFaceletProp;
737
- hintStickerSpriteURL: URLProp;
738
- initialHintFaceletsAnimation: InitialHintFaceletsAnimationProp;
739
- latitudeLimit: LatitudeLimitProp;
740
- movePressInput: MovePressInputProp;
741
- movePressCancelOptions: MovePressCancelOptions;
742
- orbitCoordinatesRequest: OrbitCoordinatesRequestProp;
743
- stickeringMaskRequest: StickeringMaskRequestProp;
744
- stickeringRequest: StickeringRequestProp;
745
- faceletScale: FaceletScaleProp;
746
- colorScheme: ColorSchemeProp;
747
- foundationStickerSprite: SpriteProp;
748
- hintStickerSprite: SpriteProp;
749
- orbitCoordinates: OrbitCoordinatesProp;
750
- stickeringMask: StickeringMaskProp;
751
- constructor(twistyPlayerModel: TwistyPlayerModel);
752
- }
753
-
754
- type Without<T, K extends string[]> = Pick<T, Exclude<keyof T, K[number]>>;
755
- declare class TwistyPlayerModel {
756
- userVisibleErrorTracker: UserVisibleErrorTracker;
757
- alg: AlgProp;
758
- backView: BackViewProp;
759
- controlPanel: ControlPanelProp;
760
- catchUpMove: CatchUpMoveProp;
761
- indexerConstructorRequest: IndexerConstructorRequestProp;
762
- playingInfo: PlayingInfoProp;
763
- puzzleDescriptionRequest: PGPuzzleDescriptionStringProp;
764
- puzzleIDRequest: PuzzleIDRequestProp;
765
- setupAnchor: SetupAnchorProp;
766
- setupAlg: AlgProp;
767
- setupTransformation: SetupTransformationProp;
768
- tempoScale: TempoScaleProp;
769
- timestampRequest: TimestampRequestProp;
770
- viewerLink: ViewerLinkProp;
771
- visualizationFormat: VisualizationFormatProp;
772
- title: ArbitraryStringProp;
773
- videoURL: URLProp;
774
- competitionID: ArbitraryStringProp;
775
- animationTimelineLeavesRequest: AnimationTimelineLeavesRequestProp;
776
- puzzleLoader: PuzzleLoaderProp;
777
- kpuzzle: KPuzzleProp;
778
- puzzleID: PuzzleIDProp;
779
- puzzleAlg: PuzzleAlgProp;
780
- puzzleSetupAlg: PuzzleAlgProp;
781
- visualizationStrategy: VisualizationStrategyProp;
782
- indexerConstructor: IndexerConstructorProp;
783
- setupAlgTransformation: AlgTransformationProp;
784
- indexer: IndexerProp;
785
- anchorTransformation: AnchorTransformationProp;
786
- timeRange: TimeRangeProp;
787
- detailedTimelineInfo: DetailedTimelineInfoProp;
788
- coarseTimelineInfo: CoarseTimelineInfoProp;
789
- currentMoveInfo: CurrentMoveInfoProp;
790
- buttonAppearance: ButtonAppearanceProp;
791
- currentLeavesSimplified: CurrentLeavesSimplifiedProp;
792
- currentPattern: CurrentPatternProp;
793
- legacyPosition: LegacyPositionProp;
794
- twistySceneModel: TwistySceneModel;
795
- twizzleLink(): Promise<string>;
796
- experimentalAddAlgLeaf(algLeaf: AlgLeaf, options?: AppendOptions): void;
797
- experimentalAddMove(flexibleMove: Move | string, options?: Without<AppendOptions, [
798
- "puzzleLoader",
799
- "puzzleSpecificSimplifyOptions"
800
- ]>): void;
801
- experimentalRemoveFinalChild(): void;
802
- }
803
-
804
- interface TwistyAnimationControllerDelegate {
805
- flash(): void;
806
- }
807
- declare class TwistyAnimationController {
808
- #private;
809
- private delegate;
810
- private playing;
811
- private direction;
812
- private catchUpHelper;
813
- private model;
814
- private lastDatestamp;
815
- private lastTimestampPromise;
816
- private scheduler;
817
- constructor(model: TwistyPlayerModel, delegate: TwistyAnimationControllerDelegate);
818
- onPlayingProp(playingInfo: PlayingInfo): Promise<void>;
819
- onCatchUpMoveProp(catchUpMove: CatchUpMove): Promise<void>;
820
- jumpToStart(options?: {
821
- flash: boolean;
822
- }): void;
823
- jumpToEnd(options?: {
824
- flash: boolean;
825
- }): void;
826
- playPause(): void;
827
- play(options?: {
828
- direction?: SimpleDirection;
829
- untilBoundary?: BoundaryType;
830
- autoSkipToOtherEndIfStartingAtBoundary?: boolean;
831
- loop?: boolean;
832
- }): Promise<void>;
833
- pause(): void;
834
- animFrame(frameDatestamp: MillisecondTimestamp): Promise<void>;
835
- }
836
-
837
- /**
838
- * @author mrdoob / http://mrdoob.com/
839
- * ESM conversion by Lucas Garron, 2021-12-21
840
- */
841
- declare class Stats {
842
- mode: number;
843
- dom: HTMLDivElement;
844
- constructor();
845
- addPanel(panel: StatsPanel): StatsPanel;
846
- showPanel(id: number): void;
847
- beginTime: number;
848
- prevTime: number;
849
- frames: number;
850
- fpsPanel: StatsPanel;
851
- msPanel: StatsPanel;
852
- memPanel: StatsPanel | null;
853
- REVISION: number;
854
- begin(): void;
855
- end(): number;
856
- update(): void;
857
- }
858
- declare class StatsPanel {
859
- private name;
860
- private fg;
861
- private bg;
862
- min: number;
863
- max: number;
864
- dom: HTMLCanvasElement;
865
- context: CanvasRenderingContext2D;
866
- constructor(name: string, fg: string, bg: string);
867
- update(value: number, maxValue: number): void;
868
- }
869
-
870
- interface Schedulable {
871
- scheduleRender(): void;
872
- }
873
-
874
- interface DragMovementInfo {
875
- attachedInfo: Record<any, any>;
876
- movementX: number;
877
- movementY: number;
878
- elapsedMs: number;
879
- }
880
- interface PressInfo {
881
- normalizedX: number;
882
- normalizedY: number;
883
- rightClick: boolean;
884
- keys: {
885
- altKey: boolean;
886
- ctrlOrMetaKey: boolean;
887
- shiftKey: boolean;
888
- };
889
- }
890
- declare class DragTracker extends EventTarget {
891
- #private;
892
- readonly target: HTMLElement;
893
- constructor(target: HTMLElement);
894
- start(): void;
895
- stop(): void;
896
- addTargetListener(eventType: string, listener: (e: MouseEvent) => any): void;
897
- private onPointerDown;
898
- private onPointerMove;
899
- private onPointerUp;
900
- }
901
-
902
- interface Twisty3DPuzzle extends Object3D {
903
- onPositionChange(position: PuzzlePosition): void;
904
- setStickeringMask(stickeringMask: StickeringMask): void;
905
- }
906
-
907
- declare class Twisty3DPuzzleWrapper extends EventTarget implements Schedulable {
908
- #private;
909
- private model;
910
- schedulable: Schedulable;
911
- private puzzleLoader;
912
- private visualizationStrategy;
913
- constructor(model: TwistyPlayerModel, schedulable: Schedulable, puzzleLoader: PuzzleLoader, visualizationStrategy: VisualizationStrategy);
914
- disconnect(): void;
915
- scheduleRender(): void;
916
- twisty3DPuzzle(): Promise<Twisty3DPuzzle>;
917
- raycastMove(raycasterPromise: Promise<Raycaster>, transformations: {
918
- invert: boolean;
919
- depth?: "secondSlice" | "rotation" | "none";
920
- }): Promise<void>;
921
- }
922
-
923
- declare class Twisty3DSceneWrapper extends ManagedCustomElement implements Schedulable {
924
- #private;
925
- model?: TwistyPlayerModel | undefined;
926
- disconnect(): void;
927
- constructor(model?: TwistyPlayerModel | undefined);
928
- connectedCallback(): Promise<void>;
929
- setBackView(backView: BackViewLayout): void;
930
- onBackView(backView: BackViewLayout): void;
931
- onPress(e: CustomEvent<{
932
- pressInfo: PressInfo;
933
- cameraPromise: Promise<PerspectiveCamera>;
934
- }>): Promise<void>;
935
- scene(): Promise<Scene>;
936
- addVantage(vantage: Twisty3DVantage): void;
937
- removeVantage(vantage: Twisty3DVantage): void;
938
- experimentalVantages(): Iterable<Twisty3DVantage>;
939
- scheduleRender(): void;
940
- setCurrentTwisty3DPuzzleWrapper(scene: Scene, twisty3DPuzzleWrapper: Twisty3DPuzzleWrapper): Promise<void>;
941
- /** @deprecated */
942
- experimentalTwisty3DPuzzleWrapper(): Promise<Twisty3DPuzzleWrapper>;
943
- onPuzzle(inputs: [
944
- puzzleLoader: PuzzleLoader,
945
- visualizationStrategy: VisualizationStrategy
946
- ]): Promise<void>;
947
- }
948
-
949
- declare class TwistyOrbitControls {
950
- private model;
951
- private mirror;
952
- private canvas;
953
- private dragTracker;
954
- /** @deprecated */
955
- experimentalInertia: boolean;
956
- private onMovementBound;
957
- experimentalHasBeenMoved: boolean;
958
- constructor(model: TwistyPlayerModel, mirror: boolean, canvas: HTMLCanvasElement, dragTracker: DragTracker);
959
- temperMovement(f: number): number;
960
- onMove(e: CustomEvent<DragMovementInfo>): void;
961
- onMovement(movementX: number, movementY: number): {
962
- temperedX: number;
963
- temperedY: number;
964
- };
965
- onUp(e: CustomEvent<DragMovementInfo>): void;
966
- }
967
-
968
- declare class Twisty3DVantage extends ManagedCustomElement {
969
- #private;
970
- private model?;
971
- private options?;
972
- scene: Twisty3DSceneWrapper | null;
973
- stats: Stats | null;
974
- private rendererIsShared;
975
- loadingElement: HTMLDivElement | null;
976
- constructor(model?: TwistyPlayerModel | undefined, scene?: Twisty3DSceneWrapper, options?: {
977
- backView?: boolean;
978
- } | undefined);
979
- connectedCallback(): Promise<void>;
980
- clearCanvas(): Promise<void>;
981
- renderer(): Promise<WebGLRenderer>;
982
- canvasInfo(): Promise<{
983
- canvas: HTMLCanvasElement;
984
- context: CanvasRenderingContext2D;
985
- }>;
986
- camera(): Promise<PerspectiveCamera>;
987
- orbitControls(): Promise<TwistyOrbitControls>;
988
- addListener<T>(prop: TwistyPropParent<T>, listener: (value: T) => void): void;
989
- disconnect(): void;
990
- experimentalNextRenderFinishedCallback(callback: () => void): void;
991
- render(): Promise<void>;
992
- scheduleRender(): void;
993
- }
994
-
995
- declare abstract class TwistyPlayerSettable extends ManagedCustomElement {
996
- experimentalModel: TwistyPlayerModel;
997
- set alg(newAlg: Alg | string);
998
- get alg(): never;
999
- set experimentalSetupAlg(newSetup: Alg | string);
1000
- get experimentalSetupAlg(): never;
1001
- set experimentalSetupAnchor(anchor: SetupToLocation);
1002
- get experimentalSetupAnchor(): never;
1003
- set puzzle(puzzleID: PuzzleID);
1004
- get puzzle(): never;
1005
- set experimentalPuzzleDescription(puzzleDescription: PuzzleDescriptionString);
1006
- get experimentalPuzzleDescription(): never;
1007
- set timestamp(timestamp: TimestampRequest);
1008
- get timestamp(): never;
1009
- set hintFacelets(hintFaceletStyle: HintFaceletStyleWithAuto);
1010
- get hintFacelets(): never;
1011
- set experimentalStickering(stickering: ExperimentalStickering);
1012
- get experimentalStickering(): never;
1013
- set experimentalStickeringMaskOrbits(stickeringMask: string | StickeringMask);
1014
- get experimentalStickeringMaskOrbits(): never;
1015
- set experimentalFaceletScale(faceletScale: FaceletScale);
1016
- get experimentalFaceletScale(): never;
1017
- set backView(backView: BackViewLayoutWithAuto);
1018
- get backView(): never;
1019
- set background(backgroundTheme: BackgroundThemeWithAuto);
1020
- get background(): never;
1021
- set colorScheme(colorScheme: ColorSchemeWithAuto);
1022
- get colorScheme(): never;
1023
- set controlPanel(newControlPanel: ControlPanelThemeWithAuto);
1024
- get controlPanel(): never;
1025
- set visualization(visualizationFormat: VisualizationFormatWithAuto);
1026
- get visualization(): never;
1027
- set experimentalTitle(title: string | null);
1028
- get experimentalTitle(): never;
1029
- set experimentalVideoURL(videoURL: string | null);
1030
- get experimentalVideoURL(): never;
1031
- set experimentalCompetitionID(competitionID: string | null);
1032
- get experimentalCompetitionID(): never;
1033
- set viewerLink(viewerLinkPage: ViewerLinkPageWithAuto);
1034
- get viewerLink(): never;
1035
- set experimentalMovePressInput(movePressInput: MovePressInput);
1036
- get experimentalMovePressInput(): never;
1037
- set experimentalMovePressCancelOptions(movePressCancelOptions: AppendCancelOptions);
1038
- get experimentalMovePressCancelOptions(): never;
1039
- set cameraLatitude(latitude: number);
1040
- get cameraLatitude(): never;
1041
- set cameraLongitude(longitude: number);
1042
- get cameraLongitude(): never;
1043
- set cameraDistance(distance: number);
1044
- get cameraDistance(): never;
1045
- set cameraLatitudeLimit(latitudeLimit: number);
1046
- get cameraLatitudeLimit(): never;
1047
- set indexer(indexer: IndexerStrategyName);
1048
- get indexer(): never;
1049
- set tempoScale(newTempoScale: number);
1050
- get tempoScale(): never;
1051
- set experimentalSprite(url: string | URL);
1052
- get experimentalSprite(): never;
1053
- set experimentalHintSprite(url: string | URL);
1054
- get experimentalHintSprite(): never;
1055
- set fullscreenElement(element: Element | null);
1056
- get fullscreenElement(): never;
1057
- set experimentalInitialHintFaceletsAnimation(anim: InitialHintFaceletsAnimation);
1058
- get experimentalInitialHintFaceletsAnimation(): never;
1059
- set experimentalDragInput(dragInputMode: DragInputMode);
1060
- get experimentalDragInput(): never;
1061
- experimentalGet: ExperimentalGetters;
1062
- }
1063
- declare class ExperimentalGetters {
1064
- private model;
1065
- constructor(model: TwistyPlayerModel);
1066
- alg(): Promise<Alg>;
1067
- setupAlg(): Promise<Alg>;
1068
- puzzleID(): Promise<PuzzleID>;
1069
- timestamp(): Promise<MillisecondTimestamp>;
1070
- }
1071
-
1072
- /**
1073
- * The config argument passed to {@link TwistyPlayer} when calling the
1074
- * constructor. This interface type be useful for avoiding bugs when you would
1075
- * like to create a {@link TwistyPlayer} using a dynamic config, or by combining
1076
- * configs.
1077
- *
1078
- * ```js
1079
- * import { TwistyPlayer, type TwistyPlayerConfig } from "cubing/twisty";
1080
- *
1081
- * const MY_DEFAULT_CONFIG: TwistyPlayerConfig = {
1082
- * puzzle: "megaminx",
1083
- * alg: "R U R'"
1084
- * };
1085
- * export function createTwistyPlayer(overrideConfig: TwistyPlayerConfig) {
1086
- * const options = { ...MY_DEFAULT_CONFIG, ...overrideConfig };
1087
- * return new TwistyPlayer(options);
1088
- * }
1089
- *
1090
- * // Example: if the current page is https://alpha.twizzle.net/edit/?alg=M2+E2+S2
1091
- * // then this gives us the "alg" param value "M2 E2 S2".
1092
- * const myOverrideConfig: TwistyPlayerConfig = {};
1093
- * const algParam = new URL(location.href).searchParams.get("alg");
1094
- * if (algParam) {
1095
- * myOverrideConfig.alg = algParam;
1096
- * }
1097
- * createTwistyPlayer(myOverrideConfig);
1098
- * ```
1099
- *
1100
- * @category TwistyPlayer
1101
- */
1102
- interface TwistyPlayerConfig {
1103
- alg?: Alg | string;
1104
- experimentalSetupAlg?: Alg | string;
1105
- experimentalSetupAnchor?: SetupToLocation;
1106
- puzzle?: PuzzleID;
1107
- experimentalPuzzleDescription?: PuzzleDescriptionString;
1108
- visualization?: VisualizationFormatWithAuto;
1109
- hintFacelets?: HintFaceletStyleWithAuto;
1110
- experimentalStickering?: ExperimentalStickering;
1111
- experimentalStickeringMaskOrbits?: StickeringMask | string;
1112
- background?: BackgroundThemeWithAuto;
1113
- colorScheme?: ColorSchemeWithAuto;
1114
- controlPanel?: ControlPanelThemeWithAuto;
1115
- backView?: BackViewLayoutWithAuto;
1116
- experimentalInitialHintFaceletsAnimation?: InitialHintFaceletsAnimation;
1117
- viewerLink?: ViewerLinkPageWithAuto;
1118
- experimentalMovePressInput?: MovePressInput;
1119
- experimentalDragInput?: DragInputMode;
1120
- experimentalTitle?: string | null;
1121
- experimentalVideoURL?: string;
1122
- experimentalCompetitionID?: string;
1123
- cameraLatitude?: number;
1124
- cameraLongitude?: number;
1125
- cameraDistance?: number;
1126
- cameraLatitudeLimit?: number;
1127
- tempoScale?: number;
1128
- experimentalSprite?: string | null;
1129
- experimentalHintSprite?: string | null;
1130
- experimentalMovePressCancelOptions?: AppendCancelOptions;
1131
- }
1132
- declare const intersectedCallback: unique symbol;
1133
- /**
1134
- * TwistyPlayer is the heart of `cubing.js`. It can be used to display a puzzle on a web page like this:
1135
- *
1136
- * <script src="path/to/cubing/twisty" type="module"></script>
1137
- * <twisty-player alg="R U R'"></twisty-player>
1138
- *
1139
- * You can also construct it directly in JavaScript:
1140
- *
1141
- * ```js
1142
- * import { TwistyPlayer } from "cubing/twisty";
1143
- * const twistyPlayer = new TwistyPlayer({alg: "R U R'"});
1144
- * // Once the page has loaded, you can do this:
1145
- * document.body.appendChild(twistyPlayer);
1146
- * ```
1147
- *
1148
- * See {@link https://js.cubing.net/cubing/} for more examples.
1149
- *
1150
- * @category TwistyPlayer
1151
- */
1152
- declare class TwistyPlayer extends TwistyPlayerSettable implements TwistyAnimationControllerDelegate {
1153
- #private;
1154
- controller: TwistyPlayerController;
1155
- buttons: TwistyButtons;
1156
- experimentalCanvasClickCallback: (...args: any) => void;
1157
- constructor(config?: TwistyPlayerConfig);
1158
- connectedCallback(): Promise<void>;
1159
- [intersectedCallback](): Promise<void>;
1160
- /** @deprecated */
1161
- experimentalSetFlashLevel(newLevel: "auto" | "none"): void;
1162
- flash(): void;
1163
- experimentalCurrentVantages(): Promise<Iterable<Twisty3DVantage>>;
1164
- experimentalCurrentCanvases(): Promise<HTMLCanvasElement[]>;
1165
- /**
1166
- * Get the first available puzzle `Object3D`. This can be inserted into
1167
- * another `three.js` scene, essentially "adopting" it from the
1168
- * `TwistyPlayer`'s scenes while still allowing the `TwistyPlayer` to animate
1169
- * it. The function returns a `Promise` that returns if and when the
1170
- * `Object3D` is available, and accepts a callback that is called whenever a
1171
- * render is scheduled for the puzzle (essentially, if something about the
1172
- * puzzle has changed, like its appearance or current animated state).
1173
- *
1174
- * Note:
1175
- * - This may never resolve if the player never creates the relevant 3D object
1176
- * under the hood (e.g. if the config is set to 2D, or is not valid for
1177
- * rendering a puzzle)
1178
- * - The architecture of `cubing.js` may change significantly, so it is not
1179
- * guaranteed that a `three.js` `Object3D` will be available from the main
1180
- * thread in the future.
1181
- * - This function only returns the current `three.js` puzzle object (once one
1182
- * exists). If you change e.g. the `puzzle` config for the player, then the
1183
- * object will currently become stale. This may be replaced with more
1184
- * convenient behaviour in the future.
1185
- *
1186
- * @deprecated */
1187
- experimentalCurrentThreeJSPuzzleObject(puzzleRenderScheduledCallback?: () => void): Promise<Object3D>;
1188
- jumpToStart(options?: {
1189
- flash: boolean;
1190
- }): void;
1191
- jumpToEnd(options?: {
1192
- flash: boolean;
1193
- }): void;
1194
- play(): void;
1195
- pause(): void;
1196
- togglePlay(play?: boolean): void;
1197
- experimentalAddMove(flexibleMove: Move | string, options?: AppendOptions): void;
1198
- experimentalAddAlgLeaf(algLeaf: AlgLeaf, options?: AppendOptions): void;
1199
- static get observedAttributes(): string[];
1200
- experimentalRemoveFinalChild(): void;
1201
- attributeChangedCallback(attributeName: string, _oldValue: string, newValue: string): void;
1202
- experimentalScreenshot(options?: {
1203
- width: number;
1204
- height: number;
1205
- }): Promise<string>;
1206
- experimentalDownloadScreenshot(filename?: string): Promise<void>;
1207
- }
1208
- declare global {
1209
- interface HTMLElementTagNameMap {
1210
- "twisty-player": TwistyPlayer;
1211
- }
1212
- }
1213
-
1214
- declare class DataDown {
1215
- earliestMoveIndex: number;
1216
- twistyAlgViewer: TwistyAlgViewer;
1217
- direction: IterationDirection;
1218
- }
1219
- declare class DataUp {
1220
- moveCount: number;
1221
- element: TwistyAlgWrapperElem | TwistyAlgLeafElem;
1222
- }
1223
- declare class TwistyAlgLeafElem extends ManagedCustomElement {
1224
- algOrAlgNode: Alg | AlgNode;
1225
- constructor(className: string, text: string, dataDown: DataDown, algOrAlgNode: Alg | AlgNode, offsetIntoMove: boolean, clickable: boolean);
1226
- pathToIndex(_index: number): (TwistyAlgWrapperElem | TwistyAlgLeafElem)[];
1227
- setCurrentMove(current: boolean): void;
1228
- }
1229
- declare class TwistyAlgWrapperElem extends HTMLElementShim {
1230
- algOrAlgNode: Alg | AlgNode;
1231
- private queue;
1232
- constructor(className: string, algOrAlgNode: Alg | AlgNode);
1233
- addString(str: string): void;
1234
- addElem(dataUp: DataUp): number;
1235
- flushQueue(direction?: IterationDirection): void;
1236
- pathToIndex(_index: number): (TwistyAlgWrapperElem | TwistyAlgLeafElem)[];
1237
- }
1238
- declare class MoveHighlighter {
1239
- moveCharIndexMap: Map<number, TwistyAlgLeafElem>;
1240
- currentElem: TwistyAlgLeafElem | null;
1241
- addMove(charIndex: number, elem: TwistyAlgLeafElem): void;
1242
- set(move: Parsed<Move> | null): void;
1243
- }
1244
- /** @category Other Custom Elements */
1245
- declare class TwistyAlgViewer extends HTMLElementShim {
1246
- #private;
1247
- highlighter: MoveHighlighter;
1248
- lastClickTimestamp: number | null;
1249
- constructor(options?: {
1250
- twistyPlayer?: TwistyPlayer;
1251
- });
1252
- protected connectedCallback(): void;
1253
- private setAlg;
1254
- get twistyPlayer(): TwistyPlayer | null;
1255
- set twistyPlayer(twistyPlayer: TwistyPlayer | null);
1256
- jumpToIndex(index: number, offsetIntoMove: boolean): Promise<void>;
1257
- protected attributeChangedCallback(attributeName: string, _oldValue: string, newValue: string): Promise<void>;
1258
- static get observedAttributes(): string[];
1259
- }
1260
- declare global {
1261
- interface HTMLElementTagNameMap {
1262
- "twisty-alg-viewer": TwistyAlgViewer;
1263
- }
1264
- }
1265
-
1266
- type AnimatedLeafAlgNodeInfo = {
1267
- leaf: Parsed<AnimatedLeafAlgNode>;
1268
- idx: number;
1269
- };
1270
- type OrderedLeafTokens = AnimatedLeafAlgNodeInfo[];
1271
-
1272
- declare class TwistyAlgEditorValueProp extends SimpleTwistyPropSource<string> {
1273
- getDefaultValue(): string;
1274
- }
1275
- interface AlgEditorAlgWithIssuesPropInput {
1276
- value: string;
1277
- }
1278
- declare class AlgEditorAlgWithIssuesProp extends TwistyPropDerived<AlgEditorAlgWithIssuesPropInput, AlgWithIssues> {
1279
- derive(input: AlgEditorAlgWithIssuesPropInput): AlgWithIssues;
1280
- }
1281
- interface SelectionInfoPropInput {
1282
- selectionStart: number;
1283
- selectionEnd: number;
1284
- }
1285
- interface SelectionInfo extends SelectionInfoPropInput {
1286
- endChangedMostRecently: boolean;
1287
- }
1288
- declare class TwistyAlgEditorSelectionProp extends TwistyPropSource<SelectionInfo, SelectionInfoPropInput> {
1289
- getDefaultValue(): {
1290
- selectionStart: number;
1291
- selectionEnd: number;
1292
- endChangedMostRecently: boolean;
1293
- };
1294
- derive(input: SelectionInfoPropInput, oldValue: Promise<SelectionInfo>): Promise<SelectionInfo>;
1295
- }
1296
- interface TargetCharPropInputs {
1297
- selectionInfo: SelectionInfo;
1298
- }
1299
- declare class TargetCharProp extends TwistyPropDerived<TargetCharPropInputs, number> {
1300
- derive(inputs: TargetCharPropInputs): number;
1301
- }
1302
- interface LeafTokensPropInputs {
1303
- algWithIssues: AlgWithIssues;
1304
- }
1305
- declare class LeafTokensProp extends TwistyPropDerived<LeafTokensPropInputs, OrderedLeafTokens> {
1306
- derive(inputs: LeafTokensPropInputs): OrderedLeafTokens;
1307
- }
1308
- interface LeafToHighlightPropInputs {
1309
- targetChar: number;
1310
- leafTokens: OrderedLeafTokens;
1311
- }
1312
- type HighlightWhere = "before" | "start" | "inside" | "end" | "after";
1313
- interface HighlightInfo {
1314
- leafInfo: AnimatedLeafAlgNodeInfo;
1315
- where: HighlightWhere;
1316
- }
1317
- declare class LeafToHighlightProp extends TwistyPropDerived<LeafToHighlightPropInputs, HighlightInfo | null> {
1318
- derive(inputs: LeafToHighlightPropInputs): HighlightInfo | null;
1319
- }
1320
- declare class TwistyAlgEditorModel {
1321
- valueProp: TwistyAlgEditorValueProp;
1322
- selectionProp: TwistyAlgEditorSelectionProp;
1323
- targetCharProp: TargetCharProp;
1324
- algEditorAlgWithIssues: AlgEditorAlgWithIssuesProp;
1325
- leafTokensProp: LeafTokensProp;
1326
- leafToHighlight: LeafToHighlightProp;
1327
- }
1328
-
1329
- /**
1330
- * Warning: the current implementation of <twisty-alg-editor> is *not good*,
1331
- * but it is *good enough*. The important parts is that:
1332
- *
1333
- * - The editor can be used in apps without much effort.
1334
- * - The editor handles alg validation and move highlighting *okay* when not
1335
- * connected to a `<twisty-player>`.
1336
- * - The editor stays in sync if it's connected to a `<twisty-player>`.
1337
- *
1338
- * The current implementation still has some race conditions and edge cases. A
1339
- * proper rewrite with a better model would be very welcome.
1340
- */
1341
-
1342
- type TwistyPlayerAlgProp = "alg" | "setupAlg";
1343
- /** @category Other Custom Elements */
1344
- declare class TwistyAlgEditor extends ManagedCustomElement {
1345
- #private;
1346
- model: TwistyAlgEditorModel;
1347
- debugNeverRequestTimestamp: boolean;
1348
- constructor(options?: {
1349
- twistyPlayer?: TwistyPlayer;
1350
- twistyPlayerProp?: TwistyPlayerAlgProp;
1351
- });
1352
- connectedCallback(): void;
1353
- set algString(s: string);
1354
- get algString(): string;
1355
- set placeholder(placeholderText: string);
1356
- onInput(): void;
1357
- onSelectionChange(): Promise<void>;
1358
- onBlur(): Promise<void>;
1359
- setAlgIssueClassForPuzzle(issues: "none" | "warning" | "error"): void;
1360
- highlightLeaf(leaf: Parsed<Move | Pause> | null): void;
1361
- get twistyPlayer(): TwistyPlayer | null;
1362
- set twistyPlayer(twistyPlayer: TwistyPlayer | null);
1363
- protected attributeChangedCallback(attributeName: string, _oldValue: string, newValue: string): void;
1364
- static get observedAttributes(): string[];
1365
- }
1366
- declare global {
1367
- interface HTMLElementTagNameMap {
1368
- "twisty-alg-editor": TwistyAlgEditor;
1369
- }
1370
- }
1371
-
1372
- declare class TwizzleLink extends ManagedCustomElement {
1373
- #private;
1374
- private options?;
1375
- twistyPlayer: TwistyPlayer | null;
1376
- a: HTMLAnchorElement | null;
1377
- constructor(options?: {
1378
- cdnForumTweaks?: boolean;
1379
- colorScheme?: ColorSchemeWithAuto;
1380
- } | undefined);
1381
- connectedCallback(): Promise<void>;
1382
- }
1383
- declare global {
1384
- interface HTMLElementTagNameMap {
1385
- "twizzle-link": TwizzleLink;
1386
- }
1387
- }
1388
-
1389
- export { type AlgIndexer as A, type BackViewLayout as B, type Duration as D, type ExperimentalStickering as E, type MillisecondTimestamp as M, NO_VALUE as N, type PuzzleLoader as P, type StickeringMask as S, type Timestamp as T, type VisualizationFormat as V, type PuzzleID as a, TwistyPlayer as b, TwistyAlgViewer as c, TwistyAlgEditor as d, type TwistyPlayerConfig as e, backViewLayouts as f, TwizzleLink as g };