@pol-studios/db 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/DataLayerContext-CL6alnkb.d.ts +755 -0
  2. package/dist/UserMetadataContext-B8gVWGMl.d.ts +35 -0
  3. package/dist/UserMetadataContext-DntmpK41.d.ts +33 -0
  4. package/dist/auth/context.d.ts +3 -2
  5. package/dist/auth/context.js +22 -12786
  6. package/dist/auth/context.js.map +1 -1
  7. package/dist/auth/guards.js +12 -7640
  8. package/dist/auth/guards.js.map +1 -1
  9. package/dist/auth/hooks.d.ts +3 -3
  10. package/dist/auth/hooks.js +26 -10591
  11. package/dist/auth/hooks.js.map +1 -1
  12. package/dist/auth/index.d.ts +3 -2
  13. package/dist/auth/index.js +45 -13008
  14. package/dist/auth/index.js.map +1 -1
  15. package/dist/{canvas-UVNDA54X.node → canvas-C4TBBDUL.node} +0 -0
  16. package/dist/canvas-ZQNCL7JL.js +1541 -0
  17. package/dist/canvas-ZQNCL7JL.js.map +1 -0
  18. package/dist/chunk-3PJTNH2L.js +2778 -0
  19. package/dist/chunk-3PJTNH2L.js.map +1 -0
  20. package/dist/chunk-5EFDS7SR.js +205 -0
  21. package/dist/chunk-5EFDS7SR.js.map +1 -0
  22. package/dist/chunk-7SCJNYTE.js +1459 -0
  23. package/dist/chunk-7SCJNYTE.js.map +1 -0
  24. package/dist/chunk-DJ6VLEAL.js +247 -0
  25. package/dist/chunk-DJ6VLEAL.js.map +1 -0
  26. package/dist/chunk-GC3TBUWE.js +14 -0
  27. package/dist/chunk-GC3TBUWE.js.map +1 -0
  28. package/dist/chunk-H3LNH2NT.js +611 -0
  29. package/dist/chunk-H3LNH2NT.js.map +1 -0
  30. package/dist/chunk-H6365JPC.js +1858 -0
  31. package/dist/chunk-H6365JPC.js.map +1 -0
  32. package/dist/chunk-HAWJTZCK.js +86 -0
  33. package/dist/chunk-HAWJTZCK.js.map +1 -0
  34. package/dist/chunk-J4ZVCXZ4.js +1 -0
  35. package/dist/chunk-J4ZVCXZ4.js.map +1 -0
  36. package/dist/chunk-JAATANS3.js +429 -0
  37. package/dist/chunk-JAATANS3.js.map +1 -0
  38. package/dist/chunk-LNJ3WF7V.js +470 -0
  39. package/dist/chunk-LNJ3WF7V.js.map +1 -0
  40. package/dist/chunk-N26IEHZT.js +79 -0
  41. package/dist/chunk-N26IEHZT.js.map +1 -0
  42. package/dist/chunk-NSIAAYW3.js +1 -0
  43. package/dist/chunk-NSIAAYW3.js.map +1 -0
  44. package/dist/chunk-NZON56CB.js +3864 -0
  45. package/dist/chunk-NZON56CB.js.map +1 -0
  46. package/dist/chunk-OQ7U6EQ3.js +7550 -0
  47. package/dist/chunk-OQ7U6EQ3.js.map +1 -0
  48. package/dist/chunk-P4UZ7IXC.js +42 -0
  49. package/dist/chunk-P4UZ7IXC.js.map +1 -0
  50. package/dist/chunk-SM73S2DY.js +11 -0
  51. package/dist/chunk-SM73S2DY.js.map +1 -0
  52. package/dist/chunk-TKWR5AAY.js +415 -0
  53. package/dist/chunk-TKWR5AAY.js.map +1 -0
  54. package/dist/chunk-U5UNPBKB.js +501 -0
  55. package/dist/chunk-U5UNPBKB.js.map +1 -0
  56. package/dist/chunk-WGDJ4IXR.js +921 -0
  57. package/dist/chunk-WGDJ4IXR.js.map +1 -0
  58. package/dist/chunk-WVF7RUW5.js +186 -0
  59. package/dist/chunk-WVF7RUW5.js.map +1 -0
  60. package/dist/chunk-X3HZLNBV.js +2129 -0
  61. package/dist/chunk-X3HZLNBV.js.map +1 -0
  62. package/dist/chunk-XU3SBFAG.js +5205 -0
  63. package/dist/chunk-XU3SBFAG.js.map +1 -0
  64. package/dist/chunk-ZVBHWU7O.js +1412 -0
  65. package/dist/chunk-ZVBHWU7O.js.map +1 -0
  66. package/dist/client/index.d.ts +1 -1
  67. package/dist/client/index.js +54 -163
  68. package/dist/client/index.js.map +1 -1
  69. package/dist/core/index.d.ts +19 -0
  70. package/dist/{index-BFu5_dS8.d.ts → database.types-ChFCG-4M.d.ts} +1 -177
  71. package/dist/dist-NDNRSNOG.js +521 -0
  72. package/dist/dist-NDNRSNOG.js.map +1 -0
  73. package/dist/gen/index.js +188 -1280
  74. package/dist/gen/index.js.map +1 -1
  75. package/dist/hooks/index.d.ts +10 -3
  76. package/dist/hooks/index.js +20 -8695
  77. package/dist/hooks/index.js.map +1 -1
  78. package/dist/index-CQLyNG6A.d.ts +433 -0
  79. package/dist/index.d.ts +12 -8
  80. package/dist/index.js +447 -47848
  81. package/dist/index.js.map +1 -1
  82. package/dist/index.native.d.ts +373 -33
  83. package/dist/index.native.js +432 -25048
  84. package/dist/index.native.js.map +1 -1
  85. package/dist/index.web.d.ts +10 -7
  86. package/dist/index.web.js +585 -43773
  87. package/dist/index.web.js.map +1 -1
  88. package/dist/mutation/index.d.ts +2 -2
  89. package/dist/mutation/index.js +331 -4777
  90. package/dist/mutation/index.js.map +1 -1
  91. package/dist/parser/index.js +45 -3697
  92. package/dist/parser/index.js.map +1 -1
  93. package/dist/pdf-PHXP7RHD.js +20336 -0
  94. package/dist/pdf-PHXP7RHD.js.map +1 -0
  95. package/dist/powersync-bridge/index.d.ts +284 -0
  96. package/dist/powersync-bridge/index.js +22 -0
  97. package/dist/powersync-bridge/index.js.map +1 -0
  98. package/dist/query/index.js +31 -13175
  99. package/dist/query/index.js.map +1 -1
  100. package/dist/realtime/index.js +279 -12541
  101. package/dist/realtime/index.js.map +1 -1
  102. package/dist/{UserMetadataContext-BYYqA6LI.d.ts → setupAuthContext-Kv-THH-h.d.ts} +1 -29
  103. package/dist/types/index.d.ts +5 -1
  104. package/dist/types/index.js +14 -0
  105. package/dist/{useBatchUpsert-CSQVX7w8.d.ts → useBatchUpsert-9OYjibLh.d.ts} +1 -1
  106. package/dist/{useDbCount-RGCuHmHp.d.ts → useDbCount-BG356T9i.d.ts} +3 -719
  107. package/dist/{useReceiptAI-Bn0czE7C.d.ts → useReceiptAI-6HkRpRml.d.ts} +1 -1
  108. package/dist/{useResolveFeedback-CpZPP8Pw.d.ts → useResolveFeedback-BWmatBlE.d.ts} +26 -45
  109. package/dist/{useSupabase-pPhUZHcl.d.ts → useSupabase-DvWVuHHE.d.ts} +2 -1
  110. package/dist/with-auth/index.d.ts +704 -0
  111. package/dist/with-auth/index.js +1221 -0
  112. package/dist/with-auth/index.js.map +1 -0
  113. package/package.json +25 -10
