@iebh/tera-fy 1.0.11 → 1.0.12

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 (34) hide show
  1. package/api.md +323 -222
  2. package/dist/terafy.js +2 -2
  3. package/dist/terafy.js.map +4 -4
  4. package/lib/terafy.client.js +31 -8
  5. package/lib/terafy.server.js +28 -58
  6. package/package.json +1 -1
  7. package/.storybook/main.js +0 -22
  8. package/.storybook/preview.js +0 -17
  9. package/docs/assets/anchor.js +0 -350
  10. package/docs/assets/bass-addons.css +0 -12
  11. package/docs/assets/bass.css +0 -544
  12. package/docs/assets/fonts/EOT/SourceCodePro-Bold.eot +0 -0
  13. package/docs/assets/fonts/EOT/SourceCodePro-Regular.eot +0 -0
  14. package/docs/assets/fonts/LICENSE.txt +0 -93
  15. package/docs/assets/fonts/OTF/SourceCodePro-Bold.otf +0 -0
  16. package/docs/assets/fonts/OTF/SourceCodePro-Regular.otf +0 -0
  17. package/docs/assets/fonts/TTF/SourceCodePro-Bold.ttf +0 -0
  18. package/docs/assets/fonts/TTF/SourceCodePro-Regular.ttf +0 -0
  19. package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff +0 -0
  20. package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff +0 -0
  21. package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff +0 -0
  22. package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff +0 -0
  23. package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 +0 -0
  24. package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 +0 -0
  25. package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 +0 -0
  26. package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 +0 -0
  27. package/docs/assets/fonts/source-code-pro.css +0 -23
  28. package/docs/assets/github.css +0 -123
  29. package/docs/assets/site.js +0 -168
  30. package/docs/assets/split.css +0 -15
  31. package/docs/assets/split.js +0 -782
  32. package/docs/assets/style.css +0 -147
  33. package/docs/index.html +0 -3636
  34. package/docs/playground.html +0 -342
package/api.md CHANGED
@@ -5,68 +5,78 @@
5
5
  * [TeraFy][1]
6
6
  * [settings][2]
7
7
  * [Properties][3]
8
- * [dom][4]
9
- * [Properties][5]
10
- * [methods][6]
11
- * [plugins][7]
12
- * [send][8]
13
- * [Parameters][9]
14
- * [sendRaw][10]
15
- * [Parameters][11]
16
- * [rpc][12]
17
- * [Parameters][13]
18
- * [acceptMessage][14]
19
- * [Parameters][15]
20
- * [acceptPostboxes][16]
21
- * [createProjectStatePatch][17]
22
- * [Parameters][18]
23
- * [applyProjectStatePatchLocal][19]
24
- * [Parameters][20]
25
- * [init][21]
26
- * [Parameters][22]
27
- * [detectMode][23]
28
- * [injectComms][24]
29
- * [injectStylesheet][25]
30
- * [injectMethods][26]
31
- * [debug][27]
32
- * [Parameters][28]
33
- * [set][29]
34
- * [Parameters][30]
35
- * [use][31]
36
- * [Parameters][32]
37
- * [mixin][33]
38
- * [Parameters][34]
39
- * [toggleDevMode][35]
40
- * [Parameters][36]
41
- * [toggleFocus][37]
42
- * [Parameters][38]
43
- * [handshake][39]
44
- * [Properties][40]
45
- * [User][41]
46
- * [Properties][42]
47
- * [getUser][43]
48
- * [Project][44]
49
- * [getProject][45]
50
- * [getProjects][46]
51
- * [setActiveProject][47]
52
- * [Parameters][48]
53
- * [requireProject][49]
54
- * [Parameters][50]
55
- * [selectProject][51]
56
- * [Parameters][52]
57
- * [getProjectState][53]
58
- * [Parameters][54]
59
- * [applyProjectStatePatch][55]
60
- * [Parameters][56]
61
- * [subscribeProjectState][57]
62
- * [ProjectFile][58]
63
- * [Properties][59]
64
- * [getProjectFiles][60]
8
+ * [events][4]
9
+ * [dom][5]
10
+ * [Properties][6]
11
+ * [methods][7]
12
+ * [plugins][8]
13
+ * [send][9]
14
+ * [Parameters][10]
15
+ * [sendRaw][11]
16
+ * [Parameters][12]
17
+ * [rpc][13]
18
+ * [Parameters][14]
19
+ * [acceptMessage][15]
20
+ * [Parameters][16]
21
+ * [acceptPostboxes][17]
22
+ * [createProjectStatePatch][18]
23
+ * [Parameters][19]
24
+ * [applyProjectStatePatchLocal][20]
25
+ * [Parameters][21]
26
+ * [init][22]
27
+ * [Parameters][23]
28
+ * [detectMode][24]
29
+ * [injectComms][25]
30
+ * [injectStylesheet][26]
31
+ * [injectMethods][27]
32
+ * [debug][28]
33
+ * [Parameters][29]
34
+ * [set][30]
35
+ * [Parameters][31]
36
+ * [setIfDev][32]
37
+ * [Parameters][33]
38
+ * [use][34]
39
+ * [Parameters][35]
40
+ * [mixin][36]
41
+ * [Parameters][37]
42
+ * [toggleDevMode][38]
43
+ * [Parameters][39]
44
+ * [toggleFocus][40]
45
+ * [Parameters][41]
46
+ * [handshake][42]
47
+ * [Properties][43]
48
+ * [User][44]
49
+ * [Properties][45]
50
+ * [getUser][46]
51
+ * [Project][47]
52
+ * [getProject][48]
53
+ * [getProjects][49]
54
+ * [setActiveProject][50]
55
+ * [Parameters][51]
56
+ * [requireProject][52]
57
+ * [Parameters][53]
58
+ * [selectProject][54]
59
+ * [Parameters][55]
60
+ * [getProjectState][56]
61
+ * [Parameters][57]
62
+ * [setProjectState][58]
63
+ * [Parameters][59]
64
+ * [setProjectStateDefaults][60]
65
65
  * [Parameters][61]
