@septkit/shell-lib 0.0.32 → 0.0.34

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 (2) hide show
  1. package/dist/index.js +521 -66
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -9,206 +9,661 @@ function a(e) {
9
9
  return i.some((t) => e.startsWith(t));
10
10
  }
11
11
  //#endregion
12
- //#region node_modules/.pnpm/@dialecte+core@0.6.1/node_modules/@dialecte/core/dist/utils-CTBHUFs9.js
13
- var o = {
12
+ //#region node_modules/.pnpm/@dialecte+core@0.8.0/node_modules/@dialecte/core/dist/utils-USNkj4sT.js
13
+ var o = "https://dialecte.github.io/core", s = {
14
14
  UNKNOWN: {
15
15
  code: "D0001",
16
- message: "An unknown error occurred"
16
+ message: "An unknown error occurred",
17
+ explanation: {
18
+ when: "A transaction's callback threw something that is not a structured error (a plain `Error`, a value); the original is its `cause`.",
19
+ fix: "Read `cause` and `detail`; raise your own failures with `throwDialecteError` or `invariant` so callers get a key.",
20
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
21
+ }
17
22
  },
18
23
  ASSERTION_FAILED: {
19
24
  code: "D0002",
20
- message: "Assertion failed"
25
+ message: "Assertion failed",
26
+ explanation: {
27
+ when: "An `invariant` without its own key failed, or core met a state it never expects (a catalogue built wrong, an inconsistent export, an engine running an sqlite-wasm older than 3.54.1, which removes a project on a failed install).",
28
+ fix: "Read `detail`: it names the condition. Give `invariant` a key of its own when the failure is one a caller should handle.",
29
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
30
+ }
21
31
  },
22
32
  STORE_CONNECTION_FAILED: {
23
33
  code: "D1001",
24
- message: "Failed to open database"
34
+ message: "Failed to open database",
35
+ explanation: {
36
+ when: "The project's database could not be opened (the SQLite file or its worker did not start), or the origin's hub could not be joined: its SharedWorker failed to start or was blocked, or a child's port went unanswered past the welcome budget (its page unbound it).",
37
+ fix: "Check the browser supports the store (OPFS, workers, SharedWorker for the hub) and that no other tab holds the project; reload, or open the project with another storage. A child view refused so is bound again by its page (`createHubPort`, then `adoptHubPort`).",
38
+ docs: `${o}/api/project#store-errors`
39
+ }
25
40
  },
26
41
  STORE_COMMIT_FAILED: {
27
42
  code: "D1002",
28
- message: "Failed to commit changes"
43
+ message: "Failed to commit changes",
44
+ explanation: {
45
+ when: "The database refused a transaction's write as it committed (the failure is the `cause`).",
46
+ fix: "Read `cause`; a full disk or a lost connection are the usual reasons. Retry the transaction once the store is back.",
47
+ docs: `${o}/api/project#store-errors`
48
+ }
29
49
  },
30
50
  STORE_RECORD_NOT_FOUND: {
31
51
  code: "D1003",
32
- message: "Record not found in database"
52
+ message: "Record not found in database",
53
+ explanation: {
54
+ when: "A write updated or deleted a record the store does not hold in that document.",
55
+ fix: "Read the record again before writing: it was deleted, or the ref names another document.",
56
+ docs: `${o}/api/project#store-errors`
57
+ }
33
58
  },
34
59
  STORE_BULK_ADD_FAILED: {
35
60
  code: "D1004",
36
- message: "Failed to add records to database"
61
+ message: "Failed to add records to database",
62
+ explanation: {
63
+ when: "The database refused to add a batch of records (import, commit); the failure is the `cause`.",
64
+ fix: "Read `cause`; a full disk or a closed store are the usual reasons.",
65
+ docs: `${o}/api/project#store-errors`
66
+ }
37
67
  },
38
68
  STORE_BULK_UPDATE_FAILED: {
39
69
  code: "D1005",
40
- message: "Failed to update records in database"
70
+ message: "Failed to update records in database",
71
+ explanation: {
72
+ when: "The database refused to update a batch of records; the failure is the `cause`.",
73
+ fix: "Read `cause`; a full disk or a closed store are the usual reasons.",
74
+ docs: `${o}/api/project#store-errors`
75
+ }
41
76
  },
42
77
  STORE_DELETE_FAILED: {
43
78
  code: "D1006",
44
- message: "Failed to delete records from database"
79
+ message: "Failed to delete records from database",
80
+ explanation: {
81
+ when: "The database refused to delete records; the failure is the `cause`.",
82
+ fix: "Read `cause`; a closed store is the usual reason.",
83
+ docs: `${o}/api/project#store-errors`
84
+ }
45
85
  },
46
86
  STORE_NOT_WRITABLE: {
47
87
  code: "D1007",
48
- message: "Store is not writable"
88
+ message: "Store is not writable",
89
+ explanation: {
90
+ when: "A write reached an in-memory store created read-only.",
91
+ fix: "Create the project with `storage: { type: 'inMemory', writable: true }` when the script writes.",
92
+ docs: `${o}/api/project#in-memory-storage`
93
+ }
49
94
  },
50
95
  STORE_BLOB_NOT_FOUND: {
51
96
  code: "D1008",
52
- message: "Blob not found"
97
+ message: "Blob not found",
98
+ explanation: {
99
+ when: "A blob operation named a blob id the store does not hold.",
100
+ fix: "List the blobs (`project.getBlobsByDocument`) and use an id from there.",
101
+ docs: `${o}/api/project#blobs`
102
+ }
103
+ },
104
+ STORE_DUPLICATE_ID: {
105
+ code: "D1009",
106
+ message: "An id is already taken in the store",
107
+ explanation: {
108
+ when: "A write would create a record (or register a document) with an id the store already holds; `meta.recordIds` lists them.",
109
+ fix: "Let core mint ids (omit `id`), or pick ids no record of the document has; `deepClone` mints new ids itself.",
110
+ docs: `${o}/api/project#store-errors`
111
+ }
112
+ },
113
+ STORE_CLOSED: {
114
+ code: "D1010",
115
+ message: "Store is closed",
116
+ explanation: {
117
+ when: "A store operation was still in flight when its store closed, or code holding the store itself (a custom store, a test context) called it after its `close()`. A project closed with `project.close()` answers `PROJECT_NOT_OPENED` instead.",
118
+ fix: "Await every operation before closing the store or the project; open it again before using it.",
119
+ docs: `${o}/api/project#lifecycle`
120
+ }
121
+ },
122
+ STORE_READ_FAILED: {
123
+ code: "D1011",
124
+ message: "Failed to read from database",
125
+ explanation: {
126
+ when: "The SQLite store's database failed under a read; the failure is the `cause`.",
127
+ fix: "Read `cause`; reopen the project. A lasting failure means the file is damaged: import its documents again.",
128
+ docs: `${o}/api/project#store-errors`
129
+ }
130
+ },
131
+ STORE_PROTOCOL_MISMATCH: {
132
+ code: "D1012",
133
+ message: "Another version of the library holds the shared store connection",
134
+ explanation: {
135
+ when: "Another version of the library already holds the shared store connection (another tab runs an older or newer build).",
136
+ fix: "Close the other tabs of the app, or reload them all on the same version.",
137
+ docs: `${o}/api/project#store-errors`
138
+ }
139
+ },
140
+ STORE_REALM_ID_TAKEN: {
141
+ code: "D1013",
142
+ message: "A view with this id is already connected to the shared store",
143
+ explanation: {
144
+ when: "A view joined the shared store with an id another connected view already uses.",
145
+ fix: "Give each view its own id; reload the page that reused one.",
146
+ docs: `${o}/api/project#store-errors`
147
+ }
148
+ },
149
+ STORE_REALM_UNKNOWN: {
150
+ code: "D1014",
151
+ message: "The shared store does not know this view",
152
+ explanation: {
153
+ when: "A view spoke to the shared store without having joined it, or after it left.",
154
+ fix: "Join (open the project) before reading or writing; reload a view that was disconnected.",
155
+ docs: `${o}/api/project#store-errors`
156
+ }
157
+ },
158
+ STORE_VALUE_NOT_JSON: {
159
+ code: "D1015",
160
+ message: "A value handed to the store is not JSON",
161
+ explanation: {
162
+ when: "A write handed the store a value that is not plain JSON (a function, a Map, undefined, a class instance) in a record or in document metadata.",
163
+ fix: "Pass plain strings, numbers, booleans, arrays and objects; `detail` names the value and the field.",
164
+ docs: `${o}/io/#values-a-store-keeps`
165
+ }
166
+ },
167
+ STORE_UNAVAILABLE: {
168
+ code: "D1016",
169
+ message: "This browser gives the page no storage for a project",
170
+ explanation: {
171
+ when: "The browser gives the page no private file system (a private window), or a worker no synchronous file access, so the SQLite project store cannot create, open or destroy the project; nothing is changed.",
172
+ fix: "Open the app in a normal (not private) window of a browser that supports the origin private file system.",
173
+ docs: `${o}/api/project#store-errors`
174
+ }
175
+ },
176
+ STORE_QUOTA_EXCEEDED: {
177
+ code: "D1017",
178
+ message: "Not enough storage left for the project",
179
+ explanation: {
180
+ when: "The origin has too little storage left: for a new project's files, for an import (eight times the file's size and at least 1 MiB, less the project's free pages), or the file system refused a write for want of space; nothing of the call applied. The SQLite project store answers it; the local (IndexedDB) store answers the failing write's own error (`STORE_COMMIT_FAILED`, `STORE_BULK_ADD_FAILED`, `STORE_BULK_UPDATE_FAILED`; an import `IMPORT_FAILED`) until it moves to SQLite; the in-memory store has no limit.",
181
+ fix: "Free storage for the origin (delete projects no longer needed) or import a smaller file, then try again; `meta.needed` and `meta.available` give the sizes when known.",
182
+ docs: `${o}/api/project#store-errors`
183
+ }
184
+ },
185
+ STORE_ENGINE_LOST: {
186
+ code: "D1018",
187
+ message: "The project engine stopped answering",
188
+ explanation: {
189
+ when: "A call to a project engine served from a worker lost that engine: it ended with what hosted it or gave no answer within its budget (`meta.reason` `'host-gone'`), it sent nothing for too long while the call waited (`'no-heartbeat'`, it may still finish), or the hub dropped this view with the page that bound it - frozen, gone, or unbinding it (`'realm-dropped'`: every call, `getWriteOutcome` too, is refused so until the view is bound again).",
190
+ fix: "A Document's commit and a Project's import ask the outcome themselves, once: a commit that landed resolves; otherwise the refusal says `meta.outcome` - `not-applied` (make it again if wanted), `running` (a silent engine may still apply it: tell the user, read again later), `unknown` (it could not be asked), or `applied` for an import (its document is in the project; its diagnostics were lost). Elsewhere ask `getWriteOutcome({ writeId })` with `meta.writeId` before writing again; never retry a write blindly. For `'realm-dropped'`, every call is refused until the page binds the view again once it is back (`onRejoined`, then `createHubPort`, its port handed to the view's `adoptHubPort`).",
191
+ docs: `${o}/api/project#store-errors`
192
+ }
193
+ },
194
+ STORE_HUB_SPAWNERS_FIXED: {
195
+ code: "D1019",
196
+ message: "The page's hub connection runs another version of this dialecte's engine",
197
+ explanation: {
198
+ when: "`connectHub({ spawners })` named a dialecte whose engine the page's connection already runs at another version, or a project was opened (or destroyed by name) on `sqlite` from a factory of such a version (the project offers its engine to the hub as it opens): a page runs one version of each dialecte's engine (two would split a project's views between two engines). A later call adds the engines of dialectes the page does not run yet. `meta.spawners` names the dialectes (id and version) refused; nothing of the call was added, nothing opened.",
199
+ fix: "Ship one version of each dialecte in the app: register each dialecte's `factory.spawner` from the copy the app opens its projects with.",
200
+ docs: `${o}/api/project#store-errors`
201
+ }
53
202
  },
54
203
  ELEMENT_NOT_FOUND: {
55
204
  code: "D2001",
56
- message: "Element not found"
205
+ message: "Element not found",
206
+ explanation: {
207
+ when: "A ref names an element the document does not hold (deleted, never created, or from another document).",
208
+ fix: "Read the ref from a query in the same document (`getRecord`, `findDescendants`) instead of keeping an old one.",
209
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
210
+ }
57
211
  },
58
212
  ROOT_NOT_FOUND: {
59
213
  code: "D2002",
60
- message: "Root element not found"
214
+ message: "Root element not found",
215
+ explanation: {
216
+ when: "The document holds no root element of the dialecte's root tag (an empty or foreign document).",
217
+ fix: "Import a file whose root is the dialecte's root element, or create the document with `project.initEmptyDocument`.",
218
+ docs: `${o}/api/project#initemptydocument`
219
+ }
61
220
  },
62
221
  DUPLICATE_ID: {
63
222
  code: "D2003",
64
- message: "Duplicate element ID"
223
+ message: "Duplicate element ID",
224
+ explanation: {
225
+ when: "Not raised by core itself: a dialecte or app code raises it when two elements carry the same id.",
226
+ fix: "Give each element its own id; let core mint them.",
227
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
228
+ }
65
229
  },
66
230
  ELEMENT_TAGNAME_MISMATCH: {
67
231
  code: "D2004",
68
- message: "Element tagName does not match the expected type"
232
+ message: "Element tagName does not match the expected type",
233
+ explanation: {
234
+ when: "A ref's `tagName` is not the tag of the record its id names.",
235
+ fix: "Build refs with `toRef(record)` from a record you read, never by hand with a guessed tag.",
236
+ docs: `${o}/api/transaction#reforrecord`
237
+ }
69
238
  },
70
239
  INVALID_PARENT_CHILD: {
71
240
  code: "D3001",
72
- message: "Invalid parent-child relationship"
241
+ message: "Invalid parent-child relationship",
242
+ explanation: {
243
+ when: "Not raised by core itself: a dialecte or app code raises it when an element is placed under a parent the schema does not admit.",
244
+ fix: "Read the parent's children in the definition (`query.getDefinition`) and add the element under an admitted parent.",
245
+ docs: `${o}/api/transaction#addchild`
246
+ }
73
247
  },
74
248
  INVALID_ATTRIBUTE: {
75
249
  code: "D3002",
76
- message: "Invalid attribute for element"
250
+ message: "Invalid attribute for element",
251
+ explanation: {
252
+ when: "Not raised by core itself: a dialecte or app code raises it for an attribute the element does not declare.",
253
+ fix: "Use an attribute the element's definition lists.",
254
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
255
+ }
77
256
  },
78
257
  PROTECTED_ROOT: {
79
258
  code: "D3003",
80
- message: "Root element cannot be deleted"
259
+ message: "Root element cannot be deleted",
260
+ explanation: {
261
+ when: "A transaction tried to delete the document's root element.",
262
+ fix: "Delete the root's children instead, or remove the whole document with `project.removeDocument`.",
263
+ docs: `${o}/api/transaction#delete`
264
+ }
81
265
  },
82
266
  REQUIRED_ATTRIBUTE_MISSING: {
83
267
  code: "D3004",
84
- message: "Required attribute is missing"
268
+ message: "Required attribute is missing",
269
+ explanation: {
270
+ when: "Not raised by core itself: a dialecte or app code raises it when a required attribute is absent.",
271
+ fix: "Give the attribute a value when creating the element.",
272
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
273
+ }
85
274
  },
86
275
  UNIQUE_CONSTRAINT_VIOLATION: {
87
276
  code: "D3005",
88
- message: "Value is already used within its scope"
277
+ message: "Value is already used within its scope",
278
+ explanation: {
279
+ when: "Not raised by core itself: a dialecte raises it when a value is already used within the scope where it must be unique.",
280
+ fix: "Pick another value, or let the dialecte's hook name the element.",
281
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
282
+ }
89
283
  },
90
284
  UNKNOWN_NAMESPACE_PREFIX: {
91
285
  code: "D3006",
92
- message: "Unknown namespace prefix on attribute — pass it explicitly as { name, namespace: { prefix, uri } }"
286
+ message: "Unknown namespace prefix on attribute — pass it explicitly as { name, namespace: { prefix, uri } }",
287
+ explanation: {
288
+ when: "An attribute was written with a namespace key or prefix the dialecte does not declare.",
289
+ fix: "Use a namespace key of the dialecte's config, or pass the namespace in full: `{ name, namespace: { prefix, uri } }`.",
290
+ docs: `${o}/api/transaction#addchild`
291
+ }
93
292
  },
94
293
  PREFIXED_ATTRIBUTE_NAME: {
95
294
  code: "D3007",
96
- message: "Authored attribute name must be a local name — pass the namespace separately as { name, namespace }, not a prefixed name"
295
+ message: "Authored attribute name must be a local name — pass the namespace separately as { name, namespace }, not a prefixed name",
296
+ explanation: {
297
+ when: "An attribute was written with a prefixed name (`ext:attr`) on create or update.",
298
+ fix: "Pass the local name and the namespace apart: `{ name: 'attr', namespace }`.",
299
+ docs: `${o}/api/transaction#addchild`
300
+ }
97
301
  },
98
302
  FIXED_VALUE_VIOLATION: {
99
303
  code: "D3008",
100
- message: "Attribute value differs from the schema-fixed value"
304
+ message: "Attribute value differs from the schema-fixed value",
305
+ explanation: {
306
+ when: "A write gave an attribute another value than the one the schema fixes.",
307
+ fix: "Leave the attribute out (core writes the fixed value) or give exactly the fixed value; `getAttributeRules` reads it.",
308
+ docs: `${o}/api/transaction#addchild`
309
+ }
101
310
  },
102
311
  XSI_TYPE_REQUIRED: {
103
312
  code: "D3009",
104
- message: "The element is declared with an abstract type: name a type with xsi:type"
313
+ message: "The element is declared with an abstract type: name a type with xsi:type",
314
+ explanation: {
315
+ when: "An element declared with an abstract type was created without naming a concrete type in `xsi:type`.",
316
+ fix: "Name one of the admitted types: `attributes: { 'xsi:type': '<Type>' }`; `admittedXsiTypes` lists them.",
317
+ docs: `${o}/api/transaction#addchild`
318
+ }
105
319
  },
106
320
  XSI_TYPE_NOT_ADMITTED: {
107
321
  code: "D3010",
108
- message: "The element may not take the type named with xsi:type"
322
+ message: "The element may not take the type named with xsi:type",
323
+ explanation: {
324
+ when: "A write named in `xsi:type` a type the element may not take.",
325
+ fix: "Pick a type from `admittedXsiTypes` for that element.",
326
+ docs: `${o}/api/transaction#addchild`
327
+ }
109
328
  },
110
329
  XSI_TYPE_CHANGE_LEAVES_CONTENT: {
111
330
  code: "D3011",
112
- message: "The new xsi:type does not admit content the element still holds"
331
+ message: "The new xsi:type does not admit content the element still holds",
332
+ explanation: {
333
+ when: "An update changed `xsi:type` to a type that does not admit attributes or children the element still holds.",
334
+ fix: "Remove that content in the same transaction before changing the type, or pick a type that admits it.",
335
+ docs: `${o}/api/transaction#update`
336
+ }
337
+ },
338
+ XML_CHARACTER_NOT_ALLOWED: {
339
+ code: "D3012",
340
+ message: "The text holds a character XML does not allow",
341
+ explanation: {
342
+ when: "A write, an import session's own writes or an export met a character XML does not allow (a control character below U+0020 but tab, line feed and carriage return, U+FFFE, U+FFFF) in a value, a name, a prefix, a namespace URI or an id; nothing was written, no file.",
343
+ fix: "Remove or replace the character named in `meta.character` at `meta.part` of the record `meta.recordId` before writing or exporting it.",
344
+ docs: `${o}/io/#values-a-store-keeps`
345
+ }
113
346
  },
114
347
  ALREADY_COMMITTED: {
115
348
  code: "D4001",
116
- message: "Transaction already committed"
349
+ message: "Transaction already committed",
350
+ explanation: {
351
+ when: "Not raised by core today: kept for a transaction used after its commit.",
352
+ fix: "Start a new `doc.transaction` for further writes.",
353
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
354
+ }
117
355
  },
118
356
  ALREADY_FAILED: {
119
357
  code: "D4002",
120
- message: "Transaction already failed"
358
+ message: "Transaction already failed",
359
+ explanation: {
360
+ when: "Not raised by core today: kept for a transaction used after it failed.",
361
+ fix: "Start a new `doc.transaction`; the failed one wrote nothing.",
362
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
363
+ }
121
364
  },
122
365
  DATABASE_COMMIT_ERROR: {
123
366
  code: "D4003",
124
- message: "An error occurred while committing changes to the database"
367
+ message: "An error occurred while committing changes to the database",
368
+ explanation: {
369
+ when: "Not raised by core today: store commit failures are `STORE_COMMIT_FAILED`.",
370
+ fix: "Read `cause`; see `STORE_COMMIT_FAILED`.",
371
+ docs: `${o}/guide/development/state-and-errors#error-catalog`
372
+ }
125
373
  },
126
374
  CONCURRENT_TRANSACTION: {
127
375
  code: "D4004",
128
- message: "A transaction is already in progress. Concurrent transactions are not supported yet — serialize them or implement a transaction queue."
376
+ message: "A transaction is already in progress. Concurrent transactions are not supported yet — serialize them or implement a transaction queue.",
377
+ explanation: {
378
+ when: "A `doc.transaction` started on a Document while another transaction or `doc.prepare` was still running on it (a missing `await`, or a nested transaction).",
379
+ fix: "Await each transaction before the next; inside a transaction, write through its `tx`, never through `doc.transaction` again.",
380
+ docs: `${o}/api/document`
381
+ }
129
382
  },
130
383
  EXPORT_ROOT_NOT_FOUND: {
131
384
  code: "D5001",
132
- message: "Root element not found in records during export"
385
+ message: "Root element not found in records during export",
386
+ explanation: {
387
+ when: "The export found no root record in the document.",
388
+ fix: "The document is empty or damaged: import it again, or create it with `project.initEmptyDocument`.",
389
+ docs: `${o}/api/project#export`
390
+ }
133
391
  },
134
392
  EXPORT_ORPHAN_CHILD_REF: {
135
393
  code: "D5002",
136
- message: "Parent references non-existent child record"
394
+ message: "Parent references non-existent child record",
395
+ explanation: {
396
+ when: "The export met a parent whose list of children names a record that does not exist.",
397
+ fix: "A hook or a raw write left a dangling child ref: a hook that deletes must also return the parent's `updated` operation.",
398
+ docs: `${o}/api/project#export`
399
+ }
137
400
  },
138
401
  PARSE_ERROR: {
139
402
  code: "D5003",
140
- message: "Failed to parse XML"
403
+ message: "Failed to parse XML",
404
+ explanation: {
405
+ when: "The file given to import (or to `parseXmlDocument`) is not well-formed XML.",
406
+ fix: "Fix the XML where `detail` points (line and column); check the file's encoding.",
407
+ docs: `${o}/api/project#import`
408
+ }
409
+ },
410
+ IMPORT_FAILED: {
411
+ code: "D5004",
412
+ message: "Failed to import the file",
413
+ explanation: {
414
+ when: "Importing a file failed after it was parsed (a hook threw, the store refused the records); nothing of the file remains.",
415
+ fix: "Read `cause` and `detail`; an import hook must not read the store or throw on data it can report as a diagnostic.",
416
+ docs: `${o}/api/project#import`
417
+ }
418
+ },
419
+ IMPORT_ABORTED: {
420
+ code: "D5005",
421
+ message: "The import was aborted",
422
+ explanation: {
423
+ when: "The import's `signal` was aborted; nothing of the file remains.",
424
+ fix: "Nothing to fix when the abort was wanted; import the file again otherwise.",
425
+ docs: `${o}/api/project#import`
426
+ }
427
+ },
428
+ EXPORT_CONFLICT: {
429
+ code: "D5006",
430
+ message: "The document changed while it was exported",
431
+ explanation: {
432
+ when: "The document was written twice while it was being exported, so no consistent file could be read.",
433
+ fix: "Export when no transaction or import is writing the document, or retry.",
434
+ docs: `${o}/api/project#export`
435
+ }
436
+ },
437
+ EXPORT_ABORTED: {
438
+ code: "D5007",
439
+ message: "The export was aborted",
440
+ explanation: {
441
+ when: "The export's `signal` was aborted.",
442
+ fix: "Nothing to fix when the abort was wanted; export again otherwise.",
443
+ docs: `${o}/api/project#export`
444
+ }
141
445
  },
142
446
  EXTENSION_METHOD_COLLISION: {
143
447
  code: "D6001",
144
- message: "Extension method name collision detected"
448
+ message: "Extension method name collision detected",
449
+ explanation: {
450
+ when: "Two extension modules merged under one key define a method of the same name.",
451
+ fix: "Rename your method, or put your module under a key of its own.",
452
+ docs: `${o}/guide/extensions/#registering-extensions`
453
+ }
145
454
  },
146
455
  UNKNOWN_CONFIG_KEY: {
147
456
  code: "D7001",
148
- message: "Unknown config key"
457
+ message: "Unknown config key",
458
+ explanation: {
459
+ when: "A document, a test or a declaration named a config key the dialecte does not declare.",
460
+ fix: "Use a key of the dialecte's `configs` (its `defaultConfigKey` when in doubt).",
461
+ docs: `${o}/api/dialecte#definedialecte`
462
+ }
149
463
  },
150
464
  DOCUMENT_NOT_REGISTERED: {
151
465
  code: "D7002",
152
- message: "Document not registered in project"
466
+ message: "Document not registered in project",
467
+ explanation: {
468
+ when: "A document id names no document of the open project (removed, or from another project).",
469
+ fix: "Use an id from `project.getDocuments()` or from the import result.",
470
+ docs: `${o}/api/project#document-access`
471
+ }
153
472
  },
154
473
  PROJECT_NOT_OPENED: {
155
474
  code: "D7003",
156
- message: "Project not opened"
475
+ message: "Project not opened",
476
+ explanation: {
477
+ when: "The project was used before `open(name)` resolved, or once `close()`, `destroy()` or another `open()` was called on it - a batch import's file whose turn came after that is refused the same.",
478
+ fix: "Keep the instance and await its `open(name)` before using the project; open it again after `close()` or `destroy()`, and await an `open()` of another project before using the Project again.",
479
+ docs: `${o}/api/project#lifecycle`
480
+ }
157
481
  },
158
482
  BLOB_NOT_FOUND: {
159
483
  code: "D7004",
160
- message: "Blob not found in store"
484
+ message: "Blob not found in store",
485
+ explanation: {
486
+ when: "`project.exportBlob` named a blob the project does not hold.",
487
+ fix: "Use an id from `project.getBlobsByDocument` or `getStandaloneBlobs`.",
488
+ docs: `${o}/api/project#blobs`
489
+ }
490
+ },
491
+ PROJECT_LAYOUT_OUTDATED: {
492
+ code: "D7005",
493
+ message: "Project stored by another version of the library",
494
+ explanation: {
495
+ when: "The project file was stored by another version of the library (another layout); nothing was written to it.",
496
+ fix: "Delete the project and import its files again with this version.",
497
+ docs: `${o}/api/project#store-errors`
498
+ }
499
+ },
500
+ PROJECT_ENGINE_UNAVAILABLE: {
501
+ code: "D7006",
502
+ message: "No view can start the project engine",
503
+ explanation: {
504
+ when: "The project's engine could not be started or reached: its worker failed to load or never answered its open within the open budget; through the origin's hub, no open view offers an engine for the project's dialecte, or the engine never said it opened; a destroy still running past the open budget, or one asked by a page suspended before the hub granted it.",
505
+ fix: "Keep one tab of the app open and reload; check the dialecte's `engineUrl` points at its worker and that it loads (the console names a script that fails); a destroy refused so is asked again once the project is closed elsewhere.",
506
+ docs: `${o}/api/project#store-errors`
507
+ }
508
+ },
509
+ PROJECT_ENGINE_BUSY: {
510
+ code: "D7007",
511
+ message: "The project is still held by another engine",
512
+ explanation: {
513
+ when: "Another engine still holds the project (another tab or a worker that did not stop).",
514
+ fix: "Close the other tabs of the app, then open the project again.",
515
+ docs: `${o}/api/project#store-errors`
516
+ }
517
+ },
518
+ PROJECT_DIALECTE_MISMATCH: {
519
+ code: "D7008",
520
+ message: "The project's engine or file is of another dialecte",
521
+ explanation: {
522
+ when: "A project file stored by another dialecte was opened (nothing of it written); or an engine was asked for a project of another dialecte than its own - the dialecte's `engineUrl` (its project factory's, or a hub spawner's) pointing at another dialecte's worker. Two dialectes' projects of one name are two projects: opening one never meets the other. `meta`: `project`, `projectDialecteId` (the engine's or the file's), `realmDialecteId` (the one asked).",
523
+ fix: "Open the project with the dialecte it was created with; point the dialecte's `engineUrl` at its own worker.",
524
+ docs: `${o}/api/project#store-errors`
525
+ }
526
+ },
527
+ PROJECT_DIALECTE_VERSION_MISMATCH: {
528
+ code: "D7009",
529
+ message: "The project engine runs another version of the dialecte",
530
+ explanation: {
531
+ when: "The project's engine runs another version of the dialecte than this view.",
532
+ fix: "Reload every tab of the app so they run the same version.",
533
+ docs: `${o}/api/project#store-errors`
534
+ }
535
+ },
536
+ PROJECT_DESTROY_FAILED: {
537
+ code: "D7010",
538
+ message: "The project could not be deleted",
539
+ explanation: {
540
+ when: "Destroying a project left its files in place: another tab or worker still holds one.",
541
+ fix: "Close the other tabs or windows of the app that have the project open, then destroy it again.",
542
+ docs: `${o}/api/project#lifecycle`
543
+ }
544
+ },
545
+ PROJECT_OPEN_ELSEWHERE: {
546
+ code: "D7011",
547
+ message: "The project is open in another tab, window or connection",
548
+ explanation: {
549
+ when: "Another tab or window has the project open and there is no shared connection between them; or a destroy was asked while another connection - a store or project of the name in this page, or another tab - has the project open (`meta.connections`, where the store counts them).",
550
+ fix: "Close the project in the other tab, window or connection, then open or destroy it here again.",
551
+ docs: `${o}/api/project#lifecycle`
552
+ }
553
+ },
554
+ PROJECT_DATABASE_LOST: {
555
+ code: "D7012",
556
+ message: "The project's database is gone",
557
+ explanation: {
558
+ when: "The project's files hold data but none of them is its database any more: the database file's header was damaged (by the disk, another program, or site data changed outside the app). Nothing is opened or changed: no empty database is made in its place. `meta.project` names the project.",
559
+ fix: "The project's data cannot be read back. Offer the user a reset, never automatically: `destroy()` on the same Project instance whose `open` was refused (keep it: `const project = new Project(params)`, then `await project.open(name)`) removes what the refused store holds, without opening it; `open(name)` then makes it again, empty, and its documents can be imported again.",
560
+ docs: `${o}/api/project#lifecycle`
561
+ }
562
+ },
563
+ PROJECT_DESTROYED_WHILE_AWAY: {
564
+ code: "D7013",
565
+ message: "The project was deleted while this view was away",
566
+ explanation: {
567
+ when: "A view's connection to a project came back - the page back from a freeze or the back/forward cache, its engine started again - and the project it had open was destroyed meanwhile by another tab (and maybe made again under its name): nothing is opened in its place and nothing of it is read. `meta.project` names the project.",
568
+ fix: "Tell the user the project was deleted elsewhere; close it in this view (`project.close()`), then open it again by its name for what is there now, or choose another.",
569
+ docs: `${o}/api/project#lifecycle`
570
+ }
571
+ },
572
+ PROJECT_NAME_INVALID: {
573
+ code: "D7014",
574
+ message: "The project's name cannot name its files",
575
+ explanation: {
576
+ when: "A project's name or its dialecte's id is empty, `.` or `..`: every store refuses it before it is built (a SQLite project's files sit in a directory named after both, which no directory can be); nothing was opened or written. `meta.project` and `meta.dialecteId` say which.",
577
+ fix: "Give the project a name of its own (and the dialecte an id) other than an empty one, `.` or `..`.",
578
+ docs: `${o}/api/project#lifecycle`
579
+ }
580
+ },
581
+ PROJECT_ENGINE_NOT_DECLARED: {
582
+ code: "D7015",
583
+ message: "This project has no engine to open it on SQLite",
584
+ explanation: {
585
+ when: "A project was opened on `storage: { type: 'sqlite' }` but made by no dialecte's project factory: its engine (the dialecte's id, its version and its engine worker's URL) is known to no one, so nothing can start it. Nothing was opened.",
586
+ fix: "Make the project with the dialecte's project factory (`createProjectFactory({ dialecte, engineUrl })`, as a dialecte package exports it), or open it on another storage.",
587
+ docs: `${o}/api/project#sqlite-storage`
588
+ }
589
+ },
590
+ PROJECT_SQLITE_NOT_IMPORTED: {
591
+ code: "D7016",
592
+ message: "SQLite storage needs `import '@dialecte/core/sqlite'`",
593
+ explanation: {
594
+ when: "A project was opened (or destroyed by name) on `storage: { type: 'sqlite' }`, or a test asked for the `sqlite` test store, but the app never imported `@dialecte/core/sqlite`: the SQLite storage kind lives behind that entry, so an app that never imports it neither emits nor downloads the SQLite engine, its wasm or the hub. Nothing was opened.",
595
+ fix: "Add `import '@dialecte/core/sqlite'` once to the app's entry (for tests, to the test runner's setup file), before the first project is opened on SQLite; or open the project on another storage. Imported already? The import registers the kind for every copy of @dialecte/core of the same SQLite storage version in the realm: a copy of another one (a dialecte bringing its own core) does not see it - align the core versions.",
596
+ docs: `${o}/api/project#sqlite-storage`
597
+ }
598
+ },
599
+ DOCUMENT_PATH_INVALID: {
600
+ code: "D7030",
601
+ message: "A document's path is not valid",
602
+ explanation: {
603
+ when: "A document's path breaks a rule (empty, `.` or `..` segment, backslash, invisible character, not NFC, too long), names another file than the document's, changes its extension, or was handed to `project.import` of several files; nothing was written. `detail` says which rule.",
604
+ fix: "Write the path relative, joined by `/`, in NFC, ending with the document's file name; pass a path to `importFile`, not to `import`.",
605
+ docs: `${o}/api/project#a-document-s-path`
606
+ }
607
+ },
608
+ DOCUMENT_PATH_TAKEN: {
609
+ code: "D7031",
610
+ message: "A document's path is another document's place",
611
+ explanation: {
612
+ when: "Another document already holds the place (`meta.takenBy`), a document still importing included: the same path, a path under another document's file, or a file at a folder another document's path uses.",
613
+ fix: "Choose a path no other document holds, or move the other document first.",
614
+ docs: `${o}/api/project#a-document-s-path`
615
+ }
161
616
  }
162
617
  };
163
- function s(e, t) {
164
- throw c(e, t);
165
- }
166
618
  function c(e, t) {
619
+ throw l(e, t);
620
+ }
621
+ function l(e, t) {
167
622
  let n = typeof e == "string" ? {
168
623
  key: e,
169
- ...o[e]
624
+ ...s[e]
170
625
  } : e, r = {
171
626
  code: n.code,
172
627
  key: n.key,
173
628
  message: t.message ?? n.message,
174
629
  detail: t.detail,
175
- method: u((/* @__PURE__ */ Error()).stack),
630
+ method: d((/* @__PURE__ */ Error()).stack),
176
631
  ref: t.ref,
177
632
  meta: t.meta,
178
633
  cause: t.cause
179
634
  }, i = Error(t.detail);
180
635
  return i.cause = r, i;
181
636
  }
182
- new Set(Object.values(o).map((e) => e.code));
183
- var l = new Set([
637
+ new Set(Object.values(s).map((e) => e.code));
638
+ var u = /* @__PURE__ */ new Set([
184
639
  "throwDialecteError",
185
640
  "createDialecteError",
186
641
  "invariant",
187
642
  "reportFailure"
188
643
  ]);
189
- function u(e) {
644
+ function d(e) {
190
645
  if (!e) return "unknown";
191
- let t = e.split("\n").slice(1).map((e) => e.match(/\bat\s+(?:async\s+)?(\S+)(?:\s+\[as\s+[^\]]+\])?\s+\(([^)]+)\)/)).find((e) => !d(e?.[1])), n = t?.[1]?.replace(/^Object\./, ""), r = t?.[2];
646
+ let t = e.split("\n").slice(1).map((e) => e.match(/\bat\s+(?:async\s+)?(\S+)(?:\s+\[as\s+[^\]]+\])?\s+\(([^)]+)\)/)).find((e) => !f(e?.[1])), n = t?.[1]?.replace(/^Object\./, ""), r = t?.[2];
192
647
  if (!r || !n) return n ?? "unknown";
193
648
  let i = r.match(/(\w[\w-]*\/src\/[^?:]+)/);
194
649
  return i ? `${i[1].replace(/\.[^/.]+$/, "")}::${n}` : n;
195
650
  }
