@iebh/tera-fy 1.0.11 → 1.0.13

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