juxscript 1.1.239 → 1.1.243

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 (297) hide show
  1. package/index.js +7 -137
  2. package/lib/components/dataframe.ts +0 -569
  3. package/lib/components/tag.ts +68 -0
  4. package/lib/styles/shadcn.css +20 -7
  5. package/lib/utils/idgen.ts +6 -0
  6. package/package.json +5 -6
  7. package/index.d.ts +0 -239
  8. package/index.d.ts.map +0 -1
  9. package/lib/components/alert.d.ts +0 -36
  10. package/lib/components/alert.d.ts.map +0 -1
  11. package/lib/components/alert.js +0 -172
  12. package/lib/components/alert.ts +0 -219
  13. package/lib/components/app.d.ts +0 -89
  14. package/lib/components/app.d.ts.map +0 -1
  15. package/lib/components/app.js +0 -175
  16. package/lib/components/app.ts +0 -247
  17. package/lib/components/badge.d.ts +0 -26
  18. package/lib/components/badge.d.ts.map +0 -1
  19. package/lib/components/badge.js +0 -91
  20. package/lib/components/badge.ts +0 -118
  21. package/lib/components/base/Animations.d.ts +0 -36
  22. package/lib/components/base/Animations.d.ts.map +0 -1
  23. package/lib/components/base/Animations.js +0 -70
  24. package/lib/components/base/Animations.ts +0 -112
  25. package/lib/components/base/BaseComponent.d.ts +0 -294
  26. package/lib/components/base/BaseComponent.d.ts.map +0 -1
  27. package/lib/components/base/BaseComponent.js +0 -735
  28. package/lib/components/base/BaseComponent.ts +0 -884
  29. package/lib/components/base/FormInput.d.ts +0 -77
  30. package/lib/components/base/FormInput.d.ts.map +0 -1
  31. package/lib/components/base/FormInput.js +0 -171
  32. package/lib/components/base/FormInput.ts +0 -237
  33. package/lib/components/blueprint.d.ts +0 -40
  34. package/lib/components/blueprint.d.ts.map +0 -1
  35. package/lib/components/blueprint.js +0 -327
  36. package/lib/components/button.d.ts +0 -70
  37. package/lib/components/button.d.ts.map +0 -1
  38. package/lib/components/button.js +0 -177
  39. package/lib/components/button.ts +0 -237
  40. package/lib/components/card.d.ts +0 -35
  41. package/lib/components/card.d.ts.map +0 -1
  42. package/lib/components/card.js +0 -130
  43. package/lib/components/card.ts +0 -177
  44. package/lib/components/chart.d.ts +0 -49
  45. package/lib/components/chart.d.ts.map +0 -1
  46. package/lib/components/chart.js +0 -205
  47. package/lib/components/chart.ts +0 -254
  48. package/lib/components/checkbox.d.ts +0 -33
  49. package/lib/components/checkbox.d.ts.map +0 -1
  50. package/lib/components/checkbox.js +0 -202
  51. package/lib/components/checkbox.ts +0 -260
  52. package/lib/components/code.d.ts +0 -52
  53. package/lib/components/code.d.ts.map +0 -1
  54. package/lib/components/code.js +0 -201
  55. package/lib/components/code.ts +0 -260
  56. package/lib/components/container.d.ts +0 -60
  57. package/lib/components/container.d.ts.map +0 -1
  58. package/lib/components/container.js +0 -195
  59. package/lib/components/container.ts +0 -259
  60. package/lib/components/data.d.ts +0 -36
  61. package/lib/components/data.d.ts.map +0 -1
  62. package/lib/components/data.js +0 -110
  63. package/lib/components/data.ts +0 -135
  64. package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
  65. package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
  66. package/lib/components/dataframe/DataFrameSource.js +0 -421
  67. package/lib/components/dataframe/DataFrameSource.ts +0 -532
  68. package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
  69. package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
  70. package/lib/components/dataframe/ImportSettingsModal.js +0 -442
  71. package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
  72. package/lib/components/dataframe.d.ts +0 -110
  73. package/lib/components/dataframe.d.ts.map +0 -1
  74. package/lib/components/dataframe.js +0 -470
  75. package/lib/components/datepicker.d.ts +0 -40
  76. package/lib/components/datepicker.d.ts.map +0 -1
  77. package/lib/components/datepicker.js +0 -193
  78. package/lib/components/datepicker.ts +0 -251
  79. package/lib/components/dialog.d.ts +0 -39
  80. package/lib/components/dialog.d.ts.map +0 -1
  81. package/lib/components/dialog.js +0 -131
  82. package/lib/components/dialog.ts +0 -178
  83. package/lib/components/divider.d.ts +0 -31
  84. package/lib/components/divider.d.ts.map +0 -1
  85. package/lib/components/divider.js +0 -72
  86. package/lib/components/divider.ts +0 -104
  87. package/lib/components/dropdown-menu.d.ts +0 -42
  88. package/lib/components/dropdown-menu.d.ts.map +0 -1
  89. package/lib/components/dropdown-menu.js +0 -177
  90. package/lib/components/dropdown-menu.ts +0 -214
  91. package/lib/components/dropdown.d.ts +0 -41
  92. package/lib/components/dropdown.d.ts.map +0 -1
  93. package/lib/components/dropdown.js +0 -136
  94. package/lib/components/dropdown.ts +0 -188
  95. package/lib/components/element.d.ts +0 -51
  96. package/lib/components/element.d.ts.map +0 -1
  97. package/lib/components/element.js +0 -209
  98. package/lib/components/element.ts +0 -271
  99. package/lib/components/event-chain.d.ts +0 -9
  100. package/lib/components/event-chain.d.ts.map +0 -1
  101. package/lib/components/event-chain.js +0 -33
  102. package/lib/components/fileupload.d.ts +0 -98
  103. package/lib/components/fileupload.d.ts.map +0 -1
  104. package/lib/components/fileupload.js +0 -351
  105. package/lib/components/fileupload.ts +0 -449
  106. package/lib/components/grid.d.ts +0 -88
  107. package/lib/components/grid.d.ts.map +0 -1
  108. package/lib/components/grid.js +0 -208
  109. package/lib/components/grid.ts +0 -295
  110. package/lib/components/heading.d.ts +0 -25
  111. package/lib/components/heading.d.ts.map +0 -1
  112. package/lib/components/heading.js +0 -83
  113. package/lib/components/heading.ts +0 -113
  114. package/lib/components/helpers.d.ts +0 -9
  115. package/lib/components/helpers.d.ts.map +0 -1
  116. package/lib/components/helpers.js +0 -30
  117. package/lib/components/helpers.ts +0 -41
  118. package/lib/components/hero.d.ts +0 -60
  119. package/lib/components/hero.d.ts.map +0 -1
  120. package/lib/components/hero.js +0 -239
  121. package/lib/components/hero.ts +0 -302
  122. package/lib/components/history/StateHistory.d.ts +0 -91
  123. package/lib/components/history/StateHistory.d.ts.map +0 -1
  124. package/lib/components/history/StateHistory.js +0 -154
  125. package/lib/components/history/StateHistory.ts +0 -200
  126. package/lib/components/icon.d.ts +0 -36
  127. package/lib/components/icon.d.ts.map +0 -1
  128. package/lib/components/icon.js +0 -135
  129. package/lib/components/icon.ts +0 -182
  130. package/lib/components/icons.d.ts +0 -25
  131. package/lib/components/icons.d.ts.map +0 -1
  132. package/lib/components/icons.js +0 -440
  133. package/lib/components/icons.ts +0 -464
  134. package/lib/components/image.d.ts +0 -42
  135. package/lib/components/image.d.ts.map +0 -1
  136. package/lib/components/image.js +0 -204
  137. package/lib/components/image.ts +0 -260
  138. package/lib/components/include.d.ts +0 -86
  139. package/lib/components/include.d.ts.map +0 -1
  140. package/lib/components/include.js +0 -238
  141. package/lib/components/include.ts +0 -281
  142. package/lib/components/input.d.ts +0 -85
  143. package/lib/components/input.d.ts.map +0 -1
  144. package/lib/components/input.js +0 -362
  145. package/lib/components/input.ts +0 -473
  146. package/lib/components/layer.d.ts +0 -72
  147. package/lib/components/layer.d.ts.map +0 -1
  148. package/lib/components/layer.js +0 -219
  149. package/lib/components/layer.ts +0 -304
  150. package/lib/components/link.d.ts +0 -41
  151. package/lib/components/link.d.ts.map +0 -1
  152. package/lib/components/link.js +0 -216
  153. package/lib/components/link.ts +0 -268
  154. package/lib/components/list.d.ts +0 -83
  155. package/lib/components/list.d.ts.map +0 -1
  156. package/lib/components/list.js +0 -314
  157. package/lib/components/list.ts +0 -423
  158. package/lib/components/loading.d.ts +0 -25
  159. package/lib/components/loading.d.ts.map +0 -1
  160. package/lib/components/loading.js +0 -76
  161. package/lib/components/loading.ts +0 -104
  162. package/lib/components/menu.d.ts +0 -38
  163. package/lib/components/menu.d.ts.map +0 -1
  164. package/lib/components/menu.js +0 -205
  165. package/lib/components/menu.ts +0 -279
  166. package/lib/components/modal.d.ts +0 -97
  167. package/lib/components/modal.d.ts.map +0 -1
  168. package/lib/components/modal.js +0 -463
  169. package/lib/components/modal.ts +0 -576
  170. package/lib/components/nav.d.ts +0 -46
  171. package/lib/components/nav.d.ts.map +0 -1
  172. package/lib/components/nav.js +0 -193
  173. package/lib/components/nav.ts +0 -261
  174. package/lib/components/paragraph.d.ts +0 -30
  175. package/lib/components/paragraph.d.ts.map +0 -1
  176. package/lib/components/paragraph.js +0 -93
  177. package/lib/components/paragraph.ts +0 -123
  178. package/lib/components/pen.d.ts +0 -125
  179. package/lib/components/pen.d.ts.map +0 -1
  180. package/lib/components/pen.js +0 -443
  181. package/lib/components/pen.ts +0 -567
  182. package/lib/components/progress.d.ts +0 -40
  183. package/lib/components/progress.d.ts.map +0 -1
  184. package/lib/components/progress.js +0 -116
  185. package/lib/components/progress.ts +0 -163
  186. package/lib/components/radio.d.ts +0 -43
  187. package/lib/components/radio.d.ts.map +0 -1
  188. package/lib/components/radio.js +0 -226
  189. package/lib/components/radio.ts +0 -303
  190. package/lib/components/registry.d.ts +0 -34
  191. package/lib/components/registry.d.ts.map +0 -1
  192. package/lib/components/registry.js +0 -163
  193. package/lib/components/registry.ts +0 -193
  194. package/lib/components/req.d.ts +0 -155
  195. package/lib/components/req.d.ts.map +0 -1
  196. package/lib/components/req.js +0 -253
  197. package/lib/components/req.ts +0 -303
  198. package/lib/components/script.d.ts +0 -14
  199. package/lib/components/script.d.ts.map +0 -1
  200. package/lib/components/script.js +0 -33
  201. package/lib/components/script.ts +0 -41
  202. package/lib/components/select.d.ts +0 -42
  203. package/lib/components/select.d.ts.map +0 -1
  204. package/lib/components/select.js +0 -209
  205. package/lib/components/select.ts +0 -281
  206. package/lib/components/sidebar.d.ts +0 -59
  207. package/lib/components/sidebar.d.ts.map +0 -1
  208. package/lib/components/sidebar.js +0 -298
  209. package/lib/components/sidebar.ts +0 -395
  210. package/lib/components/stack/BaseStack.d.ts +0 -65
  211. package/lib/components/stack/BaseStack.d.ts.map +0 -1
  212. package/lib/components/stack/BaseStack.js +0 -274
  213. package/lib/components/stack/BaseStack.ts +0 -328
  214. package/lib/components/stack/HStack.d.ts +0 -18
  215. package/lib/components/stack/HStack.d.ts.map +0 -1
  216. package/lib/components/stack/HStack.js +0 -22
  217. package/lib/components/stack/HStack.ts +0 -25
  218. package/lib/components/stack/VStack.d.ts +0 -19
  219. package/lib/components/stack/VStack.d.ts.map +0 -1
  220. package/lib/components/stack/VStack.js +0 -23
  221. package/lib/components/stack/VStack.ts +0 -26
  222. package/lib/components/stack/ZStack.d.ts +0 -18
  223. package/lib/components/stack/ZStack.d.ts.map +0 -1
  224. package/lib/components/stack/ZStack.js +0 -22
  225. package/lib/components/stack/ZStack.ts +0 -25
  226. package/lib/components/style.d.ts +0 -14
  227. package/lib/components/style.d.ts.map +0 -1
  228. package/lib/components/style.js +0 -33
  229. package/lib/components/style.ts +0 -41
  230. package/lib/components/switch.d.ts +0 -34
  231. package/lib/components/switch.d.ts.map +0 -1
  232. package/lib/components/switch.js +0 -209
  233. package/lib/components/switch.ts +0 -272
  234. package/lib/components/table.d.ts +0 -137
  235. package/lib/components/table.d.ts.map +0 -1
  236. package/lib/components/table.js +0 -1019
  237. package/lib/components/table.ts +0 -1225
  238. package/lib/components/tabs.d.ts +0 -53
  239. package/lib/components/tabs.d.ts.map +0 -1
  240. package/lib/components/tabs.js +0 -275
  241. package/lib/components/tabs.ts +0 -349
  242. package/lib/components/theme-toggle.d.ts +0 -45
  243. package/lib/components/theme-toggle.d.ts.map +0 -1
  244. package/lib/components/theme-toggle.js +0 -218
  245. package/lib/components/theme-toggle.ts +0 -297
  246. package/lib/components/tooltip.d.ts +0 -31
  247. package/lib/components/tooltip.d.ts.map +0 -1
  248. package/lib/components/tooltip.js +0 -112
  249. package/lib/components/tooltip.ts +0 -148
  250. package/lib/components/watcher.d.ts +0 -195
  251. package/lib/components/watcher.d.ts.map +0 -1
  252. package/lib/components/watcher.js +0 -241
  253. package/lib/components/watcher.ts +0 -261
  254. package/lib/components/write.d.ts +0 -107
  255. package/lib/components/write.d.ts.map +0 -1
  256. package/lib/components/write.js +0 -222
  257. package/lib/components/write.ts +0 -272
  258. package/lib/data/DataPipeline.d.ts +0 -113
  259. package/lib/data/DataPipeline.d.ts.map +0 -1
  260. package/lib/data/DataPipeline.js +0 -359
  261. package/lib/data/DataPipeline.ts +0 -452
  262. package/lib/facades/dataframe.jux +0 -0
  263. package/lib/globals.d.ts +0 -21
  264. package/lib/reactivity/state.d.ts +0 -36
  265. package/lib/reactivity/state.d.ts.map +0 -1
  266. package/lib/reactivity/state.js +0 -67
  267. package/lib/reactivity/state.ts +0 -78
  268. package/lib/storage/DataFrame.d.ts +0 -284
  269. package/lib/storage/DataFrame.d.ts.map +0 -1
  270. package/lib/storage/DataFrame.js +0 -1022
  271. package/lib/storage/DataFrame.ts +0 -1195
  272. package/lib/storage/DataFrameSource.d.ts +0 -158
  273. package/lib/storage/DataFrameSource.d.ts.map +0 -1
  274. package/lib/storage/DataFrameSource.js +0 -409
  275. package/lib/storage/DataFrameSource.ts +0 -556
  276. package/lib/storage/FileStorage.d.ts +0 -53
  277. package/lib/storage/FileStorage.d.ts.map +0 -1
  278. package/lib/storage/FileStorage.js +0 -80
  279. package/lib/storage/FileStorage.ts +0 -95
  280. package/lib/storage/IndexedDBDriver.d.ts +0 -75
  281. package/lib/storage/IndexedDBDriver.d.ts.map +0 -1
  282. package/lib/storage/IndexedDBDriver.js +0 -177
  283. package/lib/storage/IndexedDBDriver.ts +0 -226
  284. package/lib/storage/TabularDriver.d.ts +0 -118
  285. package/lib/storage/TabularDriver.d.ts.map +0 -1
  286. package/lib/storage/TabularDriver.js +0 -731
  287. package/lib/storage/TabularDriver.ts +0 -874
  288. package/lib/utils/codeparser.d.ts +0 -29
  289. package/lib/utils/codeparser.d.ts.map +0 -1
  290. package/lib/utils/codeparser.js +0 -409
  291. package/lib/utils/fetch.d.ts +0 -176
  292. package/lib/utils/fetch.d.ts.map +0 -1
  293. package/lib/utils/fetch.js +0 -427
  294. package/lib/utils/formatId.d.ts +0 -16
  295. package/lib/utils/formatId.d.ts.map +0 -1
  296. package/lib/utils/formatId.js +0 -27
  297. package/lib/utils/path-resolver.js +0 -23