@@ -1,9 +1,3 @@
1
- import { V as ValueForPropertyType, P as PropertyType, a as FilterConfig } from './FilterConfig-Bt2Ek74z.js';
2
- import { Moment } from 'moment';
3
- import { PostgrestSingleResponse } from '@supabase/supabase-js';
4
- import { Dispatch, SetStateAction } from 'react';
5
- import { UseQueryOptions, DefinedUseQueryResult } from '@tanstack/react-query';
6
-
7
1
  type Json = string | number | boolean | null | {
8
2
  [key: string]: Json | undefined;
9
3
  } | Json[];
@@ -8607,174 +8601,4 @@ declare const Constants: {
8607
8601
  };
8608
8602
  };
8609
8603
 
8610
- /**
8611
- * Represents a change log entry for database records.
8612
- * Used for tracking live changes to entities.
8613
- */
8614
- interface DbChangeLog {
8615
- modifiedByUserId: string;
8616
- changedOn: Moment;
8617
- changes: Record<string, unknown>;
8618
- }
8619
-
8620
- declare const normalizeFilter: (filter: FilterInput) => Filter | FilterGroup | null;
8621
- /**
8622
- * Filter state for the UI - extends Filter with UI-specific metadata.
8623
- * FilterState can always be assigned where Filter is expected since it
8624
- * contains all Filter properties. The omitted properties (similarity, where, options)
8625
- * are AI search-specific and not typically needed in the UI filter state.
8626
- */
8627
- interface FilterState extends Omit<Filter, 'similarity' | 'where' | 'options'> {
8628
- }
8629
- type ValueOrArrayForPropertyType<T extends PropertyType> = ValueForPropertyType<T> | ValueForPropertyType<T>[];
8630
- type BooleanOperator = "AND" | "OR";
8631
- /**
8632
- * Filter operators supported by the edge function.
8633
- * This is the single source of truth - matches /supabase/functions/_shared/query-sdk/types.ts
8634
- *
8635
- * Note: The following operators are normalized by normalizeFilter() before sending to the server:
8636
- * - "like" -> "contains"
8637
- * - "regex", "regex_i", "similar_to" -> "contains"
8638
- * - "!=" and "<>" are NOT supported - use "=" with not: true instead
8639
- */
8640
- type FilterOperator = "=" | ">" | ">=" | "<" | "<=" | "contains" | "ilike" | "is" | "in" | "ai_search";
8641
- type FilterConditionType = FilterOperator;
8642
- /**
8643
- * Filter interface - matches edge function API
8644
- */
8645
- interface Filter {
8646
- /** Unique identifier */
8647
- id: string;
8648
- /** Field to filter on */
8649
- field: string;
8650
- /** Operator */
8651
- op: FilterOperator;
8652
- /** Value to compare */
8653
- value: string | number | string[] | number[] | boolean | null;
8654
- /** Negate the condition */
8655
- not?: boolean;
8656
- /** AI search options (when op = "ai_search") */
8657
- similarity?: number;
8658
- where?: string;
8659
- display?: string;
8660
- options?: {
8661
- display: string;
8662
- value: ValueForPropertyType<PropertyType>;
8663
- }[];
8664
- /** Filter configuration (UI metadata) */
8665
- info?: FilterConfig<any>;
8666
- }
8667
- /**
8668
- * Filter group - combine multiple filters
8669
- */
8670
- interface FilterGroup {
8671
- /** Unique identifier */
8672
- id: string;
8673
- /** How to combine filters */
8674
- op: "AND" | "OR";
8675
- /** Filters in this group */
8676
- filters: Array<Filter | FilterGroup>;
8677
- /** Negate the entire group (NOT (A AND B)) */
8678
- not?: boolean;
8679
- }
8680
- /**
8681
- * Input type for normalizeFilter - accepts both legacy and new filter formats.
8682
- * The normalizeFilter function handles legacy operators (like, regex, etc.) for data migration,
8683
- * but the type only exposes the supported FilterOperator values.
8684
- */
8685
- type FilterInput = {
8686
- id?: string;
8687
- field?: string;
8688
- value?: string | number | string[] | number[] | boolean | null;
8689
- not?: boolean;
8690
- similarity?: number;
8691
- where?: string;
8692
- display?: string;
8693
- options?: {
8694
- display: string;
8695
- value: ValueForPropertyType<PropertyType>;
8696
- }[];
8697
- filters?: Array<Filter | FilterGroup | FilterInput>;
8698
- op?: FilterOperator | "AND" | "OR";
8699
- propertyName?: string;
8700
- condition?: string;
8701
- operator?: "AND" | "OR";
8702
- inverted?: boolean;
8703
- };
8704
- /**
8705
- * Pagination settings
8706
- */
8707
- interface Pagination {
8708
- offset?: number;
8709
- limit?: number;
8710
- }
8711
- /**
8712
- * Configuration for computed/aggregated field sorting
8713
- */
8714
- interface ComputedSortConfig {
8715
- /** Aggregation function to apply */
8716
- fn: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX";
8717
- /** Field to aggregate */
8718
- field: string;
8719
- /** Relationship path for related table aggregation (e.g., "OrderItem" or "Order.OrderItem") */
8720
- relationship?: string;
8721
- }
8722
- /**
8723
- * Sort order
8724
- */
8725
- interface Sort {
8726
- field: string;
8727
- direction: "asc" | "desc";
8728
- /** Optional computed/aggregated sort configuration for sorting by aggregate values */
8729
- computed?: ComputedSortConfig;
8730
- }
8731
- /**
8732
- * Query state that includes FilterGroup plus pagination, sort, and isReady
8733
- * Used by useDbAdvanceFilterQuery for managing filter state with query metadata
8734
- */
8735
- interface QueryState extends FilterGroup {
8736
- /** Pagination settings */
8737
- pagination?: Pagination;
8738
- /** Sort order */
8739
- sort?: Sort[];
8740
- /** Distinct ON expressions - returns one record per unique combination */
8741
- distinctOn?: string[];
8742
- /** Natural language query - converts to filters automatically */
8743
- naturalLanguageQuery?: string;
8744
- /** Whether the query is ready to execute */
8745
- isReady: boolean;
8746
- }
8747
- interface ClarificationSuggestion {
8748
- interpretation: string;
8749
- field_path: string;
8750
- example: string;
8751
- confidence: number;
8752
- }
8753
- interface ClarificationQuestion {
8754
- question: string;
8755
- suggestions: ClarificationSuggestion[];
8756
- }
8757
- interface FilterContextType<T> {
8758
- filters: FilterGroup;
8759
- setFilters: Dispatch<SetStateAction<FilterGroup>>;
8760
- }
8761
- interface OrderColumn {
8762
- field: string;
8763
- direction: "asc" | "desc";
8764
- }
8765
- declare function useDbAdvanceFilterQuery<Result>(query: PromiseLike<PostgrestSingleResponse<Result>>, config?: Omit<UseQueryOptions<PostgrestSingleResponse<Result>>, "queryKey" | "queryFn"> & {
8766
- key?: string;
8767
- filterKey?: string;
8768
- searchByDefault?: boolean;
8769
- timeout?: number;
8770
- count?: "exact" | "estimated" | "";
8771
- }): [
8772
- DefinedUseQueryResult<Result, Error> & {
8773
- count: number;
8774
- clarification?: ClarificationQuestion;
8775
- },
8776
- QueryState,
8777
- Dispatch<SetStateAction<QueryState>>
8778
- ];
8779
-
8780
- export { type BooleanOperator as B, type CompositeTypes as C, type Database as D, type Enums as E, type FilterOperator as F, type Json as J, type OrderColumn as O, type Pagination as P, type QueryState as Q, type Sort as S, type Tables as T, type ValueOrArrayForPropertyType as V, type TablesInsert as a, type TablesUpdate as b, Constants as c, type DbChangeLog as d, type FilterConditionType as e, type Filter as f, type FilterGroup as g, type FilterInput as h, type FilterState as i, type ComputedSortConfig as j, type ClarificationSuggestion as k, type ClarificationQuestion as l, type FilterContextType as m, normalizeFilter as n, useDbAdvanceFilterQuery as u };
8604
+ export { type CompositeTypes as C, type Database as D, type Enums as E, type Json as J, type Tables as T, type TablesInsert as a, type TablesUpdate as b, Constants as c };
@@ -0,0 +1,521 @@
1
+ import "./chunk-P4UZ7IXC.js";
2
+
3
+ // ../../../node_modules/.pnpm/path2d@0.2.2/node_modules/path2d/dist/index.js
4
+ var ARG_LENGTH = {
5
+ a: 7,
6
+ c: 6,
7
+ h: 1,
8
+ l: 2,
9
+ m: 2,
10
+ q: 4,
11
+ s: 4,
12
+ t: 2,
13
+ v: 1,
14
+ z: 0
15
+ };
16
+ var SEGMENT_PATTERN = /([astvzqmhlc])([^astvzqmhlc]*)/gi;
17
+ var NUMBER = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;
18
+ function parseValues(args) {
19
+ const numbers = args.match(NUMBER);
20
+ return numbers ? numbers.map(Number) : [];
21
+ }
22
+ function parsePath(path) {
23
+ const data = [];
24
+ const p = String(path).trim();
25
+ if (p[0] !== "M" && p[0] !== "m") {
26
+ return data;
27
+ }
28
+ p.replace(SEGMENT_PATTERN, (_, command, args) => {
29
+ const theArgs = parseValues(args);
30
+ let type = command.toLowerCase();
31
+ let theCommand = command;
32
+ if (type === "m" && theArgs.length > 2) {
33
+ data.push([theCommand, ...theArgs.splice(0, 2)]);
34
+ type = "l";
35
+ theCommand = theCommand === "m" ? "l" : "L";
36
+ }
37
+ if (theArgs.length < ARG_LENGTH[type]) {
38
+ return "";
39
+ }
40
+ data.push([theCommand, ...theArgs.splice(0, ARG_LENGTH[type])]);
41
+ while (theArgs.length >= ARG_LENGTH[type] && theArgs.length && ARG_LENGTH[type]) {
42
+ data.push([theCommand, ...theArgs.splice(0, ARG_LENGTH[type])]);
43
+ }
44
+ return "";
45
+ });
46
+ return data;
47
+ }
48
+ function rotatePoint(point, angle) {
49
+ const nx = point.x * Math.cos(angle) - point.y * Math.sin(angle);
50
+ const ny = point.y * Math.cos(angle) + point.x * Math.sin(angle);
51
+ point.x = nx;
52
+ point.y = ny;
53
+ }
54
+ function translatePoint(point, dx, dy) {
55
+ point.x += dx;
56
+ point.y += dy;
57
+ }
58
+ function scalePoint(point, s) {
59
+ point.x *= s;
60
+ point.y *= s;
61
+ }
62
+ var Path2D = class _Path2D {
63
+ constructor(path) {
64
+ this.commands = [];
65
+ if (path && path instanceof _Path2D) {
66
+ this.commands.push(...path.commands);
67
+ } else if (path) {
68
+ this.commands = parsePath(path);
69
+ }
70
+ }
71
+ addPath(path) {
72
+ if (path && path instanceof _Path2D) {
73
+ this.commands.push(...path.commands);
74
+ }
75
+ }
76
+ moveTo(x, y) {
77
+ this.commands.push(["M", x, y]);
78
+ }
79
+ lineTo(x, y) {
80
+ this.commands.push(["L", x, y]);
81
+ }
82
+ arc(x, y, r, start, end, ccw) {
83
+ this.commands.push(["AC", x, y, r, start, end, !!ccw]);
84
+ }
85
+ arcTo(x1, y1, x2, y2, r) {
86
+ this.commands.push(["AT", x1, y1, x2, y2, r]);
87
+ }
88
+ ellipse(x, y, rx, ry, angle, start, end, ccw) {
89
+ this.commands.push(["E", x, y, rx, ry, angle, start, end, !!ccw]);
90
+ }
91
+ closePath() {
92
+ this.commands.push(["Z"]);
93
+ }
94
+ bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
95
+ this.commands.push(["C", cp1x, cp1y, cp2x, cp2y, x, y]);
96
+ }
97
+ quadraticCurveTo(cpx, cpy, x, y) {
98
+ this.commands.push(["Q", cpx, cpy, x, y]);
99
+ }
100
+ rect(x, y, width, height) {
101
+ this.commands.push(["R", x, y, width, height]);
102
+ }
103
+ roundRect(x, y, width, height, radii) {
104
+ if (typeof radii === "undefined") {
105
+ this.commands.push(["RR", x, y, width, height, 0]);
106
+ } else {
107
+ this.commands.push(["RR", x, y, width, height, radii]);
108
+ }
109
+ }
110
+ };
111
+ function buildPath(ctx, commands) {
112
+ let x = 0;
113
+ let y = 0;
114
+ let endAngle;
115
+ let startAngle;
116
+ let largeArcFlag;
117
+ let sweepFlag;
118
+ let endPoint;
119
+ let midPoint;
120
+ let angle;
121
+ let lambda;
122
+ let t1;
123
+ let t2;
124
+ let x1;
125
+ let y1;
126
+ let r;
127
+ let rx;
128
+ let ry;
129
+ let w;
130
+ let h;
131
+ let pathType;
132
+ let centerPoint;
133
+ let ccw;
134
+ let radii;
135
+ let cpx = null;
136
+ let cpy = null;
137
+ let qcpx = null;
138
+ let qcpy = null;
139
+ let startPoint = null;
140
+ let currentPoint = null;
141
+ ctx.beginPath();
142
+ for (let i = 0; i < commands.length; ++i) {
143
+ pathType = commands[i][0];
144
+ if (pathType !== "S" && pathType !== "s" && pathType !== "C" && pathType !== "c") {
145
+ cpx = null;
146
+ cpy = null;
147
+ }
148
+ if (pathType !== "T" && pathType !== "t" && pathType !== "Q" && pathType !== "q") {
149
+ qcpx = null;
150
+ qcpy = null;
151
+ }
152
+ let c;
153
+ switch (pathType) {
154
+ case "m":
155
+ case "M":
156
+ c = commands[i];
157
+ if (pathType === "m") {
158
+ x += c[1];
159
+ y += c[2];
160
+ } else {
161
+ x = c[1];
162
+ y = c[2];
163
+ }
164
+ if (pathType === "M" || !startPoint) {
165
+ startPoint = { x, y };
166
+ }
167
+ ctx.moveTo(x, y);
168
+ break;
169
+ case "l":
170
+ c = commands[i];
171
+ x += c[1];
172
+ y += c[2];
173
+ ctx.lineTo(x, y);
174
+ break;
175
+ case "L":
176
+ c = commands[i];
177
+ x = c[1];
178
+ y = c[2];
179
+ ctx.lineTo(x, y);
180
+ break;
181
+ case "H":
182
+ c = commands[i];
183
+ x = c[1];
184
+ ctx.lineTo(x, y);
185
+ break;
186
+ case "h":
187
+ c = commands[i];
188
+ x += c[1];
189
+ ctx.lineTo(x, y);
190
+ break;
191
+ case "V":
192
+ c = commands[i];
193
+ y = c[1];
194
+ ctx.lineTo(x, y);
195
+ break;
196
+ case "v":
197
+ c = commands[i];
198
+ y += c[1];
199
+ ctx.lineTo(x, y);
200
+ break;
201
+ case "a":
202
+ case "A":
203
+ c = commands[i];
204
+ if (currentPoint === null) {
205
+ throw new Error("This should never happen");
206
+ }
207
+ if (pathType === "a") {
208
+ x += c[6];
209
+ y += c[7];
210
+ } else {
211
+ x = c[6];
212
+ y = c[7];
213
+ }
214
+ rx = c[1];
215
+ ry = c[2];
216
+ angle = c[3] * Math.PI / 180;
217
+ largeArcFlag = !!c[4];
218
+ sweepFlag = !!c[5];
219
+ endPoint = { x, y };
220
+ midPoint = {
221
+ x: (currentPoint.x - endPoint.x) / 2,
222
+ y: (currentPoint.y - endPoint.y) / 2
223
+ };
224
+ rotatePoint(midPoint, -angle);
225
+ lambda = midPoint.x * midPoint.x / (rx * rx) + midPoint.y * midPoint.y / (ry * ry);
226
+ if (lambda > 1) {
227
+ lambda = Math.sqrt(lambda);
228
+ rx *= lambda;
229
+ ry *= lambda;
230
+ }
231
+ centerPoint = {
232
+ x: rx * midPoint.y / ry,
233
+ y: -(ry * midPoint.x) / rx
234
+ };
235
+ t1 = rx * rx * ry * ry;
236
+ t2 = rx * rx * midPoint.y * midPoint.y + ry * ry * midPoint.x * midPoint.x;
237
+ if (sweepFlag !== largeArcFlag) {
238
+ scalePoint(centerPoint, Math.sqrt((t1 - t2) / t2) || 0);
239
+ } else {
240
+ scalePoint(centerPoint, -Math.sqrt((t1 - t2) / t2) || 0);
241
+ }
242
+ startAngle = Math.atan2((midPoint.y - centerPoint.y) / ry, (midPoint.x - centerPoint.x) / rx);
243
+ endAngle = Math.atan2(-(midPoint.y + centerPoint.y) / ry, -(midPoint.x + centerPoint.x) / rx);
244
+ rotatePoint(centerPoint, angle);
245
+ translatePoint(centerPoint, (endPoint.x + currentPoint.x) / 2, (endPoint.y + currentPoint.y) / 2);
246
+ ctx.save();
247
+ ctx.translate(centerPoint.x, centerPoint.y);
248
+ ctx.rotate(angle);
249
+ ctx.scale(rx, ry);
250
+ ctx.arc(0, 0, 1, startAngle, endAngle, !sweepFlag);
251
+ ctx.restore();
252
+ break;
253
+ case "C":
254
+ c = commands[i];
255
+ cpx = c[3];
256
+ cpy = c[4];
257
+ x = c[5];
258
+ y = c[6];
259
+ ctx.bezierCurveTo(c[1], c[2], cpx, cpy, x, y);
260
+ break;
261
+ case "c":
262
+ c = commands[i];
263
+ ctx.bezierCurveTo(c[1] + x, c[2] + y, c[3] + x, c[4] + y, c[5] + x, c[6] + y);
264
+ cpx = c[3] + x;
265
+ cpy = c[4] + y;
266
+ x += c[5];
267
+ y += c[6];
268
+ break;
269
+ case "S":
270
+ c = commands[i];
271
+ if (cpx === null || cpy === null) {
272
+ cpx = x;
273
+ cpy = y;
274
+ }
275
+ ctx.bezierCurveTo(2 * x - cpx, 2 * y - cpy, c[1], c[2], c[3], c[4]);
276
+ cpx = c[1];
277
+ cpy = c[2];
278
+ x = c[3];
279
+ y = c[4];
280
+ break;
281
+ case "s":
282
+ c = commands[i];
283
+ if (cpx === null || cpy === null) {
284
+ cpx = x;
285
+ cpy = y;
286
+ }
287
+ ctx.bezierCurveTo(2 * x - cpx, 2 * y - cpy, c[1] + x, c[2] + y, c[3] + x, c[4] + y);
288
+ cpx = c[1] + x;
289
+ cpy = c[2] + y;
290
+ x += c[3];
291
+ y += c[4];
292
+ break;
293
+ case "Q":
294
+ c = commands[i];
295
+ qcpx = c[1];
296
+ qcpy = c[2];
297
+ x = c[3];
298
+ y = c[4];
299
+ ctx.quadraticCurveTo(qcpx, qcpy, x, y);
300
+ break;
301
+ case "q":
302
+ c = commands[i];
303
+ qcpx = c[1] + x;
304
+ qcpy = c[2] + y;
305
+ x += c[3];
306
+ y += c[4];
307
+ ctx.quadraticCurveTo(qcpx, qcpy, x, y);
308
+ break;
309
+ case "T":
310
+ c = commands[i];
311
+ if (qcpx === null || qcpy === null) {
312
+ qcpx = x;
313
+ qcpy = y;
314
+ }
315
+ qcpx = 2 * x - qcpx;
316
+ qcpy = 2 * y - qcpy;
317
+ x = c[1];
318
+ y = c[2];
319
+ ctx.quadraticCurveTo(qcpx, qcpy, x, y);
320
+ break;
321
+ case "t":
322
+ c = commands[i];
323
+ if (qcpx === null || qcpy === null) {
324
+ qcpx = x;
325
+ qcpy = y;
326
+ }
327
+ qcpx = 2 * x - qcpx;
328
+ qcpy = 2 * y - qcpy;
329
+ x += c[1];
330
+ y += c[2];
331
+ ctx.quadraticCurveTo(qcpx, qcpy, x, y);
332
+ break;
333
+ case "z":
334
+ case "Z":
335
+ if (startPoint) {
336
+ x = startPoint.x;
337
+ y = startPoint.y;
338
+ }
339
+ startPoint = null;
340
+ ctx.closePath();
341
+ break;
342
+ case "AC":
343
+ c = commands[i];
344
+ x = c[1];
345
+ y = c[2];
346
+ r = c[3];
347
+ startAngle = c[4];
348
+ endAngle = c[5];
349
+ ccw = c[6];
350
+ ctx.arc(x, y, r, startAngle, endAngle, ccw);
351
+ break;
352
+ case "AT":
353
+ c = commands[i];
354
+ x1 = c[1];
355
+ y1 = c[2];
356
+ x = c[3];
357
+ y = c[4];
358
+ r = c[5];
359
+ ctx.arcTo(x1, y1, x, y, r);
360
+ break;
361
+ case "E":
362
+ c = commands[i];
363
+ x = c[1];
364
+ y = c[2];
365
+ rx = c[3];
366
+ ry = c[4];
367
+ angle = c[5];
368
+ startAngle = c[6];
369
+ endAngle = c[7];
370
+ ccw = c[8];
371
+ ctx.save();
372
+ ctx.translate(x, y);
373
+ ctx.rotate(angle);
374
+ ctx.scale(rx, ry);
375
+ ctx.arc(0, 0, 1, startAngle, endAngle, ccw);
376
+ ctx.restore();
377
+ break;
378
+ case "R":
379
+ c = commands[i];
380
+ x = c[1];
381
+ y = c[2];
382
+ w = c[3];
383
+ h = c[4];
384
+ startPoint = { x, y };
385
+ ctx.rect(x, y, w, h);
386
+ break;
387
+ case "RR":
388
+ c = commands[i];
389
+ x = c[1];
390
+ y = c[2];
391
+ w = c[3];
392
+ h = c[4];
393
+ radii = c[5];
394
+ startPoint = { x, y };
395
+ ctx.roundRect(x, y, w, h, radii);
396
+ break;
397
+ default:
398
+ throw new Error(`Invalid path command: ${pathType}`);
399
+ }
400
+ if (!currentPoint) {
401
+ currentPoint = { x, y };
402
+ } else {
403
+ currentPoint.x = x;
404
+ currentPoint.y = y;
405
+ }
406
+ }
407
+ }
408
+ function roundRect(x, y, width, height, radii = 0) {
409
+ if (typeof radii === "number") {
410
+ radii = [radii];
411
+ }
412
+ if (Array.isArray(radii)) {
413
+ if (radii.length === 0 || radii.length > 4) {
414
+ throw new RangeError(
415
+ `Failed to execute 'roundRect' on '${this.constructor.name}': ${radii.length} radii provided. Between one and four radii are necessary.`
416
+ );
417
+ }
418
+ radii.forEach((v) => {
419
+ if (v < 0) {
420
+ throw new RangeError(
421
+ `Failed to execute 'roundRect' on '${this.constructor.name}': Radius value ${v} is negative.`
422
+ );
423
+ }
424
+ });
425
+ } else {
426
+ return;
427
+ }
428
+ if (radii.length === 1 && radii[0] === 0) {
429
+ this.rect(x, y, width, height);
430
+ return;
431
+ }
432
+ const minRadius = Math.min(width, height) / 2;
433
+ const tl = Math.min(minRadius, radii[0]);
434
+ let tr = tl;
435
+ let br = tl;
436
+ let bl = tl;
437
+ if (radii.length === 2) {
438
+ tr = Math.min(minRadius, radii[1]);
439
+ bl = tr;
440
+ }
441
+ if (radii.length === 3) {
442
+ tr = Math.min(minRadius, radii[1]);
443
+ bl = tr;
444
+ br = Math.min(minRadius, radii[2]);
445
+ }
446
+ if (radii.length === 4) {
447
+ tr = Math.min(minRadius, radii[1]);
448
+ br = Math.min(minRadius, radii[2]);
449
+ bl = Math.min(minRadius, radii[3]);
450
+ }
451
+ this.moveTo(x, y + height - bl);
452
+ this.arcTo(x, y, x + tl, y, tl);
453
+ this.arcTo(x + width, y, x + width, y + tr, tr);
454
+ this.arcTo(x + width, y + height, x + width - br, y + height, br);
455
+ this.arcTo(x, y + height, x, y + height - bl, bl);
456
+ this.closePath();
457
+ }
458
+ function applyPath2DToCanvasRenderingContext(CanvasRenderingContext2D) {
459
+ if (!CanvasRenderingContext2D) return;
460
+ const cClip = CanvasRenderingContext2D.prototype.clip;
461
+ const cFill = CanvasRenderingContext2D.prototype.fill;
462
+ const cStroke = CanvasRenderingContext2D.prototype.stroke;
463
+ const cIsPointInPath = CanvasRenderingContext2D.prototype.isPointInPath;
464
+ CanvasRenderingContext2D.prototype.clip = function clip(...args) {
465
+ if (args[0] instanceof Path2D) {
466
+ const path = args[0];
467
+ const fillRule2 = args[1] || "nonzero";
468
+ buildPath(this, path.commands);
469
+ return cClip.apply(this, [fillRule2]);
470
+ }
471
+ const fillRule = args[0] || "nonzero";
472
+ return cClip.apply(this, [fillRule]);
473
+ };
474
+ CanvasRenderingContext2D.prototype.fill = function fill(...args) {
475
+ if (args[0] instanceof Path2D) {
476
+ const path = args[0];
477
+ const fillRule2 = args[1] || "nonzero";
478
+ buildPath(this, path.commands);
479
+ return cFill.apply(this, [fillRule2]);
480
+ }
481
+ const fillRule = args[0] || "nonzero";
482
+ return cFill.apply(this, [fillRule]);
483
+ };
484
+ CanvasRenderingContext2D.prototype.stroke = function stroke(path) {
485
+ if (path) {
486
+ buildPath(this, path.commands);
487
+ }
488
+ cStroke.apply(this);
489
+ };
490
+ CanvasRenderingContext2D.prototype.isPointInPath = function isPointInPath(...args) {
491
+ if (args[0] instanceof Path2D) {
492
+ const path = args[0];
493
+ const x = args[1];
494
+ const y = args[2];
495
+ const fillRule = args[3] || "nonzero";
496
+ buildPath(this, path.commands);
497
+ return cIsPointInPath.apply(this, [x, y, fillRule]);
498
+ }
499
+ return cIsPointInPath.apply(this, args);
500
+ };
501
+ }
502
+ function applyRoundRectToCanvasRenderingContext2D(CanvasRenderingContext2D) {
503
+ if (CanvasRenderingContext2D && !CanvasRenderingContext2D.prototype.roundRect) {
504
+ CanvasRenderingContext2D.prototype.roundRect = roundRect;
505
+ }
506
+ }
507
+ function applyRoundRectToPath2D(P2D) {
508
+ if (P2D && !P2D.prototype.roundRect) {
509
+ P2D.prototype.roundRect = roundRect;
510
+ }
511
+ }
512
+ export {
513
+ Path2D,
514
+ applyPath2DToCanvasRenderingContext,
515
+ applyRoundRectToCanvasRenderingContext2D,
516
+ applyRoundRectToPath2D,
517
+ buildPath,
518
+ parsePath,
519
+ roundRect
520
+ };
521
+ //# sourceMappingURL=dist-NDNRSNOG.js.map