@playpilot/tpi 5.8.1 → 5.9.0-beta.1

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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "5.8.1",
3
+ "version": "5.9.0-beta.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
- "build": "vite build",
7
+ "build": "vite build && vite build --mode editor",
8
8
  "preview": "vite preview",
9
9
  "check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
10
10
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
package/src/lib/auth.ts CHANGED
@@ -75,7 +75,7 @@ function setAuthCookie(value: string): void {
75
75
  time.setTime(time.getTime() + (days * 24 * 60 * 60 * 1000))
76
76
  const expires = 'expires='+ time.toUTCString()
77
77
 
78
- document.cookie = cookieName + '=' + value + ';' + expires + ';path=/'
78
+ document.cookie = `${cookieName}=${value}; ${expires}; path=/; SameSite=None; Secure`;
79
79
  }
80
80
 
81
81
  export function removeAuthCookie(): void {
@@ -0,0 +1 @@
1
+ declare const IS_EDITOR_BUILD: boolean
@@ -174,31 +174,33 @@
174
174
  </script>
175
175
 
176
176
  <div class="playpilot-link-injections" data-playpilot-link-injections>
177
- {#if !isUrlExcluded && hasAuthToken && !isEditorialMode}
178
- <EditorTrigger
179
- onclick={openEditorialMode}
180
- onclose={() => { hasAuthToken = false; removeAuthCookie() }} />
181
- {/if}
182
-
183
- {#if !isUrlExcluded && isEditorialMode && authorized}
184
- <svelte:boundary onerror={(error) => track(TrackingEvent.EditorError, null, { message: (error as Error).message })}>
185
- <Editor
186
- bind:linkInjections
187
- {pageText}
188
- {loading}
189
- onreinitialize={reinitializeEditor}
190
- injectionsEnabled={response?.injections_enabled}
191
- aiStatus={{
192
- aiEnabled: response?.ai_enabled,
193
- aiRunning: response?.ai_running && response?.ai_enabled,
194
- message: response?.ai_progress_message,
195
- percentage: response?.ai_progress_percentage,
196
- }} />
197
-
198
- {#snippet failed()}
199
- <Alert fixed>An error has occured in the PlayPilot Linkinjections editor view. We've been notified and will investigate!</Alert>
200
- {/snippet}
201
- </svelte:boundary>
177
+ {#if IS_EDITOR_BUILD}
178
+ {#if !isUrlExcluded && hasAuthToken && !isEditorialMode}
179
+ <EditorTrigger
180
+ onclick={openEditorialMode}
181
+ onclose={() => { hasAuthToken = false; removeAuthCookie() }} />
182
+ {/if}
183
+
184
+ {#if !isUrlExcluded && isEditorialMode && authorized}
185
+ <svelte:boundary onerror={(error) => track(TrackingEvent.EditorError, null, { message: (error as Error).message })}>
186
+ <Editor
187
+ bind:linkInjections
188
+ {pageText}
189
+ {loading}
190
+ onreinitialize={reinitializeEditor}
191
+ injectionsEnabled={response?.injections_enabled}
192
+ aiStatus={{
193
+ aiEnabled: response?.ai_enabled,
194
+ aiRunning: response?.ai_running && response?.ai_enabled,
195
+ message: response?.ai_progress_message,
196
+ percentage: response?.ai_progress_percentage,
197
+ }} />
198
+
199
+ {#snippet failed()}
200
+ <Alert fixed>An error has occured in the PlayPilot Linkinjections editor view. We've been notified and will investigate!</Alert>
201
+ {/snippet}
202
+ </svelte:boundary>
203
+ {/if}
202
204
  {/if}
203
205
  </div>
204
206
 
package/tsconfig.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "skipLibCheck": true,
10
10
  "sourceMap": true,
11
11
  "strict": true,
12
- "moduleResolution": "bundler"
12
+ "moduleResolution": "bundler",
13
13
  }
14
14
  // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
15
15
  // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
package/vite.config.js CHANGED
@@ -5,7 +5,11 @@ import { sveltekit } from '@sveltejs/kit/vite'
5
5
  import { svelte } from '@sveltejs/vite-plugin-svelte'
6
6
  import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
7
7
 
8
- export default defineConfig(({ command }) => ({
8
+ export default defineConfig(({ command, mode }) => ({
9
+ define: {
10
+ IS_EDITOR_BUILD: mode === 'editor',
11
+ },
12
+
9
13
  plugins: [
10
14
  command === 'build' ? svelte() : sveltekit(),
11
15
  command === 'build' && cssInjectedByJsPlugin(),
@@ -30,8 +34,9 @@ export default defineConfig(({ command }) => ({
30
34
 
31
35
  if (!jsFile) return
32
36
 
37
+ const affix = mode === 'editor' ? '-editor' : ''
33
38
  const sourcePath = path.join(assetsPath, jsFile)
34
- const targetPath = path.join(distPath, 'link-injections.js')
39
+ const targetPath = path.join(distPath, `link-injections${affix}.js`)
35
40
 
36
41
  // Read original file and wrap it in a self contained function
37
42
  const originalContent = fs.readFileSync(sourcePath, 'utf8')
@@ -67,4 +72,8 @@ export default defineConfig(({ command }) => ({
67
72
  '$lib': path.resolve(__dirname, './src/lib'),
68
73
  },
69
74
  },
75
+
76
+ build: {
77
+ emptyOutDir: false,
78
+ },
70
79
  }))