@@ -1,556 +0,0 @@
1
- import { DataFrame } from './DataFrame.js';
2
- import { TabularDriver } from './TabularDriver.js';
3
-
4
- export interface SourceOptions {
5
- // Storage
6
- dbName?: string;
7
- storeName?: string;
8
- persistToIndexedDB?: boolean;
9
-
10
- // Parsing
11
- inferTypes?: boolean;
12
- maxFileSize?: number; // MB
13
- maxSheetSize?: number;
14
- headerRow?: number;
15
- delimiter?: string;
16
- }
17
-
18
- export interface APIOptions {
19
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
20
- headers?: Record<string, string>;
21
- body?: any;
22
- credentials?: 'omit' | 'same-origin' | 'include';
23
- dataPath?: string; // JSONPath-like: "data.results" or "response.items[0].records"
24
- }
25
-
26
- export interface StreamOptions {
27
- mimeType?: string;
28
- chunkSize?: number;
29
- cacheToIndexedDB?: boolean;
30
- }
31
-
32
- export interface MultiSheetResult {
33
- sheets: Map<string, DataFrame>;
34
- sheetNames: string[];
35
- activeSheet: string;
36
- }
37
-
38
- /**
39
- * DataFrameSource - Data acquisition layer for DataFrames
40
- *
41
- * Responsibilities:
42
- * - Load from files (CSV, TSV, Excel)
43
- * - Load from URLs (fetch, stream)
44
- * - Load from APIs (with auth, JSON traversal)
45
- * - Load from IndexedDB
46
- * - Load from inline data
47
- * - Multi-sheet support
48
- * - Progress callbacks
49
- *
50
- * This is a PURE data layer - no UI concerns
51
- */
52
- export class DataFrameSource {
53
- private _driver: TabularDriver;
54
- private _options: SourceOptions;
55
- private _sheets: Map<string, DataFrame> = new Map();
56
- private _activeSheet: string = '';
57
- private _sourceName: string = '';
58
- private _rawFile: File | null = null;
59
- private _rawText: string | null = null;
60
-
61
- constructor(options: SourceOptions = {}) {
62
- this._options = {
63
- dbName: options.dbName ?? 'jux-dataframes',
64
- storeName: options.storeName ?? 'frames',
65
- persistToIndexedDB: options.persistToIndexedDB ?? false,
66
- inferTypes: options.inferTypes ?? true,
67
- maxFileSize: options.maxFileSize ?? 50,
68
- maxSheetSize: options.maxSheetSize ?? 100000,
69
- headerRow: options.headerRow ?? 0,
70
- delimiter: options.delimiter
71
- };
72
-
73
- this._driver = new TabularDriver(
74
- this._options.dbName!,
75
- this._options.storeName!
76
- );
77
- }
78
-
79
- /* ═══════════════════════════════════════════════════
80
- * FROM FILE
81
- * ═══════════════════════════════════════════════════ */
82
-
83
- /**
84
- * Load from a File object (CSV, TSV, Excel)
85
- */
86
- async fromFile(
87
- file: File,
88
- onProgress?: (loaded: number, total: number | null) => void
89
- ): Promise<DataFrame | MultiSheetResult> {
90
- const fileSizeMB = file.size / (1024 * 1024);
91
-
92
- if (fileSizeMB > this._options.maxFileSize!) {
93
- throw new Error(`File too large (${fileSizeMB.toFixed(1)}MB). Max: ${this._options.maxFileSize}MB`);
94
- }
95
-
96
- this._rawFile = file;
97
- this._sourceName = file.name;
98
-
99
- const isExcel = /\.(xlsx?|xls)$/i.test(file.name);
100
-
101
- if (isExcel) {
102
- const sheets = await this._driver.streamFileMultiSheet(file, {
103
- maxSheetSize: this._options.maxSheetSize,
104
- headerRow: this._options.headerRow,
105
- onProgress
106
- });
107
-
108
- this._sheets.clear();
109
- const sheetNames = Object.keys(sheets);
110
-
111
- sheetNames.forEach(name => {
112
- this._sheets.set(name, sheets[name]);
113
- });
114
-
115
- this._activeSheet = sheetNames[0] || '';
116
-
117
- if (this._options.persistToIndexedDB) {
118
- await this._driver.store(file.name, sheets[sheetNames[0]], { source: file.name });
119
- }
120
-
121
- if (sheetNames.length > 1) {
122
- return {
123
- sheets: this._sheets,
124
- sheetNames,
125
- activeSheet: this._activeSheet
126
- };
127
- } else {
128
- return this._sheets.get(this._activeSheet)!;
129
- }
130
- } else {
131
- const text = await file.text();
132
- this._rawText = text;
133
-
134
- const df = this._driver.parseCSV(text, {
135
- autoDetectDelimiter: !this._options.delimiter,
136
- delimiter: this._options.delimiter,
137
- headerRow: this._options.headerRow,
138
- hasHeader: true
139
- });
140
-
141
- this._sheets.set('Sheet1', df);
142
- this._activeSheet = 'Sheet1';
143
-
144
- if (this._options.persistToIndexedDB) {
145
- await this._driver.store(file.name, df, { source: file.name });
146
- }
147
-
148
- return df;
149
- }
150
- }
151
-
152
- /* ═══════════════════════════════════════════════════
153
- * FROM URL (Simple Fetch)
154
- * ═══════════════════════════════════════════════════ */
155
-
156
- /**
157
- * Fetch CSV/TSV from URL
158
- */
159
- async fromUrl(
160
- url: string,
161
- onProgress?: (loaded: number, total: number | null) => void
162
- ): Promise<DataFrame> {
163
- this._sourceName = url.split('/').pop() || url;
164
-
165
- const df = await this._driver.fetch(url, {
166
- autoDetectDelimiter: true,
167
- hasHeader: true,
168
- headerRow: this._options.headerRow,
169
- onProgress
170
- });
171
-
172
- this._sheets.set('Sheet1', df);
173
- this._activeSheet = 'Sheet1';
174
-
175
- if (this._options.persistToIndexedDB) {
176
- await this._driver.store(this._sourceName, df, { source: url });
177
- }
178
-
179
- return df;
180
- }
181
-
182
- /* ═══════════════════════════════════════════════════
183
- * FROM API (JSON with traversal)
184
- * ═══════════════════════════════════════════════════ */
185
-
186
- /**
187
- * Fetch data from API endpoint
188
- * Supports JSON response with path traversal
189
- */
190
- async fromAPI(url: string, options: APIOptions = {}): Promise<DataFrame> {
191
- const {
192
- method = 'GET',
193
- headers = {},
194
- body,
195
- credentials = 'same-origin',
196
- dataPath
197
- } = options;
198
-
199
- const fetchOptions: RequestInit = {
200
- method,
201
- headers: {
202
- 'Accept': 'application/json',
203
- ...headers
204
- },
205
- credentials
206
- };
207
-
208
- if (body && method !== 'GET') {
209
- fetchOptions.body = typeof body === 'string' ? body : JSON.stringify(body);
210
- if (!headers['Content-Type']) {
211
- (fetchOptions.headers as Record<string, string>)['Content-Type'] = 'application/json';
212
- }
213
- }
214
-
215
- const response = await fetch(url, fetchOptions);
216
-
217
- if (!response.ok) {
218
- throw new Error(`API request failed: ${response.status} ${response.statusText}`);
219
- }
220
-
221
- let data = await response.json();
222
-
223
- // Traverse to data path if specified
224
- if (dataPath) {
225
- data = this._traversePath(data, dataPath);
226
- }
227
-
228
- // Convert to DataFrame
229
- if (!Array.isArray(data)) {
230
- throw new Error('API response must be an array of objects (or use dataPath to navigate to array)');
231
- }
232
-
233
- const df = new DataFrame(data, { inferTypes: this._options.inferTypes });
234
-
235
- this._sourceName = url;
236
- this._sheets.set('Sheet1', df);
237
- this._activeSheet = 'Sheet1';
238
-
239
- if (this._options.persistToIndexedDB) {
240
- await this._driver.store(this._sourceName, df, { source: url });
241
- }
242
-
243
- return df;
244
- }
245
-
246
- /**
247
- * Traverse JSON path like "data.results" or "response.items[0].records"
248
- */
249
- private _traversePath(obj: any, path: string): any {
250
- const parts = path.split(/\.|\[|\]/).filter(Boolean);
251
- let current = obj;
252
-
253
- for (const part of parts) {
254
- if (current === null || current === undefined) {
255
- throw new Error(`Cannot traverse path '${path}': null at '${part}'`);
256
- }
257
-
258
- const index = Number(part);
259
- if (!isNaN(index)) {
260
- current = current[index];
261
- } else {
262
- current = current[part];
263
- }
264
- }
265
-
266
- return current;
267
- }
268
-
269
- /* ═══════════════════════════════════════════════════
270
- * FROM STREAM (Binary data with MIME type)
271
- * ═══════════════════════════════════════════════════ */
272
-
273
- /**
274
- * Stream binary data from URL, auto-detect format from MIME type
275
- */
276
- async fromStream(
277
- url: string,
278
- options: StreamOptions = {},
279
- onProgress?: (loaded: number, total: number | null) => void
280
- ): Promise<DataFrame | MultiSheetResult> {
281
- const {
282
- mimeType,
283
- cacheToIndexedDB = false
284
- } = options;
285
-
286
- const response = await fetch(url);
287
-
288
- if (!response.ok) {
289
- throw new Error(`Stream request failed: ${response.status}`);
290
- }
291
-
292
- const contentType = mimeType || response.headers.get('content-type') || '';
293
- const fileName = url.split('/').pop() || 'stream-data';
294
-
295
- // Get the blob
296
- const blob = await response.blob();
297
- const file = new File([blob], fileName, { type: contentType });
298
-
299
- // Cache to IndexedDB if requested
300
- if (cacheToIndexedDB) {
301
- // Store raw blob for potential re-parsing
302
- await this._cacheBlob(fileName, blob);
303
- }
304
-
305
- // Parse based on content type
306
- return this.fromFile(file, onProgress);
307
- }
308
-
309
- private async _cacheBlob(name: string, blob: Blob): Promise<void> {
310
- // Simple blob caching in IndexedDB
311
- const db = await this._driver.open();
312
- return new Promise((resolve, reject) => {
313
- const tx = db.transaction('blobs', 'readwrite');
314
- const store = tx.objectStore('blobs');
315
- store.put({ name, blob, timestamp: Date.now() });
316
- tx.oncomplete = () => resolve();
317
- tx.onerror = () => reject(tx.error);
318
- });
319
- }
320
-
321
- /* ═══════════════════════════════════════════════════
322
- * FROM INDEXEDDB
323
- * ═══════════════════════════════════════════════════ */
324
-
325
- /**
326
- * Load from IndexedDB by key/name
327
- */
328
- async fromStorage(key: string): Promise<DataFrame | null> {
329
- const df = await this._driver.loadByName(key);
330
-
331
- if (df) {
332
- this._sourceName = key;
333
- this._sheets.set('Sheet1', df);
334
- this._activeSheet = 'Sheet1';
335
- }
336
-
337
- return df;
338
- }
339
-
340
- /**
341
- * List all stored DataFrames
342
- */
343
- async listStored(): Promise<Array<{ id: string; name: string; rowCount: number; timestamp: number }>> {
344
- return this._driver.list();
345
- }
346
-
347
- /* ═══════════════════════════════════════════════════
348
- * FROM INLINE DATA
349
- * ═══════════════════════════════════════════════════ */
350
-
351
- /**
352
- * Create from inline data
353
- */
354
- fromData(
355
- data: Record<string, any>[] | Record<string, any[]>,
356
- name: string = 'inline'
357
- ): DataFrame {
358
- const df = new DataFrame(data, { inferTypes: this._options.inferTypes });
359
-
360
- this._sourceName = name;
361
- this._sheets.set('Sheet1', df);
362
- this._activeSheet = 'Sheet1';
363
-
364
- return df;
365
- }
366
-
367
- /**
368
- * Create empty DataFrame with specified columns
369
- */
370
- empty(columns: string[]): DataFrame {
371
- const data: Record<string, any[]> = {};
372
- columns.forEach(c => { data[c] = []; });
373
- return this.fromData(data, 'empty');
374
- }
375
-
376
- /* ═══════════════════════════════════════════════════
377
- * RE-IMPORT / RE-PARSE
378
- * ═══════════════════════════════════════════════════ */
379
-
380
- /**
381
- * Re-parse with different options
382
- */
383
- async reimport(options: {
384
- headerRow?: number;
385
- delimiter?: string;
386
- sheetName?: string;
387
- }): Promise<DataFrame | MultiSheetResult> {
388
- if (this._rawFile) {
389
- // Update options
390
- if (options.headerRow !== undefined) {
391
- this._options.headerRow = options.headerRow;
392
- }
393
- if (options.delimiter !== undefined) {
394
- this._options.delimiter = options.delimiter;
395
- }
396
-
397
- return this.fromFile(this._rawFile);
398
- } else if (this._rawText) {
399
- const df = this._driver.parseCSV(this._rawText, {
400
- delimiter: options.delimiter || this._options.delimiter,
401
- headerRow: options.headerRow ?? this._options.headerRow,
402
- hasHeader: true
403
- });
404
-
405
- this._sheets.set(this._activeSheet, df);
406
- return df;
407
- }
408
-
409
- throw new Error('No raw data available for reimport');
410
- }
411
-
412
- /**
413
- * Get raw preview rows for header selection UI
414
- */
415
- async getPreviewRows(maxRows: number = 15): Promise<{ row: number; values: any[] }[]> {
416
- if (this._rawFile && /\.(xlsx?|xls)$/i.test(this._rawFile.name)) {
417
- const rows = await this._driver.readRawExcelRows(this._rawFile, maxRows);
418
- return rows.map(r => ({ row: r.sheetRow, values: r.values }));
419
- } else if (this._rawText) {
420
- const lines = this._rawText.split('\n').slice(0, maxRows);
421
- const delimiter = (this._driver as any)._detectDelimiter(this._rawText);
422
- return lines.map((line, i) => ({
423
- row: i,
424
- values: (this._driver as any)._parseLine(line, delimiter)
425
- }));
426
- }
427
-
428
- return [];
429
- }
430
-
431
- /* ═══════════════════════════════════════════════════
432
- * MULTI-SHEET ACCESS
433
- * ═══════════════════════════════════════════════════ */
434
-
435
- /**
436
- * Get all sheet names
437
- */
438
- get sheetNames(): string[] {
439
- return Array.from(this._sheets.keys());
440
- }
441
-
442
- /**
443
- * Get active sheet
444
- */
445
- get activeSheet(): string {
446
- return this._activeSheet;
447
- }
448
-
449
- /**
450
- * Set active sheet
451
- */
452
- setActiveSheet(name: string): DataFrame {
453
- if (!this._sheets.has(name)) {
454
- throw new Error(`Sheet '${name}' not found`);
455
- }
456
- this._activeSheet = name;
457
- return this._sheets.get(name)!;
458
- }
459
-
460
- /**
461
- * Get specific sheet by name
462
- */
463
- getSheet(name: string): DataFrame | undefined {
464
- return this._sheets.get(name);
465
- }
466
-
467
- /**
468
- * Get current DataFrame (active sheet)
469
- */
470
- get df(): DataFrame | null {
471
- return this._sheets.get(this._activeSheet) || null;
472
- }
473
-
474
- /**
475
- * Get all sheets
476
- */
477
- get sheets(): Map<string, DataFrame> {
478
- return new Map(this._sheets);
479
- }
480
-
481
- /* ═══════════════════════════════════════════════════
482
- * PERSISTENCE
483
- * ═══════════════════════════════════════════════════ */
484
-
485
- /**
486
- * Save current DataFrame to IndexedDB
487
- */
488
- async save(key?: string): Promise<string | null> {
489
- const df = this.df;
490
- if (!df) return null;
491
-
492
- const name = key || this._sourceName;
493
- return this._driver.store(name, df);
494
- }
495
-
496
- /**
497
- * Save all sheets
498
- */
499
- async saveAll(prefix?: string): Promise<string[]> {
500
- const ids: string[] = [];
501
-
502
- for (const [sheetName, df] of this._sheets) {
503
- const key = prefix ? `${prefix}_${sheetName}` : `${this._sourceName}_${sheetName}`;
504
- const id = await this._driver.store(key, df);
505
- ids.push(id);
506
- }
507
-
508
- return ids;
509
- }
510
-
511
- /**
512
- * Delete from storage
513
- */
514
- async deleteStored(key: string): Promise<void> {
515
- const tables = await this._driver.list();
516
- const matching = tables.filter(t => t.name === key);
517
-
518
- for (const table of matching) {
519
- await this._driver.delete(table.id);
520
- }
521
- }
522
-
523
- /**
524
- * Clear all data
525
- */
526
- clear(): void {
527
- this._sheets.clear();
528
- this._activeSheet = '';
529
- this._sourceName = '';
530
- this._rawFile = null;
531
- this._rawText = null;
532
- }
533
-
534
- /* ═══════════════════════════════════════════════════
535
- * SOURCE INFO
536
- * ═══════════════════════════════════════════════════ */
537
-
538
- get sourceName(): string {
539
- return this._sourceName;
540
- }
541
-
542
- get hasRawData(): boolean {
543
- return this._rawFile !== null || this._rawText !== null;
544
- }
545
-
546
- get isExcel(): boolean {
547
- return this._rawFile !== null && /\.(xlsx?|xls)$/i.test(this._rawFile.name);
548
- }
549
- }
550
-
551
- /**
552
- * Factory function
553
- */
554
- export function dataFrameSource(options: SourceOptions = {}): DataFrameSource {
555
- return new DataFrameSource(options);
556
- }
@@ -1,53 +0,0 @@
1
- import { State } from '../reactivity/state.js';
2
- import { IndexedDBDriver, StoredFile, FileQuery } from './IndexedDBDriver.js';
3
- /**
4
- * Reactive file storage — wraps IndexedDBDriver with a State<StoredFile[]>
5
- * so components can subscribe to file list changes.
6
- */
7
- export declare class FileStorage {
8
- private _driver;
9
- private _state;
10
- constructor(dbName?: string, storeName?: string);
11
- /** Reactive state — subscribe to file list changes */
12
- get state(): State<StoredFile[]>;
13
- /** Current file list */
14
- get files(): StoredFile[];
15
- /** The underlying driver for advanced operations */
16
- get driver(): IndexedDBDriver;
17
- /**
18
- * Load file list from IndexedDB and update state
19
- */
20
- refresh(query?: FileQuery): Promise<StoredFile[]>;
21
- /**
22
- * Store a file and update state
23
- */
24
- store(file: File, metadata?: Record<string, any>): Promise<StoredFile>;
25
- /**
26
- * Store multiple files and update state
27
- */
28
- storeAll(files: File[], metadata?: Record<string, any>): Promise<StoredFile[]>;
29
- /**
30
- * Delete a file and update state
31
- */
32
- delete(id: string): Promise<void>;
33
- /**
34
- * Clear all files and update state
35
- */
36
- clear(): Promise<void>;
37
- /**
38
- * Get a stored file by ID (does not affect state)
39
- */
40
- get(id: string): Promise<StoredFile | null>;
41
- /**
42
- * Get storage usage
43
- */
44
- usage(): Promise<{
45
- count: number;
46
- bytes: number;
47
- }>;
48
- }
49
- /**
50
- * Factory function
51
- */
52
- export declare function fileStorage(dbName?: string, storeName?: string): FileStorage;
53
- //# sourceMappingURL=FileStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileStorage.d.ts","sourceRoot":"","sources":["FileStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE9E;;;GAGG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,MAAM,CAAsB;gBAExB,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAK/C,sDAAsD;IACtD,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC,CAE/B;IAED,wBAAwB;IACxB,IAAI,KAAK,IAAI,UAAU,EAAE,CAExB;IAED,oDAAoD;IACpD,IAAI,MAAM,IAAI,eAAe,CAE5B;IAED;;OAEG;IACG,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAMvD;;OAEG;IACG,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAM5E;;OAEG;IACG,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAMpF;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B;;OAEG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAIjD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAG3D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAE5E"}
@@ -1,80 +0,0 @@
1
- import { State } from '../reactivity/state.js';
2
- import { IndexedDBDriver } from './IndexedDBDriver.js';
3
- /**
4
- * Reactive file storage — wraps IndexedDBDriver with a State<StoredFile[]>
5
- * so components can subscribe to file list changes.
6
- */
7
- export class FileStorage {
8
- constructor(dbName, storeName) {
9
- this._driver = new IndexedDBDriver(dbName, storeName);
10
- this._state = new State([]);
11
- }
12
- /** Reactive state — subscribe to file list changes */
13
- get state() {
14
- return this._state;
15
- }
16
- /** Current file list */
17
- get files() {
18
- return this._state.value;
19
- }
20
- /** The underlying driver for advanced operations */
21
- get driver() {
22
- return this._driver;
23
- }
24
- /**
25
- * Load file list from IndexedDB and update state
26
- */
27
- async refresh(query) {
28
- const files = await this._driver.list(query);
29
- this._state.set(files);
30
- return files;
31
- }
32
- /**
33
- * Store a file and update state
34
- */
35
- async store(file, metadata) {
36
- const stored = await this._driver.store(file, metadata);
37
- await this.refresh();
38
- return stored;
39
- }
40
- /**
41
- * Store multiple files and update state
42
- */
43
- async storeAll(files, metadata) {
44
- const stored = await this._driver.storeAll(files, metadata);
45
- await this.refresh();
46
- return stored;
47
- }
48
- /**
49
- * Delete a file and update state
50
- */
51
- async delete(id) {
52
- await this._driver.delete(id);
53
- await this.refresh();
54
- }
55
- /**
56
- * Clear all files and update state
57
- */
58
- async clear() {
59
- await this._driver.clear();
60
- this._state.set([]);
61
- }
62
- /**
63
- * Get a stored file by ID (does not affect state)
64
- */
65
- async get(id) {
66
- return this._driver.get(id);
67
- }
68
- /**
69
- * Get storage usage
70
- */
71
- async usage() {
72
- return this._driver.usage();
73
- }
74
- }
75
- /**
76
- * Factory function
77
- */
78
- export function fileStorage(dbName, storeName) {
79
- return new FileStorage(dbName, storeName);
80
- }