66
- * [getProjectLibrary][62]
67
- * [Parameters][63]
68
- * [setProjectLibrary][64]
69
- * [Parameters][65]
66
+ * [saveProjectState][62]
67
+ * [replaceProjectState][63]
68
+ * [Parameters][64]
69
+ * [applyProjectStatePatch][65]
70
+ * [Parameters][66]
71
+ * [subscribeProjectState][67]
72
+ * [ProjectFile][68]
73
+ * [Properties][69]
74
+ * [getProjectFiles][70]
75
+ * [Parameters][71]
76
+ * [getProjectLibrary][72]
77
+ * [Parameters][73]
78
+ * [setProjectLibrary][74]
79
+ * [Parameters][75]
70
80
 
71
81
  ## TeraFy
72
82
 
@@ -76,21 +86,27 @@ Main Tera-Fy Client (class singleton) to be used in a frontend browser
76
86
 
77
87
  Various settings to configure behaviour
78
88
 
79
- Type: [Object][66]
89
+ Type: [Object][76]
80
90
 
81
91
  #### Properties
82
92
 
83
- * `devMode` **[Boolean][67]** Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance
93
+ * `devMode` **[Boolean][77]** Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance
84
94
  * `How` **(`"detect"` | `"parent"` | `"child"`)** to communicate with TERA. 'parent' assumes that the parent of the current document is TERA, 'child' spawns an iFrame and uses TERA there, 'detect' tries parent and fallsback to 'child'
85
- * `modeTimeout` **[Number][68]** How long entities have in 'detect' mode to identify themselves
86
- * `siteUrl` **[String][69]** The TERA URL to connect to
87
- * `restrictOrigin` **[String][69]** URL to restrict communications to
95
+ * `modeTimeout` **[Number][78]** How long entities have in 'detect' mode to identify themselves
96
+ * `siteUrl` **[String][79]** The TERA URL to connect to
97
+ * `restrictOrigin` **[String][79]** URL to restrict communications to
98
+
99
+ ### events
100
+
101
+ Event emitter subscription endpoint
102
+
103
+ Type: Mitt
88
104
 
89
105
  ### dom
90
106
 
91
107
  DOMElements for this TeraFy instance
92
108
 
93
- Type: [Object][66]
109
+ Type: [Object][76]
94
110
 
95
111
  #### Properties
96
112
 
@@ -103,13 +119,13 @@ Type: [Object][66]
103
119
  List of function stubs mapped here from the server
104
120
  This array is forms the reference of `TeraFy.METHOD()` objects to provide locally which will be mapped via `TeraFy.rpc(METHOD, ...args)`
105
121
 
106
- Type: [Array][70]<[String][69]>
122
+ Type: [Array][80]<[String][79]>
107
123
 
108
124
  ### plugins
109
125
 
110
126
  Loaded plugins via Use()
111
127
 
112
- Type: [Array][70]\<TeraFyPlugin>
128
+ Type: [Array][80]\<TeraFyPlugin>
113
129
 
114
130
  ### send
115
131
 
@@ -117,9 +133,9 @@ Send a message + wait for a response object
117
133
 
118
134
  #### Parameters
119
135
 
120
- * `message` **[Object][66]** Message object to send
136
+ * `message` **[Object][76]** Message object to send
121
137
 
122
- Returns **[Promise][71]\<any>** A promise which resolves when the operation has completed with the remote reply
138
+ Returns **[Promise][81]\<any>** A promise which resolves when the operation has completed with the remote reply
123
139
 
124
140
  ### sendRaw
125
141
 
@@ -128,7 +144,7 @@ This function does not return or wait for a reply - use `send()` for that
128
144
 
129
145
  #### Parameters
130
146
 
131
- * `message` **[Object][66]** Message object to send
147
+ * `message` **[Object][76]** Message object to send
132
148
 
133
149
  ### rpc
134
150
 
