@pageactions/page-actions-js 0.12.0 → 0.13.0
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.
- package/README.md +33 -1
- package/dist/service/PageActions.d.ts +40 -4
- package/dist/service/PageActions.d.ts.map +1 -1
- package/dist/service/PageActions.js +88 -14
- package/dist/service/PageActions.js.map +1 -1
- package/dist/type/Interaction.type.d.ts +2 -6
- package/dist/type/Interaction.type.d.ts.map +1 -1
- package/dist/type/Interaction.type.js.map +1 -1
- package/dist/type/visibility.type.d.ts +7 -0
- package/dist/type/visibility.type.d.ts.map +1 -0
- package/dist/type/visibility.type.js +3 -0
- package/dist/type/visibility.type.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -96,9 +96,29 @@ pageActions.firstAction("firstname_changed");
|
|
|
96
96
|
|
|
97
97
|
This action will be reported at most one time. Every further call with the same action type will be ignored during page visit (same PageActions instance).
|
|
98
98
|
|
|
99
|
+
### Page visit duration
|
|
100
|
+
|
|
101
|
+
Page Action can calculate the total time the user spent on a page. However, to calculate this time correctly, we need to know when a user switches browser tabs or closes the page.
|
|
102
|
+
|
|
103
|
+
You can register a default visibility change handler that uses [visibilitychange](https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event) event listener:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
pageActions.pageView();
|
|
107
|
+
pageActions.registerVisibilityListener();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The other method is to manually call functions when the page becomes hidden or visible. Remember that a `pageView()` function registers a `page visible` event by default.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
pageActions.pageVisible();
|
|
114
|
+
pageActions.pageHidden();
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The extra benefit of the default handler is that it automatically flushes all events when the page is closed.
|
|
118
|
+
|
|
99
119
|
### Flushing actions
|
|
100
120
|
|
|
101
|
-
By default, sending actions to the collector is delayed so analytics doesn't impact page performance. Sometimes you may need to send events immediately. For example, when
|
|
121
|
+
By default, sending actions to the collector is delayed so analytics doesn't impact page performance. Sometimes you may need to send events immediately. For example, when a user clicks on the button that performs navigation to a different page. In such a situation, a `flush()` method can be used to publish events before the current page is closed.
|
|
102
122
|
|
|
103
123
|
Example:
|
|
104
124
|
|
|
@@ -111,3 +131,15 @@ Another way to do this is by using a `flush` option when reporting an action.
|
|
|
111
131
|
```ts
|
|
112
132
|
pageActions.action("focus", { flush: true });
|
|
113
133
|
```
|
|
134
|
+
|
|
135
|
+
### End page view
|
|
136
|
+
|
|
137
|
+
In some cases, a page visit doesn't end with navigation to other documents or closing of the browser tab. For example, the single-page application (SPA) uses a router to navigate to the other view without reloading a page.
|
|
138
|
+
|
|
139
|
+
In such situations, you may need to signal that some view is no longer displayed and the page-duration timer should be stopped.
|
|
140
|
+
|
|
141
|
+
You can call the `endPageView()` function to do this. It also sends all existing actions to the collector if they haven't been published yet.
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
pageActions.endPageView();
|
|
145
|
+
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Interaction } from "../type/Interaction.type.js";
|
|
2
2
|
/** Object for optional action's options */
|
|
3
3
|
export interface ActionOptions {
|
|
4
4
|
/** Terminal action represents the last action on a page and no more actions are recorded */
|
|
@@ -15,7 +15,6 @@ export declare class PageActions {
|
|
|
15
15
|
interactions: Interaction[];
|
|
16
16
|
pageViewId: string | undefined;
|
|
17
17
|
private terminatedRecording;
|
|
18
|
-
browser?: Browser;
|
|
19
18
|
private _collectorUrl;
|
|
20
19
|
private _siteId;
|
|
21
20
|
private _verbose;
|
|
@@ -23,6 +22,8 @@ export declare class PageActions {
|
|
|
23
22
|
private _groupName;
|
|
24
23
|
private _pageUrl;
|
|
25
24
|
private _referrer;
|
|
25
|
+
private _visibilityChanges;
|
|
26
|
+
private _listenerAbort;
|
|
26
27
|
private _debounceTimeMs;
|
|
27
28
|
private interactionStream;
|
|
28
29
|
/**
|
|
@@ -48,8 +49,23 @@ export declare class PageActions {
|
|
|
48
49
|
* @returns Current PageActions service for chaining method calls
|
|
49
50
|
*/
|
|
50
51
|
accountId(value: string): PageActions;
|
|
52
|
+
/**
|
|
53
|
+
* Configure your group ID for reported actions. Must be configured before reporting page view or any action.
|
|
54
|
+
* It should be used if you want to measure different things or single page or you have same form on different pages. You can filter page views by group ID in the dashboard.
|
|
55
|
+
* @param value A Group ID for reported actions, 'default' if not provided
|
|
56
|
+
* @returns Current PageActions service for chaining method calls
|
|
57
|
+
*/
|
|
51
58
|
group(value: string): PageActions;
|
|
59
|
+
/**
|
|
60
|
+
* Reports page view event. Must be called only once before any page action is reported.
|
|
61
|
+
* @returns Current PageActions service for chaining method calls
|
|
62
|
+
*/
|
|
52
63
|
pageView(): PageActions;
|
|
64
|
+
/**
|
|
65
|
+
* Signals that page view ended. Stops page view duration timer and flushes all interactions to the collector.
|
|
66
|
+
* @returns Current PageActions service for chaining method calls
|
|
67
|
+
*/
|
|
68
|
+
endPageView(): PageActions;
|
|
53
69
|
/**
|
|
54
70
|
* Reports an action with given type
|
|
55
71
|
* @param type An identifier for the action
|
|
@@ -69,11 +85,31 @@ export declare class PageActions {
|
|
|
69
85
|
* @returns Current PageActions service
|
|
70
86
|
*/
|
|
71
87
|
flush(): PageActions;
|
|
72
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Register a listener that handles page visibility changes. It is used to calculate page visit duration and
|
|
90
|
+
* to automatically flush page actions when page is closed.
|
|
91
|
+
* @returns Current PageActions service
|
|
92
|
+
*/
|
|
93
|
+
registerVisibilityListener(): PageActions;
|
|
94
|
+
/**
|
|
95
|
+
* Unregister an existing visibility listener.
|
|
96
|
+
* @returns Current PageActions service
|
|
97
|
+
*/
|
|
98
|
+
unregisterVisibilityListener(): PageActions;
|
|
99
|
+
/**
|
|
100
|
+
* Report page enters visible state
|
|
101
|
+
* @returns Current PageActions service
|
|
102
|
+
*/
|
|
103
|
+
pageVisible(): PageActions;
|
|
104
|
+
/**
|
|
105
|
+
* Report page enters hidden state
|
|
106
|
+
* @returns Current PageActions service
|
|
107
|
+
*/
|
|
108
|
+
pageHidden(): PageActions;
|
|
109
|
+
private containsInteraction;
|
|
73
110
|
private createInteraction;
|
|
74
111
|
private appendInteraction;
|
|
75
112
|
private generateId;
|
|
76
|
-
private determineBrowser;
|
|
77
113
|
private isPageViewRegistered;
|
|
78
114
|
private registerInteractionsListener;
|
|
79
115
|
private publishInteractions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageActions.d.ts","sourceRoot":"","sources":["../../src/service/PageActions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PageActions.d.ts","sourceRoot":"","sources":["../../src/service/PageActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAyB,MAAM,6BAA6B,CAAC;AAIjG,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gIAAgI;IAChI,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wEAAwE;AACxE,qBAAa,WAAW;IACf,YAAY,EAAE,WAAW,EAAE,CAAM;IACjC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAa;IAClD,OAAO,CAAC,mBAAmB,CAAkB;IAE7C,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,kBAAkB,CAA0B;IACpD,OAAO,CAAC,c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VIEW } from "../type/Interaction.type.js";
|
|
4
2
|
import { debounceTime, Subject } from "rxjs";
|
|
3
|
+
import { VISIBLITY_IN, VISIBLITY_OUT } from "../type/visibility.type.js";
|
|
5
4
|
/** Entry point class to report actions to the Page Actions collector */
|
|
6
5
|
export class PageActions {
|
|
7
6
|
/**
|
|
@@ -19,6 +18,8 @@ export class PageActions {
|
|
|
19
18
|
this._groupName = "default";
|
|
20
19
|
this._pageUrl = undefined;
|
|
21
20
|
this._referrer = undefined;
|
|
21
|
+
this._visibilityChanges = [];
|
|
22
|
+
this._listenerAbort = undefined;
|
|
22
23
|
this._debounceTimeMs = 2000;
|
|
23
24
|
this.interactionStream = new Subject();
|
|
24
25
|
if (!siteId) {
|
|
@@ -60,6 +61,12 @@ export class PageActions {
|
|
|
60
61
|
this._accountId = value;
|
|
61
62
|
return this;
|
|
62
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Configure your group ID for reported actions. Must be configured before reporting page view or any action.
|
|
66
|
+
* It should be used if you want to measure different things or single page or you have same form on different pages. You can filter page views by group ID in the dashboard.
|
|
67
|
+
* @param value A Group ID for reported actions, 'default' if not provided
|
|
68
|
+
* @returns Current PageActions service for chaining method calls
|
|
69
|
+
*/
|
|
63
70
|
group(value) {
|
|
64
71
|
if (!value)
|
|
65
72
|
throw new Error(REQUIRE_GROUP_MESSAGE);
|
|
@@ -68,6 +75,10 @@ export class PageActions {
|
|
|
68
75
|
this._groupName = value;
|
|
69
76
|
return this;
|
|
70
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Reports page view event. Must be called only once before any page action is reported.
|
|
80
|
+
* @returns Current PageActions service for chaining method calls
|
|
81
|
+
*/
|
|
71
82
|
pageView() {
|
|
72
83
|
if (!this._collectorUrl)
|
|
73
84
|
throw new Error(COLLECTOR_MISSING_MESSAGE);
|
|
@@ -75,9 +86,11 @@ export class PageActions {
|
|
|
75
86
|
throw new Error(ACCOUNT_ID_MISSING_MESSAGE);
|
|
76
87
|
if (this.interactions.length > 0)
|
|
77
88
|
throw new Error(PAGEVIEW_REPEATED_MESSAGE);
|
|
78
|
-
this.determineBrowser();
|
|
79
89
|
this._pageUrl = document.location.href;
|
|
80
90
|
this._referrer = document.referrer;
|
|
91
|
+
this._visibilityChanges = [];
|
|
92
|
+
if (document.visibilityState === "visible")
|
|
93
|
+
this.pageVisible();
|
|
81
94
|
const interaction = this.createInteraction(PAGE_VIEW, {});
|
|
82
95
|
this.pageViewId = interaction.id;
|
|
83
96
|
this.appendInteraction(interaction);
|
|
@@ -85,6 +98,21 @@ export class PageActions {
|
|
|
85
98
|
console.log("Registered page view", interaction);
|
|
86
99
|
return this;
|
|
87
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Signals that page view ended. Stops page view duration timer and flushes all interactions to the collector.
|
|
103
|
+
* @returns Current PageActions service for chaining method calls
|
|
104
|
+
*/
|
|
105
|
+
endPageView() {
|
|
106
|
+
if (!this.pageViewId)
|
|
107
|
+
throw new Error(PAGEVIEW_NOT_ACTIVE);
|
|
108
|
+
this.pageHidden();
|
|
109
|
+
this.flush();
|
|
110
|
+
this.pageViewId = undefined;
|
|
111
|
+
this.interactions = [];
|
|
112
|
+
if (this._verbose)
|
|
113
|
+
console.log("Page view ended");
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
88
116
|
/**
|
|
89
117
|
* Reports an action with given type
|
|
90
118
|
* @param type An identifier for the action
|
|
@@ -155,6 +183,60 @@ export class PageActions {
|
|
|
155
183
|
this.publishInteractions();
|
|
156
184
|
return this;
|
|
157
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Register a listener that handles page visibility changes. It is used to calculate page visit duration and
|
|
188
|
+
* to automatically flush page actions when page is closed.
|
|
189
|
+
* @returns Current PageActions service
|
|
190
|
+
*/
|
|
191
|
+
registerVisibilityListener() {
|
|
192
|
+
const abortController = new AbortController();
|
|
193
|
+
this._listenerAbort = abortController;
|
|
194
|
+
addEventListener("visibilitychange", () => {
|
|
195
|
+
if (document.visibilityState === "visible") {
|
|
196
|
+
this.pageVisible();
|
|
197
|
+
}
|
|
198
|
+
if (document.visibilityState === "hidden") {
|
|
199
|
+
this.pageHidden();
|
|
200
|
+
this.flush();
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
signal: abortController.signal,
|
|
204
|
+
});
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Unregister an existing visibility listener.
|
|
209
|
+
* @returns Current PageActions service
|
|
210
|
+
*/
|
|
211
|
+
unregisterVisibilityListener() {
|
|
212
|
+
if (this._listenerAbort) {
|
|
213
|
+
this._listenerAbort.abort();
|
|
214
|
+
}
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Report page enters visible state
|
|
219
|
+
* @returns Current PageActions service
|
|
220
|
+
*/
|
|
221
|
+
pageVisible() {
|
|
222
|
+
this._visibilityChanges.push({
|
|
223
|
+
type: VISIBLITY_IN,
|
|
224
|
+
at: new Date().toISOString(),
|
|
225
|
+
});
|
|
226
|
+
return this;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Report page enters hidden state
|
|
230
|
+
* @returns Current PageActions service
|
|
231
|
+
*/
|
|
232
|
+
pageHidden() {
|
|
233
|
+
this._visibilityChanges.push({
|
|
234
|
+
type: VISIBLITY_OUT,
|
|
235
|
+
at: new Date().toISOString(),
|
|
236
|
+
});
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
// Private
|
|
158
240
|
containsInteraction(interactionType) {
|
|
159
241
|
return this.interactions.findIndex((it) => it.type === interactionType) >= 0;
|
|
160
242
|
}
|
|
@@ -178,14 +260,6 @@ export class PageActions {
|
|
|
178
260
|
return "ev" + Math.random().toString();
|
|
179
261
|
}
|
|
180
262
|
}
|
|
181
|
-
determineBrowser() {
|
|
182
|
-
const parser = new UAParser(Crawlers);
|
|
183
|
-
const results = parser.getResult();
|
|
184
|
-
this.browser = {
|
|
185
|
-
type: results.browser.type,
|
|
186
|
-
bot: results.browser.type === "crawler",
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
263
|
isPageViewRegistered() {
|
|
190
264
|
return this.interactions.length > 0 && this.interactions[0].type === "pv";
|
|
191
265
|
}
|
|
@@ -205,10 +279,9 @@ export class PageActions {
|
|
|
205
279
|
pageViewId: this.pageViewId,
|
|
206
280
|
interactions: this.interactions,
|
|
207
281
|
viewStartedAt: new Date(),
|
|
208
|
-
browser: this.browser,
|
|
209
282
|
referrer: this._referrer,
|
|
210
283
|
pageUrl: this._pageUrl,
|
|
211
|
-
|
|
284
|
+
visibility: this._visibilityChanges,
|
|
212
285
|
};
|
|
213
286
|
}
|
|
214
287
|
// extract networking to separate file
|
|
@@ -240,4 +313,5 @@ const ACCOUNT_ID_AFTER_PAGEVIEW_MESSAGE = "Account id cannot be changed after pa
|
|
|
240
313
|
const REQUIRE_GROUP_MESSAGE = "Group name cannot be empty";
|
|
241
314
|
const REQUIRE_ACCOUNT_ID_MESSAGE = "Account id cannot be empty";
|
|
242
315
|
const PAGEVIEW_REPEATED_MESSAGE = "Function pageView() can be called at most once with given PageActions object";
|
|
316
|
+
const PAGEVIEW_NOT_ACTIVE = "There is no active PageView";
|
|
243
317
|
//# sourceMappingURL=PageActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageActions.js","sourceRoot":"","sources":["../../src/service/PageActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PageActions.js","sourceRoot":"","sources":["../../src/service/PageActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA2C,MAAM,6BAA6B,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAyB,MAAM,4BAA4B,CAAC;AAchG,wEAAwE;AACxE,MAAM,OAAO,WAAW;IAkBtB;;;OAGG;IACH,YAAY,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A0B,GAAG,4BAA4B,CAAC;AAChE,MAAM,yBAAyB,GAC7B,8EAA8E,CAAC;AACjF,MAAM,mBAAmB,GAAG,6BAA6B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VisibilityChange } from "./visibility.type.js";
|
|
1
2
|
export declare const PAGE_VIEW = "pv";
|
|
2
3
|
export interface Interaction {
|
|
3
4
|
id: string;
|
|
@@ -12,13 +13,8 @@ export interface ViewInteractions {
|
|
|
12
13
|
pageViewId: string;
|
|
13
14
|
viewStartedAt: Date;
|
|
14
15
|
interactions: Interaction[];
|
|
15
|
-
browser?: Browser;
|
|
16
16
|
referrer?: string;
|
|
17
17
|
pageUrl?: string;
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
export interface Browser {
|
|
21
|
-
type?: string;
|
|
22
|
-
bot: boolean;
|
|
18
|
+
visibility: VisibilityChange[];
|
|
23
19
|
}
|
|
24
20
|
//# sourceMappingURL=Interaction.type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interaction.type.d.ts","sourceRoot":"","sources":["../../src/type/Interaction.type.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,OAAO,CAAC;AAE9B,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,IAAI,CAAC;IACpB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,
|
|
1
|
+
{"version":3,"file":"Interaction.type.d.ts","sourceRoot":"","sources":["../../src/type/Interaction.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,eAAO,MAAM,SAAS,OAAO,CAAC;AAE9B,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,IAAI,CAAC;IACpB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,gBAAgB,EAAE,CAAC;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interaction.type.js","sourceRoot":"","sources":["../../src/type/Interaction.type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Interaction.type.js","sourceRoot":"","sources":["../../src/type/Interaction.type.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visibility.type.d.ts","sourceRoot":"","sources":["../../src/type/visibility.type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,aAAa,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visibility.type.js","sourceRoot":"","sources":["../../src/type/visibility.type.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pageactions/page-actions-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Page Actions JavaScript client library",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://www.page-actions.com",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
|
+
"prebuild": "npm run fmt && npm run test",
|
|
30
31
|
"build": "tsc",
|
|
31
32
|
"build:watch": "tsc --watch",
|
|
32
33
|
"build:link": "npm run build && npm link",
|
|
@@ -37,8 +38,7 @@
|
|
|
37
38
|
"fmt:check": "oxfmt --check"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"rxjs": "^7.8.2"
|
|
41
|
-
"ua-parser-js": "^2.0.9"
|
|
41
|
+
"rxjs": "^7.8.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"jsdom": "^28.1.0",
|