@withalleo/ewidget-utils 1.0.12 → 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 (2) hide show
  1. package/README.md +19 -39
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,17 +1,7 @@
1
1
  # @withalleo/ewidget-utils
2
2
 
3
- ## Install
4
-
5
- ```bash
6
- npm i @withalleo/ewidget-utils
7
- ```
8
-
9
- ## Demo (plain HTML)
10
-
11
3
  This package ships a browser bundle at `@withalleo/ewidget-utils/browser` (UMD). You can drop it into a plain HTML page and call `demo()`.
12
4
 
13
- > Note: The CDN URL below is an example. Prefer pinning an exact version.
14
-
15
5
  ```html
16
6
  <!doctype html>
17
7
  <html lang="en">
@@ -46,13 +36,13 @@ This package ships a browser bundle at `@withalleo/ewidget-utils/browser` (UMD).
46
36
  **Outgoing examples**
47
37
 
48
38
  ```js
49
- messenger.triggerAction('demo', {
39
+ alleo.triggerAction('demo', {
50
40
  'demo-param': 'Hello from iframe',
51
41
  })
52
42
  ```
53
43
 
54
44
  ```js
55
- messenger.addContent({
45
+ alleo.addContent({
56
46
  type: 'notepad',
57
47
  textFormat: 'markdown',
58
48
  text: '# Status\n\nAll systems go.',
@@ -60,11 +50,11 @@ messenger.addContent({
60
50
  ```
61
51
 
62
52
  ```js
63
- messenger.requestSyncedStatus()
53
+ alleo.requestSyncedStatus()
64
54
  ```
65
55
 
66
56
  ```js
67
- messenger.setSyncedStatus({
57
+ alleo.setSyncedStatus({
68
58
  color: '#FFAA33',
69
59
  })
70
60
  ```
@@ -83,13 +73,13 @@ messenger.setSyncedStatus({
83
73
  **Incoming examples (one per event)**
84
74
 
85
75
  ```js
86
- messenger.onSyncedStatusUpdate((status) => {
76
+ alleo.onSyncedStatusUpdate((status) => {
87
77
  console.log('synced status', status)
88
78
  })
89
79
  ```
90
80
 
91
81
  ```js
92
- messenger.onIncomingAction(({ actionId, data }) => {
82
+ alleo.onIncomingAction(({ actionId, data }) => {
93
83
  console.log('incoming action', actionId, data)
94
84
  })
95
85
  ```
@@ -249,20 +239,17 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
249
239
  > logEl.textContent = `${line}\n${logEl.textContent}`
250
240
  > }
251
241
  >
252
- > const messenger = new AlleoEWidget.EmbedWidgetMessenger({
253
- > targetOrigin: '*',
254
- > debug: true,
255
- > })
242
+ > const alleo = new AlleoEWidget.getEmbedWidgetMessenger()
256
243
  >
257
- > messenger.onSyncedStatusUpdate((status) => {
244
+ > alleo.onSyncedStatusUpdate((status) => {
258
245
  > log('syncedStatusUpdate:', status)
259
246
  > })
260
247
  >
261
- > messenger.onIncomingAction(({ actionId, data }) => {
248
+ > alleo.onIncomingAction(({ actionId, data }) => {
262
249
  > log(`incomingAction: ${actionId}`, data)
263
250
  > })
264
251
  >
265
- > document.getElementById('trigger').addEventListener('click', () => {
252
+ > alleo.getElementById('trigger').addEventListener('click', () => {
266
253
  > messenger.triggerAction('demo', {
267
254
  > 'demo-param': 'Hello from iframe',
268
255
  > })
@@ -270,7 +257,7 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
270
257
  > })
271
258
  >
272
259
  > document.getElementById('request').addEventListener('click', () => {
273
- > messenger.requestSyncedStatus()
260
+ > alleo.requestSyncedStatus()
274
261
  > log('requestSyncedStatus sent')
275
262
  > })
276
263
  > </script>
@@ -309,13 +296,9 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
309
296
  >
310
297
  > <script src="https://unpkg.com/@withalleo/ewidget-utils/dist/ewidget-utils.umd.cjs"></script>
311
298
  > <script>
312
- > const messenger = new AlleoEWidget.EmbedWidgetMessenger({
313
- > targetOrigin: '*',
314
- > debug: true,
315
- > })
316
- >
299
+ > const alleo = new AlleoEWidget.getEmbedWidgetMessenger()
317
300
  > document.getElementById('add-notepad').addEventListener('click', () => {
318
- > messenger.addContent({
301
+ > alleo.addContent({
319
302
  > type: 'notepad',
320
303
  > textFormat: 'markdown',
321
304
  > text: '# New note\n\nAdded from iframe.',
@@ -323,7 +306,7 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
323
306
  > })
324
307
  >
325
308
  > document.getElementById('add-sticky').addEventListener('click', () => {
326
- > messenger.addContent({
309
+ > alleo.addContent({
327
310
  > type: 'sticky-note',
328
311
  > text: 'Remember to review the draft',
329
312
  > color: '#FFE680',
@@ -333,7 +316,7 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
333
316
  > })
334
317
  >
335
318
  > document.getElementById('add-html').addEventListener('click', () => {
336
- > messenger.addContent({
319
+ > alleo.addContent({
337
320
  > type: 'html',
338
321
  > html: '<!doctype html><html><body><h2>Hello from iframe</h2></body></html>',
339
322
  > })
@@ -374,17 +357,14 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
374
357
  > <script>
375
358
  > const button = document.getElementById('color')
376
359
  >
377
- > const messenger = new AlleoEWidget.EmbedWidgetMessenger({
378
- > targetOrigin: '*',
379
- > debug: true,
380
- > })
360
+ > const alleo = new AlleoEWidget.getEmbedWidgetMessenger()
381
361
  >
382
362
  > const applyColor = (status) => {
383
363
  > if (!status || !status.color) return
384
364
  > button.style.backgroundColor = status.color
385
365
  > }
386
366
  >
387
- > messenger.onSyncedStatusUpdate((status) => {
367
+ > alleo.onSyncedStatusUpdate((status) => {
388
368
  > applyColor(status)
389
369
  > })
390
370
  >
@@ -392,10 +372,10 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
392
372
  > const color = `#${Math.floor(Math.random() * 0xffffff)
393
373
  > .toString(16)
394
374
  > .padStart(6, '0')}`
395
- > messenger.setSyncedStatus({ color })
375
+ > alleo.setSyncedStatus({ color })
396
376
  > })
397
377
  >
398
- > messenger.requestSyncedStatus()
378
+ > alleo.requestSyncedStatus()
399
379
  > </script>
400
380
  > </body>
401
381
  > </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withalleo/ewidget-utils",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Alleo e-widget utility library.",
5
5
  "repository": {
6
6
  "type": "git",