@@ -136,10 +152,10 @@ Call an RPC function in the server instance
136
152
 
137
153
  #### Parameters
138
154
 
139
- * `method` **[String][69]** The method name to call
155
+ * `method` **[String][79]** The method name to call
140
156
  * `args` **...any**&#x20;
141
157
 
142
- Returns **[Promise][71]\<any>** The resolved output of the server function
158
+ Returns **[Promise][81]\<any>** The resolved output of the server function
143
159
 
144
160
  ### acceptMessage
145
161
 
@@ -148,7 +164,7 @@ Accept an incoming message
148
164
  #### Parameters
149
165
 
150
166
  * `rawMessage` &#x20;
151
- * `Raw` **[MessageEvent][72]** message event to process
167
+ * `Raw` **[MessageEvent][82]** message event to process
152
168
 
153
169
  ### acceptPostboxes
154
170
 
@@ -157,27 +173,27 @@ Listening postboxes, these correspond to outgoing message IDs that expect a resp
157
173
  ### createProjectStatePatch
158
174
 
159
175
  Create + transmit a new project state patch base on the current and previous states
160
- The transmitted patch follows the [JSPatch][73] standard
176
+ The transmitted patch follows the [JSPatch][83] standard
161
177
  This function accepts an entire projectState instance, computes the delta and transmits that to the server for merging
162
178
 
163
179
  #### Parameters
164
180
 
165
- * `newState` **[Object][66]** The local projectState to accept
166
- * `oldState` **[Object][66]** The previous projectState to examine against
181
+ * `newState` **[Object][76]** The local projectState to accept
182
+ * `oldState` **[Object][76]** The previous projectState to examine against
167
183
 
168
- Returns **[Promise][71]** A promise which will resolve when the operation has completed
184
+ Returns **[Promise][81]** A promise which will resolve when the operation has completed
169
185
 
170
186
  ### applyProjectStatePatchLocal
171
187
 
172
188
  Client function which accepts a patch from the server and applies it to local project state
173
- The patch should follow the [JSPatch][73] standard
189
+ The patch should follow the [JSPatch][83] standard
174
190
  This function is expected to be sub-classed by a plugin
175
191
 
176
192
  #### Parameters
177
193
 
178
- * `patch` **[Array][70]** A JSPatch patch to apply
194
+ * `patch` **[Array][80]** A JSPatch patch to apply
179
195
 
180
- Returns **[Promise][71]** A promise which will resolve when the operation has completed
196
+ Returns **[Promise][81]** A promise which will resolve when the operation has completed
181
197
 
182
198
  ### init
183
199
 
@@ -186,22 +202,22 @@ This function can only be called once and will return the existing init() worker
186
202
 
187
203
  #### Parameters
188
204
 
189
- * `options` **[Object][66]?** Additional options to merge into `settings` via `set`
205
+ * `options` **[Object][76]?** Additional options to merge into `settings` via `set`
190
206
 
191
- Returns **[Promise][71]<[TeraFy][1]>** An eventual promise which will resovle with this terafy instance
207
+ Returns **[Promise][81]<[TeraFy][1]>** An eventual promise which will resovle with this terafy instance
192
208
 
193
209
  ### detectMode
194
210
 
195
211
  Populate `settings.mode`
196
212
  Try to communicate with a parent frame, if none assume we need to fallback to child mode
197
213
 
198
- Returns **[Promise][71]<[String][69]>** A promise which will resolve with the detected mode to use
214
+ Returns **[Promise][81]<[String][79]>** A promise which will resolve with the detected mode to use
199
215
 
200
216
  ### injectComms
201
217
 
202
218
  Find an existing active TERA server OR initalize one
203
219
 
204
- Returns **[Promise][71]** A promise which will resolve when the loading has completed and we have found a parent TERA instance or initiallized a child
220
+ Returns **[Promise][81]** A promise which will resolve when the loading has completed and we have found a parent TERA instance or initiallized a child
205
221
 
206
222
  ### injectStylesheet
207
223
 
@@ -228,7 +244,20 @@ This function also routes 'special' keys like `devMode` to their internal handle
228
244
 
229
245
  #### Parameters
230
246
 
231
- * `key` **([String][69] | [Object][66])** Either a single setting key to set or an object to merge
247
+ * `key` **([String][79] | [Object][76])** Either a single setting key to set or an object to merge
248
+ * `value` **any** The value to set if `key` is a string
249
+
250
+ Returns **[TeraFy][1]** This chainable terafy instance
251
+
252
+ ### setIfDev
253
+
254
+ * **See**: set()
255
+
256
+ Set or merge settings - but only in dev mode
257
+
258
+ #### Parameters
259
+
260
+ * `key` **([String][79] | [Object][76])** Either a single setting key to set or an object to merge
232
261
  * `value` **any** The value to set if `key` is a string
233
262
 
234
263
  Returns **[TeraFy][1]** This chainable terafy instance
@@ -240,8 +269,8 @@ Include a TeraFy client plugin
240
269
  #### Parameters
