@playpilot/tpi 8.10.3 → 8.10.4-beta.2
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/dist/editorial.mount.js +8 -8
- package/dist/link-injections.js +2 -2
- package/dist/mount.js +6 -6
- package/package.json +1 -1
- package/src/lib/api/externalPages.ts +17 -10
- package/src/lib/api/session.ts +5 -7
- package/src/lib/injectionElements.ts +2 -2
- package/src/main.ts +1 -4
- package/src/routes/+page.svelte +4 -10
- package/src/routes/components/Editorial/Editor.svelte +3 -4
- package/src/routes/components/Editorial/ManualInjection.svelte +4 -3
- package/src/routes/components/Editorial/Session.svelte +2 -4
- package/src/routes/components/Explore/ExploreLayout.svelte +1 -0
- package/vite._mount.config.js.timestamp-1781001671448-4d03f5733979f.mjs +0 -105
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import type { LinkInjectionResponse, LinkInjection } from '../types/injection'
|
|
|
6
6
|
import { getFullUrlPath } from '../url'
|
|
7
7
|
import { api } from './api'
|
|
8
8
|
import { getApiToken } from '$lib/token'
|
|
9
|
+
import { getPageTextAndElements } from '$lib/injectionElements'
|
|
9
10
|
|
|
10
11
|
let pollTimeout: ReturnType<typeof setTimeout> | null = null
|
|
11
12
|
|
|
@@ -13,19 +14,22 @@ let pollTimeout: ReturnType<typeof setTimeout> | null = null
|
|
|
13
14
|
* Fetch link injections for a URL. This will be either a POST or a GET request depending on whether on not the AI should run.
|
|
14
15
|
*/
|
|
15
16
|
export async function fetchLinkInjections(
|
|
16
|
-
|
|
17
|
-
{ url
|
|
18
|
-
{ url?: string, hash?: string, params?: Record<string, any>, method?: 'GET' | 'POST' } = {},
|
|
17
|
+
{ url = getFullUrlPath(), params = {}, method = 'GET' }:
|
|
18
|
+
{ url?: string, params?: Record<string, any>, method?: 'GET' | 'POST' } = {},
|
|
19
19
|
): Promise<LinkInjectionResponse> {
|
|
20
20
|
const apiToken = getApiToken()
|
|
21
21
|
const isEditorialMode = isEditorialModeEnabled() ? await authorize() : false
|
|
22
22
|
const language = getLanguage()
|
|
23
|
+
const { pageText } = getPageTextAndElements()
|
|
24
|
+
const hash = stringToHash(pageText || '')
|
|
23
25
|
|
|
24
26
|
if (!apiToken) throw new Error('No token was provided')
|
|
25
27
|
|
|
26
28
|
const apiUrl = `/external-pages/?api-token=${apiToken}&include_title_details=true${isEditorialMode ? '&editorial_mode_enabled=true' : ''}&language=${language}`
|
|
27
29
|
let response: LinkInjectionResponse
|
|
28
30
|
|
|
31
|
+
console.log('page text in fetchLinkInjections', { pageText })
|
|
32
|
+
|
|
29
33
|
// We use separate requests when running the AI or setting the editor session vs when only getting the results.
|
|
30
34
|
// For regular requests we use a GET endpoint, but when saving data we POST to the same url.
|
|
31
35
|
if (method === 'POST') {
|
|
@@ -60,16 +64,19 @@ export async function fetchLinkInjections(
|
|
|
60
64
|
* The results return `injections_ready=false` while the injections are not yet ready.
|
|
61
65
|
*/
|
|
62
66
|
export async function pollLinkInjections(
|
|
63
|
-
pageText: string,
|
|
64
67
|
{ requireCompletedResult = false, runAiWhenRelevant = false, pollInterval = 3000, maxTries = 600, onpoll = () => null }:
|
|
65
68
|
{ requireCompletedResult?: boolean, runAiWhenRelevant?: boolean, pollInterval?: number, maxTries?: number, onpoll?: (_response: LinkInjectionResponse) => void } = {},
|
|
66
69
|
): Promise<LinkInjectionResponse> {
|
|
70
|
+
const { pageText } = getPageTextAndElements()
|
|
71
|
+
|
|
67
72
|
let currentTry = 0
|
|
68
73
|
|
|
69
74
|
// Clear pollTimeout if it is already running to prevent multiple timeouts from running at the same time
|
|
70
75
|
// This is mostly handy during HMR, but also during navigation changes
|
|
71
76
|
if (pollTimeout) clearTimeout(pollTimeout)
|
|
72
77
|
|
|
78
|
+
console.log('page text in pollLinkInjections', { pageText })
|
|
79
|
+
|
|
73
80
|
const poll = async (resolve: Function, reject: Function): Promise<void> => {
|
|
74
81
|
let response
|
|
75
82
|
try {
|
|
@@ -77,14 +84,14 @@ export async function pollLinkInjections(
|
|
|
77
84
|
// if it does. We're still interested in handling the response from here and don't want it to short circuit
|
|
78
85
|
// just because the fetch failed.
|
|
79
86
|
try {
|
|
80
|
-
response = await fetchLinkInjections(
|
|
87
|
+
response = await fetchLinkInjections()
|
|
81
88
|
} catch(error: any) {
|
|
82
89
|
if (error?.status === 404) {
|
|
83
90
|
// If the GET endpoint returns a 404 no article has been generated yet and we can safely generate
|
|
84
91
|
// a new article. We can safely throw here (meaning we poll again) as nothing will be returned.
|
|
85
92
|
// The first POST indexes the article, the second runs the AI if needed.
|
|
86
|
-
response = await fetchLinkInjections(
|
|
87
|
-
if (response.ai_enabled) response = await fetchLinkInjections(
|
|
93
|
+
response = await fetchLinkInjections({ method: 'POST' })
|
|
94
|
+
if (response.ai_enabled) response = await fetchLinkInjections({ params: { run_ai: true }, method: 'POST' })
|
|
88
95
|
}
|
|
89
96
|
|
|
90
97
|
throw new Error
|
|
@@ -133,10 +140,10 @@ export async function runAiBasedOnResponse(pageText: string, response: LinkInjec
|
|
|
133
140
|
if (response.ai_last_run && isCurrentTimeEqualToResponseTime) return response
|
|
134
141
|
if (new Date(currentModifiedTime || 0) <= new Date(responseModifiedTime || 0)) return response
|
|
135
142
|
|
|
136
|
-
return await fetchLinkInjections(
|
|
143
|
+
return await fetchLinkInjections({ params: { run_ai: true }, method: 'POST' })
|
|
137
144
|
}
|
|
138
145
|
|
|
139
|
-
export async function saveLinkInjections(linkInjections: LinkInjection[]
|
|
146
|
+
export async function saveLinkInjections(linkInjections: LinkInjection[]): Promise<LinkInjection[]> {
|
|
140
147
|
const selector = window.PlayPilotLinkInjections?.selector
|
|
141
148
|
|
|
142
149
|
// Only save manual injections, AI injections should be left intact and can't be saved over
|
|
@@ -156,7 +163,7 @@ export async function saveLinkInjections(linkInjections: LinkInjection[], pageTe
|
|
|
156
163
|
removed: !!linkInjection.removed,
|
|
157
164
|
}))
|
|
158
165
|
|
|
159
|
-
const response = await fetchLinkInjections(
|
|
166
|
+
const response = await fetchLinkInjections({
|
|
160
167
|
method: 'POST',
|
|
161
168
|
params: {
|
|
162
169
|
private_token: getAuthToken(),
|
package/src/lib/api/session.ts
CHANGED
|
@@ -11,10 +11,9 @@ export const sessionPeriodMilliseconds = sessionPollPeriodMilliseconds * 2
|
|
|
11
11
|
* where we save the session.
|
|
12
12
|
* Along with that, we also return ai_enabled and injections_enabled as they are used to update the state of
|
|
13
13
|
* the current editing session.
|
|
14
|
-
* @param pageText Despite not being used, the request still requires a valid pageText string
|
|
15
14
|
*/
|
|
16
|
-
export async function fetchAsSession(
|
|
17
|
-
const { ai_enabled, injections_enabled, ai_last_run, session_id, session_last_ping } = await fetchLinkInjections(
|
|
15
|
+
export async function fetchAsSession(): Promise<SessionResponse> {
|
|
16
|
+
const { ai_enabled, injections_enabled, ai_last_run, session_id, session_last_ping } = await fetchLinkInjections()
|
|
18
17
|
|
|
19
18
|
const isCurrentlyAllowToEdit = isAllowedToEdit(session_id || null, session_last_ping || null)
|
|
20
19
|
|
|
@@ -28,15 +27,14 @@ export async function fetchAsSession(pageText: string): Promise<SessionResponse>
|
|
|
28
27
|
|
|
29
28
|
if (!isCurrentlyAllowToEdit) return response
|
|
30
29
|
|
|
31
|
-
return await saveCurrentSession(
|
|
30
|
+
return await saveCurrentSession()
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
34
|
* Save the current users session id as the currently active session. This is always completed regardless of if the user
|
|
36
35
|
* is the current owner of the session, so check that first if necessary!
|
|
37
|
-
* @param pageText Despite not being used, the request still requires a valid pageText string
|
|
38
36
|
*/
|
|
39
|
-
export async function saveCurrentSession(
|
|
37
|
+
export async function saveCurrentSession(): Promise<SessionResponse> {
|
|
40
38
|
const sessionId = getSessionId()
|
|
41
39
|
const now = new Date(Date.now()).toISOString()
|
|
42
40
|
|
|
@@ -45,7 +43,7 @@ export async function saveCurrentSession(pageText: string): Promise<SessionRespo
|
|
|
45
43
|
session_last_ping: now.toString(),
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
const { ai_enabled, injections_enabled, ai_last_run } = await fetchLinkInjections(
|
|
46
|
+
const { ai_enabled, injections_enabled, ai_last_run } = await fetchLinkInjections({ params })
|
|
49
47
|
|
|
50
48
|
return {
|
|
51
49
|
ai_enabled,
|
|
@@ -91,9 +91,9 @@ export function getPageText(elements: HTMLElement[]): string {
|
|
|
91
91
|
return elements.map(element => element.innerText).join('\n\n')
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export function getPageTextAndElements(config: ConfigResponse
|
|
94
|
+
export function getPageTextAndElements(config: ConfigResponse = window.PlayPilotLinkInjections?.config): { parentElement: HTMLElement, elements: HTMLElement[], pageText: string } {
|
|
95
95
|
const parentElement = getLinkInjectionsParentElement()
|
|
96
|
-
const elements = getLinkInjectionElements(parentElement, config
|
|
96
|
+
const elements = getLinkInjectionElements(parentElement, config.exclude_elements_selector || '')
|
|
97
97
|
const pageText = getPageText(elements)
|
|
98
98
|
|
|
99
99
|
return { parentElement, elements, pageText }
|
package/src/main.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { fetchConfig } from '$lib/api/config'
|
|
|
3
3
|
import { pollLinkInjections } from '$lib/api/externalPages'
|
|
4
4
|
import { setConsent } from '$lib/consent'
|
|
5
5
|
import { isCrawler } from '$lib/crawler'
|
|
6
|
-
import { getPageTextAndElements } from '$lib/injectionElements'
|
|
7
6
|
import { isUrlExcludedViaConfig } from '$lib/url'
|
|
8
7
|
|
|
9
8
|
window.PlayPilotLinkInjections ||= {
|
|
@@ -70,9 +69,7 @@ window.PlayPilotLinkInjections ||= {
|
|
|
70
69
|
|
|
71
70
|
if (isUrlExcludedViaConfig(this.config)) return
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.initial_link_injections_promise = pollLinkInjections(pageText, { maxTries: 1, runAiWhenRelevant: !isCrawler() })
|
|
72
|
+
this.initial_link_injections_promise = pollLinkInjections({ maxTries: 1, runAiWhenRelevant: !isCrawler() })
|
|
76
73
|
|
|
77
74
|
this.mount()
|
|
78
75
|
},
|
package/src/routes/+page.svelte
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { onDestroy } from 'svelte'
|
|
3
3
|
import { pollLinkInjections } from '$lib/api/externalPages'
|
|
4
4
|
import { clearLinkInjections, injectLinksInDocument, separateLinkInjectionTypes } from '$lib/injection'
|
|
5
|
-
import { getPageText, getPageTextAndElements } from '$lib/injectionElements'
|
|
6
5
|
import { fireQueuedTrackingEvents, setTrackingSids, track } from '$lib/tracking'
|
|
7
6
|
import { isUrlExcludedViaConfig } from '$lib/url'
|
|
8
7
|
import { isCrawler } from '$lib/crawler'
|
|
@@ -11,6 +10,7 @@
|
|
|
11
10
|
import { fetchConfig } from '$lib/api/config'
|
|
12
11
|
import { insertExplore, insertExploreIntoNavigation } from '$lib/explore'
|
|
13
12
|
import { authorize, getAuthToken, isEditorialModeEnabled, removeAuthCookie, setEditorialParamInUrl } from '$lib/api/auth'
|
|
13
|
+
import { getPageTextAndElements } from '$lib/injectionElements'
|
|
14
14
|
import type { LinkInjectionResponse, LinkInjection, LinkInjectionTypes } from '$lib/types/injection'
|
|
15
15
|
import Editor from './components/Editorial/Editor.svelte'
|
|
16
16
|
import EditorTrigger from './components/Editorial/EditorTrigger.svelte'
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
import PostersScrollReveal from './components/PostersScrollReveal.svelte'
|
|
23
23
|
import TrackingPixelsForTitleDataPerLink from './components/TrackingPixelsForTitleDataPerLink.svelte'
|
|
24
24
|
|
|
25
|
-
let elements: HTMLElement[] = $state([])
|
|
26
|
-
|
|
27
25
|
let response: LinkInjectionResponse | null = $state(null)
|
|
28
26
|
let isEditorialMode = $state(isEditorialModeEnabled())
|
|
29
27
|
let hasAuthToken = $state(!!getAuthToken())
|
|
@@ -35,8 +33,6 @@
|
|
|
35
33
|
// @ts-ignore It's ok if the response is empty
|
|
36
34
|
const { ai_injections: aiInjections = [], manual_injections: manualInjections = [] } = $derived(response || {})
|
|
37
35
|
|
|
38
|
-
const pageText = $derived(getPageText(elements))
|
|
39
|
-
|
|
40
36
|
const initializePromise = initialize()
|
|
41
37
|
|
|
42
38
|
$effect(() => {
|
|
@@ -86,8 +82,6 @@
|
|
|
86
82
|
if (isUrlExcluded) return
|
|
87
83
|
|
|
88
84
|
if (config?.html_selector) window.PlayPilotLinkInjections.selector = config?.html_selector
|
|
89
|
-
|
|
90
|
-
elements = getPageTextAndElements(window.PlayPilotLinkInjections.config).elements
|
|
91
85
|
} catch(error) {
|
|
92
86
|
// We return if the config did not get fetched properly, as we can't determine what should and should
|
|
93
87
|
// get injected without it.
|
|
@@ -98,7 +92,7 @@
|
|
|
98
92
|
|
|
99
93
|
try {
|
|
100
94
|
response = await window.PlayPilotLinkInjections.initial_link_injections_promise || null
|
|
101
|
-
response ||= await pollLinkInjections(
|
|
95
|
+
response ||= await pollLinkInjections({ maxTries: 1, runAiWhenRelevant: !isCrawler() })
|
|
102
96
|
|
|
103
97
|
loading = false
|
|
104
98
|
|
|
@@ -114,7 +108,7 @@
|
|
|
114
108
|
|
|
115
109
|
if (!isEditorialMode || isCrawler()) return
|
|
116
110
|
|
|
117
|
-
response = await pollLinkInjections(
|
|
111
|
+
response = await pollLinkInjections({ requireCompletedResult: true, onpoll: (update) => response = update })
|
|
118
112
|
inject({ aiInjections, manualInjections })
|
|
119
113
|
} catch(error: unknown) {
|
|
120
114
|
console.error(error)
|
|
@@ -136,6 +130,7 @@
|
|
|
136
130
|
}
|
|
137
131
|
|
|
138
132
|
function inject(injections: LinkInjectionTypes = { aiInjections, manualInjections }): void {
|
|
133
|
+
const { elements } = getPageTextAndElements()
|
|
139
134
|
const filteredInjections = injectLinksInDocument(elements, injections)
|
|
140
135
|
|
|
141
136
|
if (JSON.stringify(filteredInjections) !== JSON.stringify(linkInjections)) {
|
|
@@ -206,7 +201,6 @@
|
|
|
206
201
|
<svelte:boundary onerror={(error) => track(TrackingEvent.EditorError, null, { message: (error as Error).message })}>
|
|
207
202
|
<Editor
|
|
208
203
|
bind:linkInjections
|
|
209
|
-
{pageText}
|
|
210
204
|
{loading}
|
|
211
205
|
onreinitialize={reinitializeEditor}
|
|
212
206
|
injectionsEnabled={response?.injections_enabled}
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
|
|
34
34
|
let {
|
|
35
35
|
linkInjections = $bindable(),
|
|
36
|
-
pageText = '',
|
|
37
36
|
loading = false,
|
|
38
37
|
injectionsEnabled = false,
|
|
39
38
|
aiStatus = {},
|
|
@@ -46,6 +45,8 @@
|
|
|
46
45
|
const position: Position = JSON.parse(localStorage.getItem(editorPositionKey) || '{ "x": 0, "y": 0 }')
|
|
47
46
|
const height: number = parseInt(localStorage.getItem(editorHeightKey) || '0')
|
|
48
47
|
|
|
48
|
+
|
|
49
|
+
|
|
49
50
|
let editorElement: HTMLElement | null = $state(null)
|
|
50
51
|
let manualInjectionActive = $state(false)
|
|
51
52
|
let saving = $state(false)
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
saving = true
|
|
86
87
|
hasError = false
|
|
87
88
|
|
|
88
|
-
linkInjections = await saveLinkInjections(linkInjections
|
|
89
|
+
linkInjections = await saveLinkInjections(linkInjections)
|
|
89
90
|
initialStateString = linkInjectionsString
|
|
90
91
|
} catch {
|
|
91
92
|
hasError = true
|
|
@@ -177,7 +178,6 @@
|
|
|
177
178
|
|
|
178
179
|
{#if !loading}
|
|
179
180
|
<Session
|
|
180
|
-
{pageText}
|
|
181
181
|
onallow={() => allowEditing = true}
|
|
182
182
|
ondisallow={() => allowEditing = false}
|
|
183
183
|
ontakeover={onreinitialize}
|
|
@@ -231,7 +231,6 @@
|
|
|
231
231
|
style:top="{scrollDistance}px"
|
|
232
232
|
transition:fly={{ x: Math.min(window.innerWidth, 320), duration: 200, opacity: 1 }}>
|
|
233
233
|
<ManualInjection
|
|
234
|
-
{pageText}
|
|
235
234
|
onclose={() => manualInjectionActive = false}
|
|
236
235
|
onsave={(linkInjection) => linkInjections.push(linkInjection)} />
|
|
237
236
|
</div>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { onMount } from 'svelte'
|
|
5
5
|
import { playPilotBaseUrl } from '$lib/constants'
|
|
6
6
|
import { generateInjectionKey } from '$lib/api/externalPages'
|
|
7
|
-
import { getLinkInjectionsParentElement } from '$lib/injectionElements'
|
|
7
|
+
import { getLinkInjectionsParentElement, getPageTextAndElements } from '$lib/injectionElements'
|
|
8
8
|
import { heading } from '$lib/actions/heading'
|
|
9
9
|
import { findSurroundingPhrases, cleanPhrase } from '$lib/text'
|
|
10
10
|
import { getIndexOfSelection } from '$lib/selection'
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
import TitleSearch from './Search/TitleSearch.svelte'
|
|
16
16
|
|
|
17
17
|
interface Props {
|
|
18
|
-
pageText: string
|
|
19
18
|
onsave: (linkInjection: LinkInjection) => void
|
|
20
19
|
onclose?: () => void
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
const {
|
|
22
|
+
const { onsave, onclose = () => null }: Props = $props()
|
|
23
|
+
|
|
24
|
+
const { pageText } = getPageTextAndElements()
|
|
24
25
|
|
|
25
26
|
let currentSelection = $state('')
|
|
26
27
|
let selectionSentence = $state('')
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import Alert from './Alert.svelte'
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
|
-
pageText?: string,
|
|
8
7
|
onpoll?: ({ injectionsEnabled, aiEnabled }: { injectionsEnabled: boolean, aiEnabled: boolean }) => void,
|
|
9
8
|
onallow?: () => void,
|
|
10
9
|
ondisallow?: () => void,
|
|
@@ -12,7 +11,6 @@
|
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
const {
|
|
15
|
-
pageText = '',
|
|
16
14
|
onpoll = () => null,
|
|
17
15
|
onallow = () => null,
|
|
18
16
|
ondisallow = () => null,
|
|
@@ -36,7 +34,7 @@
|
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
async function setSession(): Promise<void> {
|
|
39
|
-
const result = await fetchAsSession(
|
|
37
|
+
const result = await fetchAsSession()
|
|
40
38
|
|
|
41
39
|
if (!result) return
|
|
42
40
|
|
|
@@ -49,7 +47,7 @@
|
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
function takeOverEditing(): void {
|
|
52
|
-
saveCurrentSession(
|
|
50
|
+
saveCurrentSession()
|
|
53
51
|
ontakeover()
|
|
54
52
|
}
|
|
55
53
|
</script>
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
let { navigate = () => null, searchQuery = $bindable(''), filter = $bindable({}), children }: Props = $props()
|
|
23
23
|
|
|
24
|
+
// svelte-ignore non_reactive_update
|
|
24
25
|
let element: HTMLElement | null = null
|
|
25
26
|
let height: string | null = $state(null)
|
|
26
27
|
let clientWidth: number = $state(window.innerWidth)
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// vite._mount.config.js
|
|
2
|
-
import path from "path";
|
|
3
|
-
import * as dotenv from "file:///C:/Sites/playpilot-link-injection/node_modules/dotenv/lib/main.js";
|
|
4
|
-
import { defineConfig } from "file:///C:/Sites/playpilot-link-injection/node_modules/vitest/dist/config.js";
|
|
5
|
-
import { svelte } from "file:///C:/Sites/playpilot-link-injection/node_modules/@sveltejs/vite-plugin-svelte/src/index.js";
|
|
6
|
-
import cssInjectedByJsPlugin from "file:///C:/Sites/playpilot-link-injection/node_modules/vite-plugin-css-injected-by-js/dist/esm/index.js";
|
|
7
|
-
|
|
8
|
-
// package.json
|
|
9
|
-
var package_default = {
|
|
10
|
-
name: "@playpilot/tpi",
|
|
11
|
-
version: "8.10.3",
|
|
12
|
-
type: "module",
|
|
13
|
-
scripts: {
|
|
14
|
-
dev: "vite dev",
|
|
15
|
-
"dev-build": "npx http-server . /build.html -p 3000",
|
|
16
|
-
build: "vite build --config vite._main.config.js && vite build --config vite._mount.config.js && vite build --config vite._mount.config.js --mode editorial",
|
|
17
|
-
preview: "vite preview",
|
|
18
|
-
check: "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
|
|
19
|
-
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
|
|
20
|
-
format: "prettier --write .",
|
|
21
|
-
lint: "prettier --check . && eslint .",
|
|
22
|
-
"test:unit": "vitest",
|
|
23
|
-
test: "npm run test:unit -- --run",
|
|
24
|
-
release: "node release.js"
|
|
25
|
-
},
|
|
26
|
-
devDependencies: {
|
|
27
|
-
"@playpilot/retargeting-tracking": "^0.1.0",
|
|
28
|
-
"@sveltejs/adapter-auto": "^7.0.1",
|
|
29
|
-
"@sveltejs/kit": "^2.56.1",
|
|
30
|
-
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
31
|
-
"@testing-library/svelte": "^5.2.6",
|
|
32
|
-
"@types/node": "^25.5.2",
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
34
|
-
"@typescript-eslint/parser": "^8.32.1",
|
|
35
|
-
dotenv: "^17.4.1",
|
|
36
|
-
eslint: "^9.27.0",
|
|
37
|
-
"eslint-config-prettier": "^9.1.0",
|
|
38
|
-
"eslint-plugin-svelte": "^3.15.0",
|
|
39
|
-
globals: "^15.0.0",
|
|
40
|
-
"happy-dom": "^16.8.1",
|
|
41
|
-
prettier: "^3.8.3",
|
|
42
|
-
"prettier-plugin-svelte": "^3.2.6",
|
|
43
|
-
sass: "^1.99.0",
|
|
44
|
-
svelte: "5.44.1",
|
|
45
|
-
"svelte-check": "^4.0.0",
|
|
46
|
-
"svelte-preprocess": "^6.0.3",
|
|
47
|
-
"svelte-tiny-slider": "^2.7.1",
|
|
48
|
-
typescript: "^5.9.3",
|
|
49
|
-
"typescript-eslint": "^8.59.2",
|
|
50
|
-
vite: "^5.4.21",
|
|
51
|
-
"vite-plugin-css-injected-by-js": "^4.0.1",
|
|
52
|
-
vitest: "^2.1.9"
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// vite._mount.config.js
|
|
57
|
-
var __vite_injected_original_dirname = "C:\\Sites\\playpilot-link-injection";
|
|
58
|
-
dotenv.config({ path: ".env" });
|
|
59
|
-
var vite_mount_config_default = defineConfig(({ mode }) => {
|
|
60
|
-
const isEditiorial = mode === "editorial";
|
|
61
|
-
return {
|
|
62
|
-
plugins: [
|
|
63
|
-
svelte(),
|
|
64
|
-
cssInjectedByJsPlugin(),
|
|
65
|
-
injectEnvVariables
|
|
66
|
-
],
|
|
67
|
-
build: {
|
|
68
|
-
emptyOutDir: false,
|
|
69
|
-
rollupOptions: {
|
|
70
|
-
input: "./src/mount.ts",
|
|
71
|
-
output: {
|
|
72
|
-
format: "iife",
|
|
73
|
-
name: "PlayPilotMount",
|
|
74
|
-
entryFileNames: isEditiorial ? "editorial.mount.js" : "mount.js"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
resolve: {
|
|
79
|
-
alias: {
|
|
80
|
-
"$lib": path.resolve(__vite_injected_original_dirname, "./src/lib")
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
define: {
|
|
84
|
-
__SCRIPT_VERSION__: JSON.stringify(package_default.version),
|
|
85
|
-
__IS_EDITORIAL_SCRIPT__: JSON.stringify(isEditiorial)
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
});
|
|
89
|
-
var injectEnvVariables = {
|
|
90
|
-
name: "resolve-env-variables",
|
|
91
|
-
/** @param {string} id */
|
|
92
|
-
resolveId(id) {
|
|
93
|
-
if (id === "$env/static/public") return "\0$env/static/public";
|
|
94
|
-
},
|
|
95
|
-
/** @param {string} id */
|
|
96
|
-
load(id) {
|
|
97
|
-
if (id === "\0$env/static/public") {
|
|
98
|
-
return Object.entries(process.env).filter(([key]) => key.startsWith("PUBLIC_")).map(([key, value]) => `export const ${key} = ${JSON.stringify(value)};`).join("\n");
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
export {
|
|
103
|
-
vite_mount_config_default as default
|
|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