@parafin/core 3.1.1 → 3.2.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/index.ts +7 -1
- package/out/index.d.ts +1 -0
- package/out/index.js +6 -1
- package/package.json +12 -3
package/index.ts
CHANGED
|
@@ -59,6 +59,9 @@ export const openParafinDashboard = (
|
|
|
59
59
|
...('inWebView' in props &&
|
|
60
60
|
props.inWebView !== undefined &&
|
|
61
61
|
props.inWebView !== null && { inWebView: props.inWebView.toString() }),
|
|
62
|
+
...(props.dashboardTargetElementId && {
|
|
63
|
+
isDashboardEmbedded: 'true',
|
|
64
|
+
}),
|
|
62
65
|
...Object.fromEntries(searchParams),
|
|
63
66
|
}
|
|
64
67
|
|
|
@@ -196,6 +199,7 @@ export type WidgetProps = {
|
|
|
196
199
|
openInNewTab?: boolean
|
|
197
200
|
onLinkOpened?: (url: string, metadata: LinkOpenedMetadata) => void
|
|
198
201
|
inWebView?: boolean
|
|
202
|
+
dashboardTargetElementId?: string
|
|
199
203
|
}
|
|
200
204
|
|
|
201
205
|
export const initializeParafinWidget = (
|
|
@@ -203,6 +207,7 @@ export const initializeParafinWidget = (
|
|
|
203
207
|
props: WidgetProps
|
|
204
208
|
) => {
|
|
205
209
|
let initStartTime = Date.now()
|
|
210
|
+
let hasLoadedOnce = false
|
|
206
211
|
|
|
207
212
|
// @ts-ignore
|
|
208
213
|
const url = new URL(props.widgetUrlOverride ?? 'https://widget.parafin.com')
|
|
@@ -282,10 +287,11 @@ export const initializeParafinWidget = (
|
|
|
282
287
|
}
|
|
283
288
|
break
|
|
284
289
|
case 'widget-load-complete':
|
|
285
|
-
if (props.onEvent) {
|
|
290
|
+
if (props.onEvent && !hasLoadedOnce) {
|
|
286
291
|
const timeToLoadInMs = Date.now() - initStartTime
|
|
287
292
|
props.onEvent('widget_loaded', { timeToLoadInMs })
|
|
288
293
|
}
|
|
294
|
+
hasLoadedOnce = true
|
|
289
295
|
break
|
|
290
296
|
}
|
|
291
297
|
}
|
package/out/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export type WidgetProps = {
|
|
|
47
47
|
openInNewTab?: boolean;
|
|
48
48
|
onLinkOpened?: (url: string, metadata: LinkOpenedMetadata) => void;
|
|
49
49
|
inWebView?: boolean;
|
|
50
|
+
dashboardTargetElementId?: string;
|
|
50
51
|
};
|
|
51
52
|
export declare const initializeParafinWidget: (iframe: HTMLIFrameElement, props: WidgetProps) => () => void;
|
|
52
53
|
export {};
|
package/out/index.js
CHANGED
|
@@ -29,6 +29,9 @@ export const openParafinDashboard = (props) => {
|
|
|
29
29
|
...('inWebView' in props &&
|
|
30
30
|
props.inWebView !== undefined &&
|
|
31
31
|
props.inWebView !== null && { inWebView: props.inWebView.toString() }),
|
|
32
|
+
...(props.dashboardTargetElementId && {
|
|
33
|
+
isDashboardEmbedded: 'true',
|
|
34
|
+
}),
|
|
32
35
|
...Object.fromEntries(searchParams),
|
|
33
36
|
};
|
|
34
37
|
const url = `${origin}${route}?${new URLSearchParams(query).toString()}`;
|
|
@@ -132,6 +135,7 @@ const emptyMetadata = {
|
|
|
132
135
|
};
|
|
133
136
|
export const initializeParafinWidget = (iframe, props) => {
|
|
134
137
|
let initStartTime = Date.now();
|
|
138
|
+
let hasLoadedOnce = false;
|
|
135
139
|
// @ts-ignore
|
|
136
140
|
const url = new URL(props.widgetUrlOverride ?? 'https://widget.parafin.com');
|
|
137
141
|
const query = {
|
|
@@ -211,10 +215,11 @@ export const initializeParafinWidget = (iframe, props) => {
|
|
|
211
215
|
}
|
|
212
216
|
break;
|
|
213
217
|
case 'widget-load-complete':
|
|
214
|
-
if (props.onEvent) {
|
|
218
|
+
if (props.onEvent && !hasLoadedOnce) {
|
|
215
219
|
const timeToLoadInMs = Date.now() - initStartTime;
|
|
216
220
|
props.onEvent('widget_loaded', { timeToLoadInMs });
|
|
217
221
|
}
|
|
222
|
+
hasLoadedOnce = true;
|
|
218
223
|
break;
|
|
219
224
|
}
|
|
220
225
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parafin/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Parafin embedded core",
|
|
5
5
|
"author": "Parafin (https://www.parafin.com)",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"main": "./out/index.js",
|
|
7
|
+
"module": "./out/index.js",
|
|
8
|
+
"types": "./out/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./out/index.d.ts",
|
|
13
|
+
"import": "./out/index.js",
|
|
14
|
+
"default": "./out/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
8
17
|
"license": "MIT",
|
|
9
18
|
"scripts": {
|
|
10
19
|
"build": "tsc"
|