241
270
 
242
271
  * `mod` &#x20;
243
- * `options` **[Object][66]?** Additional options to mutate behaviour
244
- * `The` **[Object][66]** module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
272
+ * `options` **[Object][76]?** Additional options to mutate behaviour
273
+ * `The` **[Object][76]** module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
245
274
 
246
275
  Returns **[TeraFy][1]** This chainable terafy instance
247
276
 
@@ -251,8 +280,8 @@ Internal function used by use() to merge an external declared singleton against
251
280
 
252
281
  #### Parameters
253
282
 
254
- * `target` **[Object][66]** Initalied class instance to extend
255
- * `source` **[Object][66]** Initalized source object to extend from
283
+ * `target` **[Object][76]** Initalied class instance to extend
284
+ * `source` **[Object][76]** Initalized source object to extend from
256
285
 
257
286
  ### toggleDevMode
258
287
 
@@ -260,7 +289,7 @@ Set or toggle devMode
260
289
 
261
290
  #### Parameters
262
291
 
263
- * `devModeEnabled` **([String][69] | [Boolean][67])** Optional boolean to force dev mode (optional, default `'toggle'`)
292
+ * `devModeEnabled` **([String][79] | [Boolean][77])** Optional boolean to force dev mode (optional, default `'toggle'`)
264
293
 
265
294
  Returns **[TeraFy][1]** This chainable terafy instance
266
295
 
@@ -271,7 +300,7 @@ This is usually because the server component wants to perform some user activity
271
300
 
272
301
  #### Parameters
273
302
 
274
- * `isFocused` **([String][69] | [Boolean][67])** Whether to fullscreen the embedded component (optional, default `'toggle'`)
303
+ * `isFocused` **([String][79] | [Boolean][77])** Whether to fullscreen the embedded component (optional, default `'toggle'`)
275
304
 
276
305
  ## handshake
277
306
 
@@ -279,9 +308,9 @@ Return basic server information as a form of validation
279
308
 
280
309
  ### Properties
281
310
 
282
- * `date` **[Date][74]** Server date
311
+ * `date` **[Date][84]** Server date
283
312
 
284
- Returns **[Promise][71]<[Object][66]>** Basic promise result
313
+ Returns **[Promise][81]<[Object][76]>** Basic promise result
285
314
 
286
315
  ## User
287
316
 
@@ -289,16 +318,16 @@ User / active session within TERA
289
318
 
290
319
  ### Properties
291
320
 
292
- * `id` **[String][69]** Unique identifier of the user
293
- * `email` **[String][69]** The email address of the current user
294
- * `name` **[String][69]** The provided full name of the user
295
- * `isSubscribed` **[Boolean][67]** Whether the active user has a TERA subscription
321
+ * `id` **[String][79]** Unique identifier of the user
322
+ * `email` **[String][79]** The email address of the current user
323
+ * `name` **[String][79]** The provided full name of the user
324
+ * `isSubscribed` **[Boolean][77]** Whether the active user has a TERA subscription
296
325
 
297
326
  ## getUser
298
327
 
299
328
  Fetch the current session user
300
329
 
301
- Returns **[Promise][71]<[User][41]>** The current logged in user or null if none
330
+ Returns **[Promise][81]<[User][44]>** The current logged in user or null if none
302
331
 
303
332
  ## Project
304
333
 
@@ -308,13 +337,13 @@ Project entry within TERA
308
337
 
309
338
  Get the currently active project, if any
310
339
 
311
- Returns **[Promise][71]<([Project][44] | null)>** The currently active project, if any
340
+ Returns **[Promise][81]<([Project][47] | null)>** The currently active project, if any
312
341
 
313
342
  ## getProjects
314
343
 
315
344
  Get a list of projects the current session user has access to
316
345
 
317
- Returns **[Promise][71]<[Array][70]<[Project][44]>>** Collection of projects the user has access to
346
+ Returns **[Promise][81]<[Array][80]<[Project][47]>>** Collection of projects the user has access to
318
347
 
319
348
  ## setActiveProject
320
349
 
@@ -322,7 +351,7 @@ Set the currently active project within TERA
322
351
 
323
352
  ### Parameters
324
353
 
325
- * `project` **([Object][66] | [String][69])** The project to set as active - either the full Project object or its ID
354
+ * `project` **([Object][76] | [String][79])** The project to set as active - either the full Project object or its ID
326
355
 
327
356
  ## requireProject
328
357
 
@@ -331,14 +360,14 @@ Note that this function will percist in asking the uesr even if they try to canc
331
360
 
332
361
  ### Parameters
333
362
 
334
- * `options` **[Object][66]?** Additional options to mutate behaviour
363
+ * `options` **[Object][76]?** Additional options to mutate behaviour
335
364
 