196
- function d(e) {
197
- return e ? l.has(e.slice(e.lastIndexOf(".") + 1)) : !1;
651
+ function f(e) {
652
+ return e ? u.has(e.slice(e.lastIndexOf(".") + 1)) : !1;
198
653
  }
199
654
  `${{
200
655
  uri: "http://dialecte.dev/XML/DEV",
201
656
  prefix: "dev"
202
657
  }.prefix}`;
203
- var f = {
658
+ var p = {
204
659
  uri: "http://www.w3.org/2001/XMLSchema-instance",
205
660
  prefix: "xsi"
206
661
  };
207
- `${f.prefix}${f.uri}`;
208
- function p(e, t) {
662
+ `${p.prefix}${p.uri}`;
663
+ function m(e, t) {
209
664
  if (e) return;
210
665
  let { detail: n, key: r = "ASSERTION_FAILED", ref: i, meta: a } = t;
211
- s(r, {
666
+ c(r, {
212
667
  detail: n,
213
668
  ref: i,
214
669
  meta: a
@@ -216,27 +671,27 @@ function p(e, t) {
216
671
  }
217
672
  //#endregion
218
673
  //#region src/shell-context.ts
219
- var m = null;
220
- function h(e) {
221
- m = e;
222
- }
223
- function g() {
224
- m = null;
674
+ var h = null;
675
+ function g(e) {
676
+ h = e;
225
677
  }
226
678
  function _() {
227
- return p(m, { detail: "getProject: shell context not set. Call setShellContext(api) before app.mount()." }), m.project;
679
+ h = null;
228
680
  }
229
681
  function v() {
230
- return p(m, { detail: "getActiveDocumentId: shell context not set. Call setShellContext(api) before app.mount()." }), m.activeDocumentId;
682
+ return m(h, { detail: "getProject: shell context not set. Call setShellContext(api) before app.mount()." }), h.project;
231
683
  }
232
684
  function y() {
233
- return p(m, { detail: "getCommands: shell context not set. Call setShellContext(api) before app.mount()." }), m.commands;
685
+ return m(h, { detail: "getActiveDocumentId: shell context not set. Call setShellContext(api) before app.mount()." }), h.activeDocumentId;
234
686
  }
235
687
  function b() {
236
- return p(m, { detail: "getStorageSources: shell context not set. Call setShellContext(api) before app.mount()." }), p(m.storageSources, { detail: "getStorageSources: no storage sources provided by the shell." }), m.storageSources;
688
+ return m(h, { detail: "getCommands: shell context not set. Call setShellContext(api) before app.mount()." }), h.commands;
237
689
  }
238
690
  function x() {
239
- return p(m, { detail: "getPwa: shell context not set. Call setShellContext(api) before app.mount()." }), p(m.pwa, { detail: "getPwa: no PWA surface provided by the shell." }), m.pwa;
691
+ return m(h, { detail: "getStorageSources: shell context not set. Call setShellContext(api) before app.mount()." }), m(h.storageSources, { detail: "getStorageSources: no storage sources provided by the shell." }), h.storageSources;
692
+ }
693
+ function S() {
694
+ return m(h, { detail: "getPwa: shell context not set. Call setShellContext(api) before app.mount()." }), m(h.pwa, { detail: "getPwa: no PWA surface provided by the shell." }), h.pwa;
240
695
  }
241
696
  //#endregion
242
- export { t as LIBRARY_DB_PREFIX, i as RESERVED_DB_PREFIXES, e as SHELL_DB_PREFIX, n as TEMP_DOCUMENT_PREFIX, r as TEMP_PROJECT_PREFIX, g as clearShellContext, v as getActiveDocumentId, y as getCommands, _ as getProject, x as getPwa, b as getStorageSources, a as isReservedDatabaseName, h as setShellContext };
697
+ export { t as LIBRARY_DB_PREFIX, i as RESERVED_DB_PREFIXES, e as SHELL_DB_PREFIX, n as TEMP_DOCUMENT_PREFIX, r as TEMP_PROJECT_PREFIX, _ as clearShellContext, y as getActiveDocumentId, b as getCommands, v as getProject, S as getPwa, x as getStorageSources, a as isReservedDatabaseName, g as setShellContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@septkit/shell-lib",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -13,8 +13,8 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "@dialecte/core": "0.6.1",
17
- "@dialecte/scl": "0.8.0"
16
+ "@dialecte/core": "0.8.0",
17
+ "@dialecte/scl": "0.11.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "oxlint": "~1.6.0",