@sudobility/music_types 0.11.31 → 0.11.33
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/dist/domain/commands/note-commands.d.ts +8 -155
- package/dist/domain/commands/note-commands.d.ts.map +1 -1
- package/dist/domain/commands/note-commands.js +1 -423
- package/dist/domain/commands/note-commands.js.map +1 -1
- package/dist/domain/commands/note-marks.d.ts +171 -0
- package/dist/domain/commands/note-marks.d.ts.map +1 -0
- package/dist/domain/commands/note-marks.js +427 -0
- package/dist/domain/commands/note-marks.js.map +1 -0
- package/dist/domain/score/fragment.d.ts +3 -7
- package/dist/domain/score/fragment.d.ts.map +1 -1
- package/dist/domain/score/fragment.js.map +1 -1
- package/dist/domain/selection/types.d.ts +2 -2
- package/dist/domain/selection/types.d.ts.map +1 -1
- package/dist/index.d.ts +7 -5499
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -461
- package/dist/index.js.map +1 -1
- package/dist/model/api.d.ts +1696 -0
- package/dist/model/api.d.ts.map +1 -0
- package/dist/model/api.js +125 -0
- package/dist/model/api.js.map +1 -0
- package/dist/model/generation.d.ts +2178 -0
- package/dist/model/generation.d.ts.map +1 -0
- package/dist/model/generation.js +142 -0
- package/dist/model/generation.js.map +1 -0
- package/dist/model/position.d.ts +82 -0
- package/dist/model/position.d.ts.map +1 -0
- package/dist/model/position.js +24 -0
- package/dist/model/position.js.map +1 -0
- package/dist/model/schemas.d.ts +1200 -0
- package/dist/model/schemas.d.ts.map +1 -0
- package/dist/model/schemas.js +200 -0
- package/dist/model/schemas.js.map +1 -0
- package/dist/model/score.d.ts +462 -0
- package/dist/model/score.d.ts.map +1 -0
- package/dist/model/score.js +34 -0
- package/dist/model/score.js.map +1 -0
- package/dist/model/selection-source.d.ts +53 -0
- package/dist/model/selection-source.d.ts.map +1 -0
- package/dist/model/selection-source.js +2 -0
- package/dist/model/selection-source.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@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C;CACpB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;iBAS9B,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;iBAI3C,CAAC;AAEH,2GAA2G;AAC3G,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,OAAO,GAAG,oBAAoB,CAE7E;AAED,0GAA0G;AAC1G,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GAAG,mBAAmB,CAE3E;AAED,8GAA8G;AAC9G,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,OAAO,GACZ,uBAAuB,CAEzB;AAED,6GAA6G;AAC7G,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,OAAO,GACZ,sBAAsB,CAExB;AAED,4GAA4G;AAC5G,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,OAAO,GACZ,qBAAqB,CAEvB"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AI generation contracts, and the schemas that validate them.
|
|
3
|
+
*
|
|
4
|
+
* The request and result shapes `music_api` and the app agree on. Both sides
|
|
5
|
+
* import these, which is the whole reason this package exists.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { clefSchema, keySignatureSchema, measureSchema, scoreSchema, timeSignatureSchema, } from "./schemas.js";
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// 6. Zod schemas for the generation contracts
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
export const midiRangeSchema = z.object({
|
|
13
|
+
lowestMidi: z.number().int().min(0).max(127),
|
|
14
|
+
highestMidi: z.number().int().min(0).max(127),
|
|
15
|
+
});
|
|
16
|
+
export const scoreRangeSchema = z.object({
|
|
17
|
+
startTick: z.number().int().nonnegative(),
|
|
18
|
+
endTick: z.number().int().nonnegative(),
|
|
19
|
+
trackIds: z.array(z.string().min(1)),
|
|
20
|
+
});
|
|
21
|
+
export const scoreFragmentSchema = z.object({
|
|
22
|
+
range: scoreRangeSchema,
|
|
23
|
+
ppq: z.number().int().positive(),
|
|
24
|
+
tracks: z.array(z.object({ trackId: z.string().min(1), measures: z.array(measureSchema) })),
|
|
25
|
+
});
|
|
26
|
+
export const generateScoreRequestTrackSchema = z.object({
|
|
27
|
+
name: z.string(),
|
|
28
|
+
instrumentName: z.string(),
|
|
29
|
+
midiProgram: z.number().int().min(0).max(127),
|
|
30
|
+
clef: clefSchema,
|
|
31
|
+
range: midiRangeSchema.optional(),
|
|
32
|
+
maximumPolyphony: z.number().int().positive().optional(),
|
|
33
|
+
});
|
|
34
|
+
export const generateScoreRequestSchema = z.object({
|
|
35
|
+
prompt: z.string(),
|
|
36
|
+
title: z.string().optional(),
|
|
37
|
+
style: z.string().optional(),
|
|
38
|
+
mood: z.string().optional(),
|
|
39
|
+
durationMeasures: z.number().int().positive(),
|
|
40
|
+
tempo: z.number().positive().optional(),
|
|
41
|
+
timeSignature: timeSignatureSchema.optional(),
|
|
42
|
+
keySignature: keySignatureSchema.optional(),
|
|
43
|
+
tracks: z.array(generateScoreRequestTrackSchema),
|
|
44
|
+
complexity: z.enum(["simple", "moderate", "complex"]).optional(),
|
|
45
|
+
});
|
|
46
|
+
export const generateScoreResultSchema = z.object({
|
|
47
|
+
score: scoreSchema,
|
|
48
|
+
warnings: z.array(z.string()),
|
|
49
|
+
});
|
|
50
|
+
export const regenerationConstraintsSchema = z.object({
|
|
51
|
+
preserveMeasureCount: z.literal(true).optional(),
|
|
52
|
+
preserveTimeSignatures: z.literal(true),
|
|
53
|
+
preserveTempoEvents: z.literal(true),
|
|
54
|
+
preserveBoundaryNotes: z.boolean().optional(),
|
|
55
|
+
preserveHarmony: z.boolean().optional(),
|
|
56
|
+
preserveRhythm: z.boolean().optional(),
|
|
57
|
+
preserveMelody: z.boolean().optional(),
|
|
58
|
+
maximumPolyphony: z.number().int().positive().optional(),
|
|
59
|
+
allowedPitchRangeByTrack: z.record(z.string(), midiRangeSchema).optional(),
|
|
60
|
+
});
|
|
61
|
+
export const regenerateRegionRequestSchema = z.object({
|
|
62
|
+
scoreId: z.string().min(1),
|
|
63
|
+
instruction: z.string(),
|
|
64
|
+
range: scoreRangeSchema,
|
|
65
|
+
precedingContext: scoreFragmentSchema,
|
|
66
|
+
selectedFragment: scoreFragmentSchema,
|
|
67
|
+
followingContext: scoreFragmentSchema,
|
|
68
|
+
constraints: regenerationConstraintsSchema,
|
|
69
|
+
candidateCount: z.number().int().positive(),
|
|
70
|
+
style: z.string().optional(),
|
|
71
|
+
mood: z.string().optional(),
|
|
72
|
+
complexity: z.enum(["simple", "moderate", "complex"]).optional(),
|
|
73
|
+
});
|
|
74
|
+
export const regenerationCandidateSchema = z.object({
|
|
75
|
+
id: z.string().min(1),
|
|
76
|
+
label: z.string(),
|
|
77
|
+
fragment: scoreFragmentSchema,
|
|
78
|
+
});
|
|
79
|
+
export const regenerateRegionResultSchema = z.object({
|
|
80
|
+
candidates: z.array(regenerationCandidateSchema),
|
|
81
|
+
warnings: z.array(z.string()),
|
|
82
|
+
});
|
|
83
|
+
export const projectStatusSchema = z.enum([
|
|
84
|
+
"ready",
|
|
85
|
+
"generating",
|
|
86
|
+
"transcribing",
|
|
87
|
+
]);
|
|
88
|
+
export const generationJobKindSchema = z.enum([
|
|
89
|
+
"generate-score",
|
|
90
|
+
"generate-track",
|
|
91
|
+
"replace-notes",
|
|
92
|
+
"replace-measures",
|
|
93
|
+
"replace-track",
|
|
94
|
+
]);
|
|
95
|
+
export const generationJobStatusSchema = z.enum([
|
|
96
|
+
"queued",
|
|
97
|
+
"running",
|
|
98
|
+
"done",
|
|
99
|
+
"failed",
|
|
100
|
+
"cancelled",
|
|
101
|
+
]);
|
|
102
|
+
export const tokenUsageSchema = z.object({
|
|
103
|
+
promptTokens: z.number().int().nonnegative(),
|
|
104
|
+
completionTokens: z.number().int().nonnegative(),
|
|
105
|
+
model: z.string().min(1),
|
|
106
|
+
});
|
|
107
|
+
export const generationJobSchema = z.object({
|
|
108
|
+
id: z.string().min(1),
|
|
109
|
+
projectId: z.string().min(1),
|
|
110
|
+
kind: generationJobKindSchema,
|
|
111
|
+
status: generationJobStatusSchema,
|
|
112
|
+
createdAt: z.string(),
|
|
113
|
+
finishedAt: z.string().nullable(),
|
|
114
|
+
error: z.string().nullable(),
|
|
115
|
+
usage: tokenUsageSchema.optional(),
|
|
116
|
+
});
|
|
117
|
+
export const createGenerationJobRequestSchema = z.object({
|
|
118
|
+
projectId: z.string().min(1),
|
|
119
|
+
kind: generationJobKindSchema,
|
|
120
|
+
request: z.unknown(),
|
|
121
|
+
});
|
|
122
|
+
/** Parses and validates untrusted JSON as a `GenerateScoreRequest`. Throws `ZodError` on invalid input. */
|
|
123
|
+
export function parseGenerateScoreRequest(json) {
|
|
124
|
+
return generateScoreRequestSchema.parse(json);
|
|
125
|
+
}
|
|
126
|
+
/** Parses and validates untrusted JSON as a `GenerateScoreResult`. Throws `ZodError` on invalid input. */
|
|
127
|
+
export function parseGenerateScoreResult(json) {
|
|
128
|
+
return generateScoreResultSchema.parse(json);
|
|
129
|
+
}
|
|
130
|
+
/** Parses and validates untrusted JSON as a `RegenerateRegionRequest`. Throws `ZodError` on invalid input. */
|
|
131
|
+
export function parseRegenerateRegionRequest(json) {
|
|
132
|
+
return regenerateRegionRequestSchema.parse(json);
|
|
133
|
+
}
|
|
134
|
+
/** Parses and validates untrusted JSON as a `RegenerateRegionResult`. Throws `ZodError` on invalid input. */
|
|
135
|
+
export function parseRegenerateRegionResult(json) {
|
|
136
|
+
return regenerateRegionResultSchema.parse(json);
|
|
137
|
+
}
|
|
138
|
+
/** Parses and validates untrusted JSON as a `RegenerationCandidate`. Throws `ZodError` on invalid input. */
|
|
139
|
+
export function parseRegenerationCandidate(json) {
|
|
140
|
+
return regenerationCandidateSchema.parse(json);
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=generation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation.js","sourceRoot":"","sources":["../../src/model/generation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAmGtB,8EAA8E;AAC9E,8CAA8C;AAC9C,8EAA8E;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CAC9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACzC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACvC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAA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AC,GAAG,CAAC,CAAC,CAAC;IAC5B,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAC;AAEH,2GAA2G;AAC3G,MAAM,UAAU,yBAAyB,CAAC,IAAa;IACrD,OAAO,0BAA0B,CAAC,KAAK,CAAC,IAAI,CAAyB,CAAC;AACxE,CAAC;AAED,0GAA0G;AAC1G,MAAM,UAAU,wBAAwB,CAAC,IAAa;IACpD,OAAO,yBAAyB,CAAC,KAAK,CAAC,IAAI,CAAwB,CAAC;AACtE,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,4BAA4B,CAC1C,IAAa;IAEb,OAAO,6BAA6B,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;AAC9E,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,2BAA2B,CACzC,IAAa;IAEb,OAAO,4BAA4B,CAAC,KAAK,CAAC,IAAI,CAA2B,CAAC;AAC5E,CAAC;AAED,4GAA4G;AAC5G,MAAM,UAAU,0BAA0B,CACxC,IAAa;IAEb,OAAO,2BAA2B,CAAC,KAAK,CAAC,IAAI,CAA0B,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where playback is, as one number that everything reads.
|
|
3
|
+
*
|
|
4
|
+
* The editor has three things that follow the music — the caret, the note
|
|
5
|
+
* highlighting, and the piano keyboard — and they used to learn about it
|
|
6
|
+
* separately. The engine published a throttled `positionTick` on one channel
|
|
7
|
+
* and the sounding set on another, and the caret then *re-derived* its own
|
|
8
|
+
* position by dead-reckoning against `performance.now()` from whenever React
|
|
9
|
+
* happened to process the last report. Three consumers, three clocks: under
|
|
10
|
+
* load the caret's anchor was stamped late and drifted against notes that had
|
|
11
|
+
* lit up on the audio clock, so the three visibly disagreed.
|
|
12
|
+
*
|
|
13
|
+
* This is the interface that removes the possibility. One implementation owns
|
|
14
|
+
* the current tick — including the smoothing that keeps a caret gliding
|
|
15
|
+
* between engine reports — and playback *writes* it while everything that
|
|
16
|
+
* follows the music *reads* it. Two views of one number cannot disagree; three
|
|
17
|
+
* derivations of three numbers eventually will.
|
|
18
|
+
*
|
|
19
|
+
* Deliberately not a store slice: the value changes ~30 times a second and
|
|
20
|
+
* routing it through Zustand notifies every subscriber in the app at that rate,
|
|
21
|
+
* which is the cost the playback bus was built to avoid.
|
|
22
|
+
*/
|
|
23
|
+
/** Detaches a listener registered with {@link IMusicPosition.subscribe}. */
|
|
24
|
+
export type UnsubscribePosition = () => void;
|
|
25
|
+
/**
|
|
26
|
+
* The playhead, in **score ticks**.
|
|
27
|
+
*
|
|
28
|
+
* Score ticks, not performance ticks: repeats and jumps mean a bar can be
|
|
29
|
+
* played more than once, and every consumer here draws or highlights something
|
|
30
|
+
* on the page, where a bar exists exactly once. The translation happens at the
|
|
31
|
+
* transport boundary so nothing downstream has to know repeats exist.
|
|
32
|
+
*/
|
|
33
|
+
export interface IMusicPosition {
|
|
34
|
+
/**
|
|
35
|
+
* The current tick.
|
|
36
|
+
*
|
|
37
|
+
* Read this rather than remembering the last value from `subscribe`: an
|
|
38
|
+
* implementation may smooth between engine reports, in which case this is
|
|
39
|
+
* fresher than the last event and is the number the caret should draw at.
|
|
40
|
+
*/
|
|
41
|
+
readonly tick: number;
|
|
42
|
+
/** Whether the transport is advancing, which is when smoothing applies. */
|
|
43
|
+
readonly isPlaying: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Observe changes.
|
|
46
|
+
*
|
|
47
|
+
* Fires when the underlying position is *reported*, not once per animation
|
|
48
|
+
* frame — a consumer that paints every frame should read {@link tick} in its
|
|
49
|
+
* own loop rather than expect an event per frame.
|
|
50
|
+
*/
|
|
51
|
+
subscribe(listener: (tick: number) => void): UnsubscribePosition;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The writable side, held by whatever is driving playback.
|
|
55
|
+
*
|
|
56
|
+
* Split from the read interface so the split is visible in a signature: the
|
|
57
|
+
* transport takes this, and everything that merely follows the music takes
|
|
58
|
+
* {@link IMusicPosition} and cannot move the playhead by accident.
|
|
59
|
+
*/
|
|
60
|
+
export interface IMusicPositionSource extends IMusicPosition {
|
|
61
|
+
/**
|
|
62
|
+
* Report an authoritative position, in score ticks.
|
|
63
|
+
*
|
|
64
|
+
* `atSeconds` is the *engine's own* clock reading for this position, not the
|
|
65
|
+
* wall clock at the moment the report is handled. That distinction is the
|
|
66
|
+
* whole point: anchoring on receipt time folds event-loop latency into the
|
|
67
|
+
* playhead, which is what made the caret drift under load.
|
|
68
|
+
*/
|
|
69
|
+
report(tick: number, atSeconds?: number): void;
|
|
70
|
+
/** Start or stop smoothing, and set the rate ticks advance at. */
|
|
71
|
+
setPlaying(playing: boolean, ticksPerSecond?: number): void;
|
|
72
|
+
/**
|
|
73
|
+
* How fast ticks are passing right now.
|
|
74
|
+
*
|
|
75
|
+
* Separate from `setPlaying` because it changes *during* playback and must
|
|
76
|
+
* not re-anchor when it does: a score can slow into a fermata or change
|
|
77
|
+
* tempo at a rehearsal mark, and the projection between reports has to use
|
|
78
|
+
* the rate in force at that moment or the playhead glides past the hold.
|
|
79
|
+
*/
|
|
80
|
+
setRate(ticksPerSecond: number): void;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../src/model/position.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,mBAAmB,CAAC;CAClE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/C,kEAAkE;IAClE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5D;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where playback is, as one number that everything reads.
|
|
3
|
+
*
|
|
4
|
+
* The editor has three things that follow the music — the caret, the note
|
|
5
|
+
* highlighting, and the piano keyboard — and they used to learn about it
|
|
6
|
+
* separately. The engine published a throttled `positionTick` on one channel
|
|
7
|
+
* and the sounding set on another, and the caret then *re-derived* its own
|
|
8
|
+
* position by dead-reckoning against `performance.now()` from whenever React
|
|
9
|
+
* happened to process the last report. Three consumers, three clocks: under
|
|
10
|
+
* load the caret's anchor was stamped late and drifted against notes that had
|
|
11
|
+
* lit up on the audio clock, so the three visibly disagreed.
|
|
12
|
+
*
|
|
13
|
+
* This is the interface that removes the possibility. One implementation owns
|
|
14
|
+
* the current tick — including the smoothing that keeps a caret gliding
|
|
15
|
+
* between engine reports — and playback *writes* it while everything that
|
|
16
|
+
* follows the music *reads* it. Two views of one number cannot disagree; three
|
|
17
|
+
* derivations of three numbers eventually will.
|
|
18
|
+
*
|
|
19
|
+
* Deliberately not a store slice: the value changes ~30 times a second and
|
|
20
|
+
* routing it through Zustand notifies every subscriber in the app at that rate,
|
|
21
|
+
* which is the cost the playback bus was built to avoid.
|
|
22
|
+
*/
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=position.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.js","sourceRoot":"","sources":["../../src/model/position.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG"}
|