336
- * `options.autoSetActiveProject` **[Boolean][67]** After selecting a project set that project as active in TERA (optional, default `true`)
337
- * `options.title` **[String][69]** The title of the dialog to display (optional, default `"Select a project to work with"`)
338
- * `options.noSelectTitle` **[String][69]** Dialog title when warning the user they need to select something (optional, default `'Select project'`)
339
- * `options.noSelectBody` **[String][69]** Dialog body when warning the user they need to select something (optional, default `'A project needs to be selected to continue'`)
365
+ * `options.autoSetActiveProject` **[Boolean][77]** After selecting a project set that project as active in TERA (optional, default `true`)
366
+ * `options.title` **[String][79]** The title of the dialog to display (optional, default `"Select a project to work with"`)
367
+ * `options.noSelectTitle` **[String][79]** Dialog title when warning the user they need to select something (optional, default `'Select project'`)
368
+ * `options.noSelectBody` **[String][79]** Dialog body when warning the user they need to select something (optional, default `'A project needs to be selected to continue'`)
340
369
 
341
- Returns **[Promise][71]<[Project][44]>** The active project
370
+ Returns **[Promise][81]<[Project][47]>** The active project
342
371
 
343
372
  ## selectProject
344
373
 
@@ -346,13 +375,13 @@ Prompt the user to select a project from those available
346
375
 
347
376
  ### Parameters
348
377
 
349
- * `options` **[Object][66]?** Additional options to mutate behaviour
378
+ * `options` **[Object][76]?** Additional options to mutate behaviour
350
379
 
351
- * `options.title` **[String][69]** The title of the dialog to display (optional, default `"Select a project to work with"`)
352
- * `options.allowCancel` **[Boolean][67]** Advertise cancelling the operation, the dialog can still be cancelled by closing it (optional, default `true`)
353
- * `options.setActive` **[Boolean][67]** Also set the project as active when selected (optional, default `false`)
380
+ * `options.title` **[String][79]** The title of the dialog to display (optional, default `"Select a project to work with"`)
381
+ * `options.allowCancel` **[Boolean][77]** Advertise cancelling the operation, the dialog can still be cancelled by closing it (optional, default `true`)
382
+ * `options.setActive` **[Boolean][77]** Also set the project as active when selected (optional, default `false`)
354
383
 
355
- Returns **[Promise][71]<[Project][44]>** The active project
384
+ Returns **[Promise][81]<[Project][47]>** The active project
356
385
 
357
386
  ## getProjectState
358
387
 
@@ -360,12 +389,64 @@ Return the current, full snapshot state of the active project
360
389
 
361
390
  ### Parameters
362
391
 
363
- * `options` **[Object][66]?** Additional options to mutate behaviour
392
+ * `options` **[Object][76]?** Additional options to mutate behaviour
364
393
 
365
- * `options.autoRequire` **[Boolean][67]** Run `requireProject()` automatically before continuing (optional, default `true`)
366
- * `Paths` **[Array][70]<[String][69]>** to subscribe to e.g. \['/users/'],
394
+ * `options.autoRequire` **[Boolean][77]** Run `requireProject()` automatically before continuing (optional, default `true`)
395
+ * `Paths` **[Array][80]<[String][79]>** to subscribe to e.g. \['/users/'],
367
396
 
368
- Returns **[Promise][71]<[Object][66]>** The current project state snapshot
397
+ Returns **[Promise][81]<[Object][76]>** The current project state snapshot
398
+
399
+ ## setProjectState
400
+
401
+ Set a nested value within the project state
402
+ Paths can be any valid Lodash.set() value such as:
403
+
404
+ - Dotted notation - e.g. `foo.bar.1.baz`
405
+ - Array path segments e.g. `['foo', 'bar', 1, 'baz']`
406
+
407
+ ### Parameters
408
+
409
+ * `path` **([String][79] | [Array][80]<[String][79]>)** The sub-path within the project state to set
410
+ * `value` **any** The value to set
411
+ * `options` **[Object][76]?** Additional options to mutate behaviour
412
+
413
+ * `options.save` **[Boolean][77]** Save the changes to the server immediately, disable to queue up multiple writes (optional, default `true`)
414
+ * `options.sync` **[Boolean][77]** Wait for the server to acknowledge the write, you almost never need to do this (optional, default `false`)
415
+
416
+ Returns **[Promise][81]** A promise which resolves when the operation has synced with the server
417
+
418
+ ## setProjectStateDefaults
419
+
420
+ * **See**: setProjectState()
421
+
422
+ Set a nested value within the project state - just like `setProjectState()` - but only if no value for that path exists
423
+
424
+ ### Parameters
425
+
426
+ * `path` **([String][79] | [Array][80]<[String][79]>)** The sub-path within the project state to set
427
+ * `value` **any** The value to set
428
+ * `options` **[Object][76]?** Additional options to mutate behaviour, see setProjectState() for the full list of supported options
429
+
430
+ Returns **[Promise][81]<[Boolean][77]>** A promise which resolves to whether any changes were made - True if defaults were applied, false otherwise
431
+
432
+ ## saveProjectState
433
+
434
+ Force-Save the currently active project state
435
+
436
+ Returns **[Promise][81]** A promise which resolves when the operation has completed
437
+
438
+ ## replaceProjectState
439
+
440
+ * **See**: setProjectState()
441
+
442
+ Overwrite the entire project state with a new object
443
+ You almost never want to use this function directly, see `setProjectState(path, value)` for a nicer wrapper
444
+
445
+ ### Parameters
446
+
447
+ * `newState` **[Object][76]** The new state to replace the current state with
448
+
449
+ Returns **[Promise][81]** A promise which resolves when the operation has completed
369
450
 
370
451
  ## applyProjectStatePatch
371
452
 
@@ -373,9 +454,9 @@ Apply a computed `just-diff` patch to the current project state
373
454
 
374
455
  ### Parameters
375
456
 
376
- * `Patch` **[Object][66]** to apply
457
+ * `Patch` **[Object][76]** to apply
377
458
 
378
- Returns **[Promise][71]** A promise which resolves when the operation has completed
459
+ Returns **[Promise][81]** A promise which resolves when the operation has completed
379
460
 
380
461
  ## subscribeProjectState
381
462
 
@@ -383,7 +464,7 @@ Subscribe to project state changes
383
464
  This will dispatch an RPC call to the source object `applyProjectStatePatchLocal()` function with the patch
384
465
  If the above call fails the subscriber is assumed as dead and unsubscribed from the polling list
385
466
 
386
- Returns **[Promise][71]<[Function][75]>** A promise which resolves when a subscription has been created, call the resulting function to unsubscribe
467
+ Returns **[Promise][81]<[Function][85]>** A promise which resolves when a subscription has been created, call the resulting function to unsubscribe
387
468
 
388
469
  ## ProjectFile
389
470
 
@@ -391,19 +472,19 @@ Data structure for a project file
391
472
 
392
473
  ### Properties
393
474
 
394
- * `id` **[String][69]** A UUID string representing the unique ID of the file
395
- * `name` **[String][69]** Relative name path (can contain prefix directories) for the human readable file name
396
- * `parsedName` **[Object][66]** An object representing meta file parts of a file name
475
+ * `id` **[String][79]** A UUID string representing the unique ID of the file
476
+ * `name` **[String][79]** Relative name path (can contain prefix directories) for the human readable file name
477
+ * `parsedName` **[Object][76]** An object representing meta file parts of a file name
397
478
 
398
- * `parsedName.basename` **[String][69]** The filename + extention (i.e. everything without directory name)
399
- * `parsedName.filename` **[String][69]** The file portion of the name (basename without the extension)
400
- * `parsedName.ext` **[String][69]** The extension portion of the name (always lower case)
401
- * `parsedName.dirName` **[String][69]** The directory path portion of the name
402
- * `created` **[Date][74]** A date representing when the file was created
403
- * `modified` **[Date][74]** A date representing when the file was created
404
- * `accessed` **[Date][74]** A date representing when the file was last accessed
405
- * `size` **[Number][68]** Size, in bytes, of the file
406
- * `mime` **[String][69]** The associated mime type for the file
479
+ * `parsedName.basename` **[String][79]** The filename + extention (i.e. everything without directory name)
480
+ * `parsedName.filename` **[String][79]** The file portion of the name (basename without the extension)
481
+ * `parsedName.ext` **[String][79]** The extension portion of the name (always lower case)
482
+ * `parsedName.dirName` **[String][79]** The directory path portion of the name
483
+ * `created` **[Date][84]** A date representing when the file was created
484
+ * `modified` **[Date][84]** A date representing when the file was created
485
+ * `accessed` **[Date][84]** A date representing when the file was last accessed
486
+ * `size` **[Number][78]** Size, in bytes, of the file
487
+ * `mime` **[String][79]** The associated mime type for the file
407
488
 
408
489
  ## getProjectFiles
409
490
 
@@ -411,12 +492,12 @@ Fetch the files associated with a given project
411
492
 
412
493
  ### Parameters
413
494
 
414
- * `options` **[Object][66]** Options which mutate behaviour
495
+ * `options` **[Object][76]** Options which mutate behaviour
415
496
 
416
- * `options.autoRequire` **[Boolean][67]** Run `requireProject()` automatically before continuing (optional, default `true`)
417
- * `options.meta` **[Boolean][67]** Pull meta information for each file entity (optional, default `true`)
497
+ * `options.autoRequire` **[Boolean][77]** Run `requireProject()` automatically before continuing (optional, default `true`)
498
+ * `options.meta` **[Boolean][77]** Pull meta information for each file entity (optional, default `true`)
418
499
 
419
- Returns **[Promise][71]<[ProjectFile][58]>** A collection of project files for the given project
500
+ Returns **[Promise][81]<[ProjectFile][68]>** A collection of project files for the given project
420
501
 
421
502
  ## getProjectLibrary
422
503
 
@@ -424,16 +505,16 @@ Fetch the active projects citation library
424
505
 
425
506
  ### Parameters
426
507
 
427
- * `path` **[String][69]?** Optional file path to use, if omitted the contents of `options` are used to guess at a suitable file
428
- * `options` **[Object][66]?** Additional options to mutate behaviour
508
+ * `path` **[String][79]?** Optional file path to use, if omitted the contents of `options` are used to guess at a suitable file
509
+ * `options` **[Object][76]?** Additional options to mutate behaviour
429
510
 
430
- * `options.autoRequire` **[Boolean][67]** Run `requireProject()` automatically before continuing (optional, default `true`)
431
- * `options.multiple` **[Boolean][67]** Allow selection of multiple libraries (optional, default `false`)
432
- * `options.filter` **[Function][75]?** Optional async file filter, called each time as `(File:ProjectFile)`
433
- * `options.find` **[Function][75]?** Optional async final stage file filter to reduce all candidates down to one subject file
434
- * `options.hint` **([String][69] | [Array][70]<[String][69]>)?** Hints to identify the library to select in array order of preference. Generally corresponds to the previous stage - e.g. 'deduped', 'review1', 'review2', 'dedisputed'
511
+ * `options.autoRequire` **[Boolean][77]** Run `requireProject()` automatically before continuing (optional, default `true`)
512
+ * `options.multiple` **[Boolean][77]** Allow selection of multiple libraries (optional, default `false`)
513
+ * `options.filter` **[Function][85]?** Optional async file filter, called each time as `(File:ProjectFile)`
514
+ * `options.find` **[Function][85]?** Optional async final stage file filter to reduce all candidates down to one subject file
515
+ * `options.hint` **([String][79] | [Array][80]<[String][79]>)?** Hints to identify the library to select in array order of preference. Generally corresponds to the previous stage - e.g. 'deduped', 'review1', 'review2', 'dedisputed'
435
516
 
436
- Returns **[Promise][71]<[Array][70]<[ProjectFile][58]>>** Collection of references for the selected library matching the given hint + filter, this could be a zero length array
517
+ Returns **[Promise][81]<[Array][80]<[ProjectFile][68]>>** Collection of references for the selected library matching the given hint + filter, this could be a zero length array
437
518
 
438
519
  ## setProjectLibrary
439
520
 
@@ -441,13 +522,13 @@ Save back a projects citation library
441
522
 
442
523
  ### Parameters
443
524
 
444
- * `Collection` **[Array][70]\<RefLibRef>** of references for the selected library
445
- * `options` **[Object][66]?** Additional options to mutate behaviour
525
+ * `Collection` **[Array][80]\<RefLibRef>** of references for the selected library
526
+ * `options` **[Object][76]?** Additional options to mutate behaviour
446
527
 
447
- * `options.autoRequire` **[Boolean][67]** Run `requireProject()` automatically before continuing (optional, default `true`)
448
- * `options.hint` **[String][69]?** Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
528
+ * `options.autoRequire` **[Boolean][77]** Run `requireProject()` automatically before continuing (optional, default `true`)
529
+ * `options.hint` **[String][79]?** Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
449
530
 
450
- Returns **[Promise][71]** A promise which resolves when the save operation has completed
531
+ Returns **[Promise][81]** A promise which resolves when the save operation has completed
451
532
 
452
533
  [1]: #terafy
453
534
 
@@ -455,146 +536,166 @@ Returns **[Promise][71]** A promise which resolves when the save operation has c
455
536
 
456
537
  [3]: #properties
457
538
 
458
- [4]: #dom
539
+ [4]: #events
540
+
541
+ [5]: #dom
542
+
543
+ [6]: #properties-1
544
+
545
+ [7]: #methods
546
+
547
+ [8]: #plugins
548
+
549
+ [9]: #send
550
+
551
+ [10]: #parameters
552
+
553
+ [11]: #sendraw
554
+
555
+ [12]: #parameters-1
556
+
557
+ [13]: #rpc
558
+
559
+ [14]: #parameters-2
459
560
 
460
- [5]: #properties-1
561
+ [15]: #acceptmessage
461
562
 
462
- [6]: #methods
563
+ [16]: #parameters-3
463
564
 
464
- [7]: #plugins
565
+ [17]: #acceptpostboxes
465
566
 
466
- [8]: #send
567
+ [18]: #createprojectstatepatch
467
568
 
468
- [9]: #parameters
569
+ [19]: #parameters-4
469
570
 
470
- [10]: #sendraw
571
+ [20]: #applyprojectstatepatchlocal
471
572
 
472
- [11]: #parameters-1
573
+ [21]: #parameters-5
473
574
 
474
- [12]: #rpc
575
+ [22]: #init
475
576
 
476
- [13]: #parameters-2
577
+ [23]: #parameters-6
477
578
 
478
- [14]: #acceptmessage
579
+ [24]: #detectmode
479
580
 
480
- [15]: #parameters-3
581
+ [25]: #injectcomms
481
582
 
482
- [16]: #acceptpostboxes
583
+ [26]: #injectstylesheet
483
584
 
484
- [17]: #createprojectstatepatch
585
+ [27]: #injectmethods
485
586
 
486
- [18]: #parameters-4
587
+ [28]: #debug
487
588
 
488
- [19]: #applyprojectstatepatchlocal
589
+ [29]: #parameters-7
489
590
 
490
- [20]: #parameters-5
591
+ [30]: #set
491
592
 
492
- [21]: #init
593
+ [31]: #parameters-8
493
594
 
494
- [22]: #parameters-6
595
+ [32]: #setifdev
495
596
 
496
- [23]: #detectmode
597
+ [33]: #parameters-9
497
598
 
498
- [24]: #injectcomms
599
+ [34]: #use
499
600
 
500
- [25]: #injectstylesheet
601
+ [35]: #parameters-10
501
602
 
502
- [26]: #injectmethods
603
+ [36]: #mixin
503
604
 
504
- [27]: #debug
605
+ [37]: #parameters-11
505
606
 
506
- [28]: #parameters-7
607
+ [38]: #toggledevmode
507
608
 
508
- [29]: #set
609
+ [39]: #parameters-12
509
610
 
510
- [30]: #parameters-8
611
+ [40]: #togglefocus
511
612
 
512
- [31]: #use
613
+ [41]: #parameters-13
513
614
 
514
- [32]: #parameters-9
615
+ [42]: #handshake
515
616
 
516
- [33]: #mixin
617
+ [43]: #properties-2
517
618
 
518
- [34]: #parameters-10
619
+ [44]: #user
519
620
 
520
- [35]: #toggledevmode
621
+ [45]: #properties-3
521
622
 
522
- [36]: #parameters-11
623
+ [46]: #getuser
523
624
 
524
- [37]: #togglefocus
625
+ [47]: #project
525
626
 
526
- [38]: #parameters-12
627
+ [48]: #getproject
527
628
 
528
- [39]: #handshake
629
+ [49]: #getprojects
529
630
 
530
- [40]: #properties-2
631
+ [50]: #setactiveproject
531
632
 
532
- [41]: #user
633
+ [51]: #parameters-14
533
634
 
534
- [42]: #properties-3
635
+ [52]: #requireproject
535
636
 
536
- [43]: #getuser
637
+ [53]: #parameters-15
537
638
 
538
- [44]: #project
639
+ [54]: #selectproject
539
640
 
540
- [45]: #getproject
641
+ [55]: #parameters-16
541
642
 
542
- [46]: #getprojects
643
+ [56]: #getprojectstate
543
644
 
544
- [47]: #setactiveproject
645
+ [57]: #parameters-17
545
646
 
546
- [48]: #parameters-13
647
+ [58]: #setprojectstate
547
648
 
548
- [49]: #requireproject
649
+ [59]: #parameters-18
549
650
 
550
- [50]: #parameters-14
651
+ [60]: #setprojectstatedefaults
551
652
 
552
- [51]: #selectproject
653
+ [61]: #parameters-19
553
654
 
554
- [52]: #parameters-15
655
+ [62]: #saveprojectstate
555
656
 
556
- [53]: #getprojectstate
657
+ [63]: #replaceprojectstate
557
658
 
558
- [54]: #parameters-16
659
+ [64]: #parameters-20
559
660
 
560
- [55]: #applyprojectstatepatch
661
+ [65]: #applyprojectstatepatch
561
662
 
562
- [56]: #parameters-17
663
+ [66]: #parameters-21
563
664
 
564
- [57]: #subscribeprojectstate
665
+ [67]: #subscribeprojectstate
565
666
 
566
- [58]: #projectfile
667
+ [68]: #projectfile
567
668
 
568
- [59]: #properties-4
669
+ [69]: #properties-4
569
670
 
570
- [60]: #getprojectfiles
671
+ [70]: #getprojectfiles
571
672
 
572
- [61]: #parameters-18
673
+ [71]: #parameters-22
573
674
 
574
- [62]: #getprojectlibrary
675
+ [72]: #getprojectlibrary
575
676
 
576
- [63]: #parameters-19
677
+ [73]: #parameters-23
577
678
 
578
- [64]: #setprojectlibrary
679
+ [74]: #setprojectlibrary
579
680
 
580
- [65]: #parameters-20
681
+ [75]: #parameters-24
581
682
 
582
- [66]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
683
+ [76]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
583
684
 
584
- [67]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
685
+ [77]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
585
686
 
586
- [68]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
687
+ [78]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
587
688
 
588
- [69]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
689
+ [79]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
589
690
 
590
- [70]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
691
+ [80]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
591
692
 
592
- [71]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
693
+ [81]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
593
694
 
594
- [72]: https://developer.mozilla.org/docs/Web/API/MessageEvent
695
+ [82]: https://developer.mozilla.org/docs/Web/API/MessageEvent
595
696
 
596
- [73]: http://jsonpatch.com
697
+ [83]: http://jsonpatch.com
597
698
 
598
- [74]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date
699
+ [84]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date
599
700
 
600
- [75]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
701
+ [85]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function