diff --git a/bin/build-phar.sh b/bin/build-phar.sh
index 2d2f4354f8..2a9e7575c2 100755
--- a/bin/build-phar.sh
+++ b/bin/build-phar.sh
@@ -3,6 +3,13 @@ set -e
CLI_DIR="src/cli"
+restore_cli_package() {
+ composer config repositories --unset --working-dir="$CLI_DIR"
+ rm -rf "$CLI_DIR/vendor"
+}
+
+trap restore_cli_package EXIT
+
composer config repositories.local-etl '{"type": "path", "url": "../core/etl", "options": {"symlink": false}}' --working-dir="$CLI_DIR"
composer config repositories.local-adapter-csv '{"type": "path", "url": "../adapter/etl-adapter-csv", "options": {"symlink": false}}' --working-dir="$CLI_DIR"
composer config repositories.local-adapter-parquet '{"type": "path", "url": "../adapter/etl-adapter-parquet", "options": {"symlink": false}}' --working-dir="$CLI_DIR"
@@ -29,8 +36,5 @@ rm -rf "$CLI_DIR/vendor"
composer update --no-dev --working-dir="$CLI_DIR"
-tools/box/vendor/bin/box compile --config "$CLI_DIR/box.json"
-
-composer config repositories --unset --working-dir="$CLI_DIR"
-
-rm -rf "$CLI_DIR/vendor"
+# Box runs composer in a temporary directory, where a composer wrapper that reads secrets finds no configuration
+COMPOSER_AUTH="${COMPOSER_AUTH:-"{}"}" tools/box/vendor/bin/box compile --config "$CLI_DIR/box.json"
diff --git a/phpdoc/.phpdoc/template/layout.html.twig b/phpdoc/.phpdoc/template/layout.html.twig
index 35a06e7d1c..2f42e2f30f 100644
--- a/phpdoc/.phpdoc/template/layout.html.twig
+++ b/phpdoc/.phpdoc/template/layout.html.twig
@@ -22,6 +22,7 @@
{% endblock %}
{% block javascripts %}
+
diff --git a/web/landing/assets/controllers/clipboard_controller.js b/web/landing/assets/controllers/clipboard_controller.js
index 7474526fa2..c0ca9e6c79 100644
--- a/web/landing/assets/controllers/clipboard_controller.js
+++ b/web/landing/assets/controllers/clipboard_controller.js
@@ -3,6 +3,8 @@ import ClipboardJS from 'clipboard';
export default class extends Controller
{
+ static values = { kind: String }
+
connect()
{
if (!ClipboardJS.isSupported()) {
@@ -18,6 +20,8 @@ export default class extends Controller
this.element.classList.add('copied');
setTimeout(() => this.element.classList.remove('copied'), 2000);
+
+ window.posthog?.capture('site:code_copy', { code_kind: this.kindValue });
});
}
-}
\ No newline at end of file
+}
diff --git a/web/landing/assets/controllers/code_editor_controller.js b/web/landing/assets/controllers/code_editor_controller.js
index e4dd636a96..84f8ffc666 100644
--- a/web/landing/assets/controllers/code_editor_controller.js
+++ b/web/landing/assets/controllers/code_editor_controller.js
@@ -1,6 +1,6 @@
import { Controller } from "@hotwired/stimulus"
import { EditorView, basicSetup } from "codemirror"
-import { EditorState, StateField, StateEffect, Compartment, Prec } from "@codemirror/state"
+import { EditorState, StateField, StateEffect, Compartment, Prec, Transaction } from "@codemirror/state"
import { Decoration } from "@codemirror/view"
import { keymap } from "@codemirror/view"
import { php } from "@codemirror/lang-php"
@@ -17,6 +17,7 @@ export default class extends Controller {
#textarea
#errorEffect
#editorReady = false
+ #codeModified = false
#themeCompartment = new Compartment()
#onThemeChanged = null
@@ -74,6 +75,10 @@ export default class extends Controller {
flowTooltips,
EditorView.updateListener.of((update) => {
if (update.docChanged) {
+ if (update.transactions.some(transaction => transaction.annotation(Transaction.userEvent) !== undefined)) {
+ this.#codeModified = true
+ }
+
this.#textarea.value = update.state.doc.toString()
this.dispatch('code-changed', { bubbles: true })
}
@@ -143,6 +148,10 @@ export default class extends Controller {
}
}
+ isCodeModified() {
+ return this.#codeModified
+ }
+
getCode() {
return this.#editor ? this.#editor.state.doc.toString() : ''
}
diff --git a/web/landing/assets/controllers/playground_controller.js b/web/landing/assets/controllers/playground_controller.js
index 3456eea4bf..ecab1499bd 100644
--- a/web/landing/assets/controllers/playground_controller.js
+++ b/web/landing/assets/controllers/playground_controller.js
@@ -1,5 +1,13 @@
import { Controller } from "@hotwired/stimulus"
+const POSTHOG_EVENTS = {
+ 'wasm:runtime-load': 'playground:runtime_load',
+ 'playground-run:code-run': 'playground:code_run',
+ 'playground-share:snippet-share': 'playground:snippet_share',
+ 'playground-share:snippet-open': 'playground:snippet_open',
+ 'playground-upload:file-upload': 'playground:file_upload',
+}
+
export default class extends Controller {
static outlets = ["wasm", "code-editor", "turnstile", "playground-output", "playground-tabs"]
static targets = ["loadingMessage", "loadingBar", "loadingPercent", "navigation", "editor", "outputContainer", "storageIndicator", "actionSpinner"]
@@ -13,6 +21,10 @@ export default class extends Controller {
this.#log('Connecting playground controller')
}
+ capture({ type, detail }) {
+ window.posthog?.capture(POSTHOG_EVENTS[type], detail)
+ }
+
onNotification(event) {
const { message, type } = event.detail
if (this.hasPlaygroundOutputOutlet) {
diff --git a/web/landing/assets/controllers/playground_run_controller.js b/web/landing/assets/controllers/playground_run_controller.js
index 708ecc4678..037b3ebb97 100644
--- a/web/landing/assets/controllers/playground_run_controller.js
+++ b/web/landing/assets/controllers/playground_run_controller.js
@@ -2,6 +2,7 @@ import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static outlets = ["code-editor", "wasm", "playground-output"]
+ static values = { isExample: { type: Boolean, default: false } }
async run() {
this.dispatch('action-started', { bubbles: true })
@@ -37,8 +38,14 @@ export default class extends Controller {
}
}
- this.dispatch('executed', {
- detail: { success: result.success, executionTime: result.executionTime },
+ this.dispatch('code-run', {
+ detail: {
+ is_success: result.success,
+ duration_ms: result.executionTime,
+ failure_reason: result.failureReason,
+ is_example: this.isExampleValue,
+ is_code_modified: this.codeEditorOutlet.isCodeModified()
+ },
bubbles: true
})
} finally {
diff --git a/web/landing/assets/controllers/playground_share_controller.js b/web/landing/assets/controllers/playground_share_controller.js
index caed0228d2..b6df965b13 100644
--- a/web/landing/assets/controllers/playground_share_controller.js
+++ b/web/landing/assets/controllers/playground_share_controller.js
@@ -14,8 +14,6 @@ export default class extends Controller {
#wasmResourcesLoaded = false
#pendingSnippetLoad = false
#defaultFingerprint = null
- #exampleCodeModified = false
- #boundHandleExampleLoaded = null
connect() {
this.#debug = this.application.debug
@@ -24,25 +22,12 @@ export default class extends Controller {
this.#boundHandleCodeChanged = this.#handleCodeChanged.bind(this)
this.element.addEventListener('code-editor:code-changed', this.#boundHandleCodeChanged)
-
- this.#boundHandleExampleLoaded = this.#handleExampleLoaded.bind(this)
- this.element.addEventListener('playground-storage:loaded-from-example', this.#boundHandleExampleLoaded)
}
disconnect() {
if (this.#boundHandleCodeChanged) {
this.element.removeEventListener('code-editor:code-changed', this.#boundHandleCodeChanged)
}
- if (this.#boundHandleExampleLoaded) {
- this.element.removeEventListener('playground-storage:loaded-from-example', this.#boundHandleExampleLoaded)
- }
- }
-
- #handleExampleLoaded() {
- // Reset the modified flag when example is initially loaded
- // This prevents the initial setCode() call from marking example as modified
- this.#exampleCodeModified = false
- this.#log('Example loaded, reset exampleCodeModified flag')
}
async onWasmResourcesLoaded() {
@@ -130,6 +115,8 @@ export default class extends Controller {
}
async #loadSnippetFromR2(snippetId) {
+ let failureReason = 'other'
+
try {
const snippetsBaseUrl = this.snippetsUrlValue
const baseUrl = `${snippetsBaseUrl}/snippets/${snippetId}`
@@ -139,6 +126,7 @@ export default class extends Controller {
const metadataResponse = await fetch(metadataUrl)
if (!metadataResponse.ok) {
+ failureReason = 'not_found'
throw new Error(`Snippet not found (HTTP ${metadataResponse.status})`)
}
@@ -146,12 +134,14 @@ export default class extends Controller {
const expiresAt = new Date(metadata.expires_at)
if (Date.now() > expiresAt.getTime()) {
+ failureReason = 'expired'
throw new Error('Snippet has expired')
}
const codeUrl = `${baseUrl}/code.php`
const codeResponse = await fetch(codeUrl)
if (!codeResponse.ok) {
+ failureReason = 'code_missing'
throw new Error('Code file not found')
}
const code = await codeResponse.text()
@@ -177,6 +167,7 @@ export default class extends Controller {
if (!this.wasmOutlet.areResourcesLoaded()) {
this.#showNotification('WASM resources failed to load, datasets not loaded', 'error')
+ this.#reportOpen(null)
return
}
this.#log('WASM resources loaded, proceeding with dataset upload')
@@ -233,8 +224,9 @@ export default class extends Controller {
this.#showNotification('Snippet loaded successfully!', 'success')
this.#snippetLoaded = true
-
+ this.#reportOpen(null)
} catch (error) {
+ this.#reportOpen(failureReason)
console.error('[ShareCode] Failed to load snippet:', error)
this.#showNotification(`Failed to load snippet: ${error.message}`, 'error')
}
@@ -243,6 +235,8 @@ export default class extends Controller {
async share() {
this.dispatch('action-started', { bubbles: true })
+ let files = []
+
try {
// First, wait only for code-editor and wasm (NOT turnstile yet)
await Promise.all([
@@ -250,13 +244,14 @@ export default class extends Controller {
this.wasmOutlet.onLoad()
])
- const files = await this.#collectUploadedFiles()
+ files = await this.#collectUploadedFiles()
// Check for unmodified example BEFORE requiring Turnstile
- if (this.isExampleValue && !this.#exampleCodeModified && files.length === 0) {
+ if (this.isExampleValue && !this.codeEditorOutlet.isCodeModified() && files.length === 0) {
const exampleUrl = `${window.location.origin}${window.location.pathname}`
await this.#copyToClipboard(exampleUrl)
this.#showNotification('Example link copied to clipboard!', 'success', exampleUrl)
+ this.#reportShare('example_link', files.length)
return
}
@@ -275,6 +270,7 @@ export default class extends Controller {
if (this.#defaultFingerprint && fingerprint === this.#defaultFingerprint) {
this.#log('Code matches default, not uploading')
this.#showNotification('You are trying to share default code. Please modify the code first.', 'info')
+ this.#reportShare('refused', files.length)
return
}
@@ -293,11 +289,14 @@ export default class extends Controller {
await this.#copyToClipboard(shareUrl)
this.#showNotification('Snippet already exists! Link copied to clipboard.', 'success', shareUrl)
+ this.#reportShare('exists', files.length)
return
}
await this.#uploadSnippetToAPI(code, fingerprint, files)
+ this.#reportShare('created', files.length)
} catch (error) {
+ this.#reportShare('failed', files.length)
console.error('[ShareCode] Share failed:', error)
console.error('[ShareCode] Error stack:', error.stack)
this.#logError('[ShareCode] Share failed:', error)
@@ -378,12 +377,18 @@ export default class extends Controller {
}
}
- #handleCodeChanged() {
- // Mark example as modified when code changes
- if (this.isExampleValue) {
- this.#exampleCodeModified = true
- }
+ #reportShare(outcome, fileCount) {
+ this.dispatch('snippet-share', { detail: { outcome, file_count: fileCount }, bubbles: true })
+ }
+ #reportOpen(failureReason) {
+ this.dispatch('snippet-open', {
+ detail: { is_success: failureReason === null, failure_reason: failureReason },
+ bubbles: true
+ })
+ }
+
+ #handleCodeChanged() {
if (this.#snippetLoaded) {
this.#log('Code changed, clearing snippet URL from browser')
const cleanUrl = `${window.location.origin}${window.location.pathname}`
diff --git a/web/landing/assets/controllers/playground_upload_controller.js b/web/landing/assets/controllers/playground_upload_controller.js
index db2c61d6f3..2a99a94b6d 100644
--- a/web/landing/assets/controllers/playground_upload_controller.js
+++ b/web/landing/assets/controllers/playground_upload_controller.js
@@ -27,6 +27,7 @@ export default class extends Controller {
const validation = this.#validate(file)
if (!validation.valid) {
this.playgroundOutputOutlet.show({ content: validation.error, type: 'error' })
+ this.#reportUpload(file, validation.failureReason)
return
}
@@ -42,6 +43,22 @@ export default class extends Controller {
this.playgroundOutputOutlet.show({ content: `File uploaded: ${file.name}`, type: 'success' })
this.dispatch('file-uploaded', { detail: { filename: file.name, size: file.size }, bubbles: true })
}
+
+ this.#reportUpload(file, result.success ? null : 'write')
+ }
+
+ #reportUpload(file, failureReason) {
+ const extension = file.name.split('.').pop().toLowerCase()
+
+ this.dispatch('file-upload', {
+ detail: {
+ is_success: failureReason === null,
+ file_extension: this.allowedExtensionsValue.includes(extension) ? extension : 'other',
+ file_size: file.size,
+ failure_reason: failureReason
+ },
+ bubbles: true
+ })
}
async handleFileUpload(event) {
@@ -96,16 +113,16 @@ export default class extends Controller {
#validate(file) {
const filenameCheck = this.#validateFilename(file.name)
if (!filenameCheck.valid) {
- return filenameCheck
+ return { ...filenameCheck, failureReason: 'filename' }
}
if (file.size > this.maxFileSizeValue) {
- return { valid: false, error: `File too large: ${file.name} (max 2MB)` }
+ return { valid: false, error: `File too large: ${file.name} (max 2MB)`, failureReason: 'size' }
}
const ext = file.name.split('.').pop().toLowerCase()
if (!this.allowedExtensionsValue.includes(ext)) {
- return { valid: false, error: `Invalid extension: ${ext}` }
+ return { valid: false, error: `Invalid extension: ${ext}`, failureReason: 'extension' }
}
return { valid: true }
diff --git a/web/landing/assets/controllers/playground_workspace_controller.js b/web/landing/assets/controllers/playground_workspace_controller.js
index 34de26e743..4033ae9851 100644
--- a/web/landing/assets/controllers/playground_workspace_controller.js
+++ b/web/landing/assets/controllers/playground_workspace_controller.js
@@ -103,7 +103,7 @@ export default class extends Controller {
return
}
- this.treeTarget.innerHTML = this.#renderFileTree(tree)
+ this.treeTarget.replaceChildren(this.#renderFileTree(tree))
this.#populateDropdown(tree)
this.#treeRendered = true
@@ -145,7 +145,8 @@ export default class extends Controller {
}
#renderFileTree(tree, level = 0) {
- let html = '
'
+ const list = document.createElement('ul')
+ list.className = 'file-tree'
const entries = Object.values(tree).sort((a, b) => {
if (a.type === 'directory' && b.type !== 'directory') return -1
@@ -154,33 +155,36 @@ export default class extends Controller {
})
for (const entry of entries) {
- const indent = level * 16
+ const isDirectory = entry.type === 'directory'
- if (entry.type === 'directory') {
- html += `
- -
-
- ${entry.name}
-
- `
-
- if (entry.children && Object.keys(entry.children).length > 0) {
- html += this.#renderFileTree(entry.children, level + 1)
- }
- } else {
- html += `
- -
-
- ${entry.name}
-
- `
+ const item = document.createElement('li')
+ item.className = isDirectory ? 'file-tree-item directory' : 'file-tree-item file clickable'
+ item.style.paddingLeft = `${level * 16}px`
+
+ if (!isDirectory) {
+ item.dataset.action = 'click->playground-tabs#openFile'
+ item.dataset.filePath = entry.path
+ }
+
+ const icon = document.createElement('img')
+ icon.src = isDirectory ? this.folderIconValue : this.fileIconValue
+ icon.className = 'icon'
+ icon.width = 16
+ icon.height = 16
+ icon.alt = ''
+
+ const name = document.createElement('span')
+ name.textContent = entry.name
+
+ item.append(icon, name)
+ list.append(item)
+
+ if (isDirectory && entry.children && Object.keys(entry.children).length > 0) {
+ list.append(this.#renderFileTree(entry.children, level + 1))
}
}
- html += '
'
- return html
+ return list
}
#updateSelectedState() {
diff --git a/web/landing/assets/controllers/site_search_controller.js b/web/landing/assets/controllers/site_search_controller.js
index 66334539e2..824fe7a5c3 100644
--- a/web/landing/assets/controllers/site_search_controller.js
+++ b/web/landing/assets/controllers/site_search_controller.js
@@ -1,19 +1,35 @@
import { Controller } from '@hotwired/stimulus';
+const queryOf = (term) => {
+ const trimmed = term.trim();
+
+ if (/\S+@\S+\.\S+/.test(trimmed) || /\S{16,}/.test(trimmed)) {
+ return null;
+ }
+
+ return trimmed.toLowerCase().slice(0, 64);
+};
+
export default class extends Controller {
static targets = ['mount'];
static values = { bundlePath: String };
- #ui = null;
+ #instance = null;
+ #term = '';
+ #count = 0;
+ #reported = false;
#onKey = null;
#onModalToggle = null;
+ #onResultClick = null;
async connect() {
this.#onKey = this.#handleKey.bind(this);
this.#onModalToggle = this.#handleModalToggle.bind(this);
+ this.#onResultClick = this.#handleResultClick.bind(this);
document.addEventListener('keydown', this.#onKey);
this.element.addEventListener('toggle', this.#onModalToggle);
+ this.mountTarget.addEventListener('click', this.#onResultClick);
}
disconnect() {
@@ -24,24 +40,47 @@ export default class extends Controller {
if (this.#onModalToggle) {
this.element.removeEventListener('toggle', this.#onModalToggle);
}
+
+ if (this.#onResultClick) {
+ this.mountTarget.removeEventListener('click', this.#onResultClick);
+ }
}
async #ensureUi() {
- if (this.#ui) return;
- if (!this.hasMountTarget) return;
-
- await import(this.bundlePathValue + 'pagefind-ui.js');
-
- // eslint-disable-next-line no-undef
- this.#ui = new PagefindUI({
- element: this.mountTarget,
- bundlePath: this.bundlePathValue,
- showSubResults: true,
- showImages: false,
- pageSize: 6,
- excerptLength: 24,
- resetStyles: false,
- translations: { placeholder: 'Search documentation...' },
+ if (this.#instance) return;
+
+ try {
+ await import(this.bundlePathValue + 'pagefind-component-ui.js');
+ } catch (error) {
+ console.error('[site-search] Pagefind failed to load', error);
+ }
+
+ if (!window.PagefindComponents) return;
+
+ this.#instance = window.PagefindComponents.getInstanceManager().getInstance('default');
+ this.#instance.on('search', (term) => { this.#term = term; }, this);
+ this.#instance.on('results', (result) => { this.#count = result.results.length; }, this);
+ }
+
+ #reportResultsView() {
+ if (this.#reported || !this.#term) return;
+
+ this.#reported = true;
+ window.posthog?.capture('search:results_view', {
+ search_query: queryOf(this.#term),
+ result_count: this.#count,
+ });
+ }
+
+ #handleResultClick(event) {
+ const result = event.target.closest('[data-pf-result-index]');
+
+ if (!result || !event.target.closest('a')) return;
+
+ this.#reportResultsView();
+ window.posthog?.capture('search:result_click', {
+ search_query: queryOf(this.#term),
+ result_position: Number(result.dataset.pfResultIndex) + 1,
});
}
@@ -58,13 +97,16 @@ export default class extends Controller {
}
async #handleModalToggle(event) {
- if (event.newState !== 'open') return;
+ if (event.newState !== 'open') {
+ this.#reportResultsView();
+
+ return;
+ }
+
+ this.#reported = false;
await this.#ensureUi();
- setTimeout(() => {
- const input = this.element.querySelector('.pagefind-ui__search-input');
- input?.focus();
- }, 50);
+ setTimeout(() => this.element.querySelector('pagefind-input')?.focus(), 50);
}
}
diff --git a/web/landing/assets/controllers/wasm_controller.js b/web/landing/assets/controllers/wasm_controller.js
index 651bb7d43b..6199632e59 100644
--- a/web/landing/assets/controllers/wasm_controller.js
+++ b/web/landing/assets/controllers/wasm_controller.js
@@ -15,6 +15,7 @@ export default class extends Controller {
#combinedOutput = ''
#debug = false
#recycleCount = 0
+ #runtimeLoadReported = false
connect() {
this.#debug = this.application.debug
@@ -66,10 +67,13 @@ export default class extends Controller {
this.#combinedOutput = ''
+ const startedAt = performance.now()
+
try {
this.#phpModule.FS.chdir('/workspace')
const exitCode = this.#phpModule.ccall('pib_eval', 'number', ['string'], [code])
+ const executionTime = Math.round(performance.now() - startedAt)
const errorInfo = this.#parseErrorMessage(this.#combinedOutput)
@@ -85,7 +89,8 @@ export default class extends Controller {
},
output: this.#combinedOutput,
exitCode,
- executionTime: 0,
+ executionTime,
+ failureReason: this.#runFailureReason(this.#combinedOutput),
memoryUsed: 0
}
}
@@ -94,7 +99,8 @@ export default class extends Controller {
success: true,
output: this.#combinedOutput || 'Code executed successfully (no output)',
exitCode,
- executionTime: 0,
+ executionTime,
+ failureReason: null,
memoryUsed: 0
}
} catch (e) {
@@ -107,7 +113,8 @@ export default class extends Controller {
},
output: this.#combinedOutput,
exitCode: 1,
- executionTime: 0,
+ executionTime: Math.round(performance.now() - startedAt),
+ failureReason: 'other',
memoryUsed: 0
}
}
@@ -362,6 +369,7 @@ export default class extends Controller {
return true
} catch (error) {
this.#logError('Failed to load resources:', error)
+ this.#reportRuntimeLoad('resources')
this.#dispatchError('Failed to load resources: ' + error.message)
return false
}
@@ -417,16 +425,19 @@ export default class extends Controller {
await this.#loadResources()
}).catch((err) => {
this.#logError('Failed to initialize PHP module:', err)
+ this.#reportRuntimeLoad('instantiate')
this.#dispatchError('Failed to initialize PHP: ' + err.message)
})
} else {
this.#logError('PHP function not available after script load')
+ this.#reportRuntimeLoad('runtime_missing')
this.#dispatchError('Failed to load PHP module')
}
}
script.onerror = (err) => {
this.#logError('Failed to load PHP script:', err)
+ this.#reportRuntimeLoad('script')
this.#dispatchError('Failed to load PHP WebAssembly module')
}
@@ -550,6 +561,32 @@ export default class extends Controller {
#dispatchInitialized() {
this.dispatch('initialized')
+ this.#reportRuntimeLoad(null)
+ }
+
+ #reportRuntimeLoad(failureReason) {
+ if (this.#runtimeLoadReported) {
+ return
+ }
+
+ this.#runtimeLoadReported = true
+ this.dispatch('runtime-load', {
+ detail: {
+ is_success: failureReason === null,
+ duration_ms: Math.round(performance.now()),
+ failure_reason: failureReason
+ }
+ })
+ }
+
+ #runFailureReason(output) {
+ const thrown = output.match(/Uncaught throwable '([^']+)'/)
+
+ if (!thrown || thrown[1] === 'ParseError') {
+ return 'parse'
+ }
+
+ return thrown[1].startsWith('Flow\\') ? 'flow' : 'php'
}
#dispatchResourcesLoaded() {
diff --git a/web/landing/assets/styles/app.css b/web/landing/assets/styles/app.css
index 8f06155d27..ef84d53b01 100644
--- a/web/landing/assets/styles/app.css
+++ b/web/landing/assets/styles/app.css
@@ -891,146 +891,32 @@ code {
}
}
-:root {
- --pagefind-ui-scale: 0.9;
- --pagefind-ui-primary: #B33D32;
- --pagefind-ui-text: #0f172a;
- --pagefind-ui-background: transparent;
- --pagefind-ui-border: #e2e8f0;
- --pagefind-ui-tag: #f1f5f9;
- --pagefind-ui-border-width: 1px;
- --pagefind-ui-border-radius: 0.5rem;
- --pagefind-ui-image-border-radius: 0.5rem;
- --pagefind-ui-image-box-ratio: 3 / 2;
- --pagefind-ui-font: 'Cabin Variable', system-ui, sans-serif;
-}
-
-[data-theme="dark"] {
- --pagefind-ui-primary: #ff5547;
- --pagefind-ui-text: rgba(255, 255, 255, 0.92);
- --pagefind-ui-border: rgba(255, 255, 255, 0.10);
- --pagefind-ui-tag: rgba(255, 255, 255, 0.06);
-}
-
-#site-search .pagefind-ui__search-input {
- background: #fff;
- color: #0f172a;
-}
-
-#site-search .pagefind-ui__search-input::placeholder {
- color: #94a3b8;
-}
-
-#site-search .pagefind-ui__result {
- border-bottom: 1px solid #e2e8f0;
-}
-
-#site-search .pagefind-ui__result-link {
- color: #0f172a;
-}
-
-#site-search .pagefind-ui__result-link:hover {
- color: #B33D32;
-}
-
-#site-search .pagefind-ui__result-excerpt {
- color: #475569;
-}
-
-#site-search mark {
- background: transparent;
- color: #B33D32;
- font-weight: 600;
-}
-
-#site-search .pagefind-ui__filter-panel,
-#site-search .pagefind-ui__filter-name,
-#site-search .pagefind-ui__filter-value {
- color: #334155;
-}
-
-#site-search .pagefind-ui__filter-name {
- font-weight: 600;
- text-transform: uppercase;
- letter-spacing: 0.08em;
- font-size: 0.75rem;
- color: #64748b;
-}
-
-#site-search .pagefind-ui__filter-value input[type="checkbox"] {
- accent-color: #ff5547;
-}
-
-#site-search .pagefind-ui__message {
- color: #64748b;
-}
-
-#site-search .pagefind-ui__search-clear {
- background: transparent;
- border: 1px solid #cbd5e1;
- color: #475569;
- font-size: 0.75rem;
- padding: 0.35rem 0.6rem;
- border-radius: 0.375rem;
- transition: border-color 120ms, background 120ms, color 120ms;
-}
-
-#site-search .pagefind-ui__search-clear:hover {
- background: #f1f5f9;
- border-color: #94a3b8;
- color: #0f172a;
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__search-input {
- background: rgba(255, 255, 255, 0.04);
- color: rgba(255, 255, 255, 0.92);
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__search-input::placeholder {
- color: rgba(255, 255, 255, 0.45);
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__result {
- border-bottom: 1px solid rgba(255, 255, 255, 0.08);
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__result-link {
- color: #fff;
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__result-link:hover {
- color: #ff5547;
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__result-excerpt {
- color: rgba(255, 255, 255, 0.70);
-}
-
-[data-theme="dark"] #site-search mark {
- color: #ff5547;
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__filter-panel,
-[data-theme="dark"] #site-search .pagefind-ui__filter-name,
-[data-theme="dark"] #site-search .pagefind-ui__filter-value {
- color: rgba(255, 255, 255, 0.85);
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__filter-name {
- color: rgba(255, 255, 255, 0.55);
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__message {
- color: rgba(255, 255, 255, 0.65);
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__search-clear {
- border: 1px solid rgba(255, 255, 255, 0.10);
- color: rgba(255, 255, 255, 0.70);
-}
-
-[data-theme="dark"] #site-search .pagefind-ui__search-clear:hover {
- background: rgba(255, 255, 255, 0.06);
- border-color: rgba(255, 255, 255, 0.20);
- color: #fff;
+#site-search {
+ --pf-text: #0f172a;
+ --pf-text-secondary: #475569;
+ --pf-text-muted: #64748b;
+ --pf-background: #fff;
+ --pf-border: #e2e8f0;
+ --pf-border-focus: #94a3b8;
+ --pf-skeleton: #f1f5f9;
+ --pf-skeleton-shine: #f8fafc;
+ --pf-hover: #f1f5f9;
+ --pf-mark: #B33D32;
+ --pf-outline-focus: #B33D32;
+ --pf-border-radius: 0.5rem;
+ --pf-font: 'Cabin Variable', system-ui, sans-serif;
+}
+
+[data-theme="dark"] #site-search {
+ --pf-text: rgba(255, 255, 255, 0.92);
+ --pf-text-secondary: rgba(255, 255, 255, 0.70);
+ --pf-text-muted: rgba(255, 255, 255, 0.55);
+ --pf-background: rgba(255, 255, 255, 0.04);
+ --pf-border: rgba(255, 255, 255, 0.10);
+ --pf-border-focus: rgba(255, 255, 255, 0.20);
+ --pf-skeleton: rgba(255, 255, 255, 0.06);
+ --pf-skeleton-shine: rgba(255, 255, 255, 0.10);
+ --pf-hover: rgba(255, 255, 255, 0.06);
+ --pf-mark: #ff5547;
+ --pf-outline-focus: #ff5547;
}
diff --git a/web/landing/src/Flow/Website/Controller/HomeController.php b/web/landing/src/Flow/Website/Controller/HomeController.php
index d88781bad3..3373fd6325 100644
--- a/web/landing/src/Flow/Website/Controller/HomeController.php
+++ b/web/landing/src/Flow/Website/Controller/HomeController.php
@@ -23,6 +23,18 @@ public function home(): Response
]);
}
+ #[Route('/404.html', name: 'not_found', options: ['sitemap' => false])]
+ public function notFound(): Response
+ {
+ return $this->render('main/not_found.html.twig', []);
+ }
+
+ #[Route('/posthog.js', name: 'posthog_loader', options: ['sitemap' => false])]
+ public function posthogLoader(): Response
+ {
+ return $this->render('main/posthog.js.twig', [], new Response(headers: ['Content-Type' => 'text/javascript']));
+ }
+
#[Route('/sponsor', name: 'sponsor', options: ['sitemap' => false])]
public function sponsor(): Response
{
diff --git a/web/landing/src/Flow/Website/Service/Markdown/FlowCodeRenderer.php b/web/landing/src/Flow/Website/Service/Markdown/FlowCodeRenderer.php
index 1f7b92ecdc..9b03fbf709 100644
--- a/web/landing/src/Flow/Website/Service/Markdown/FlowCodeRenderer.php
+++ b/web/landing/src/Flow/Website/Service/Markdown/FlowCodeRenderer.php
@@ -10,6 +10,7 @@
use League\CommonMark\Renderer\ChildNodeRendererInterface;
use League\CommonMark\Renderer\NodeRendererInterface;
use League\CommonMark\Util\HtmlElement;
+use Symfony\Component\Asset\Packages;
use function array_key_exists;
use function Flow\Types\DSL\type_boolean;
@@ -20,6 +21,10 @@
class FlowCodeRenderer implements NodeRendererInterface
{
+ public function __construct(
+ private readonly Packages $packages,
+ ) {}
+
public function render(Node $node, ChildNodeRendererInterface $childRenderer)
{
if (!$node instanceof FencedCode) {
@@ -39,13 +44,39 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer)
? type_string()->assert($attrs['class']) . ' ' . $class
: $class;
- // Escape the code content
- $escapedContent = htmlspecialchars($node->getLiteral(), ENT_NOQUOTES, 'UTF-8');
-
- // Render as content
- $codeElement = new HtmlElement('code', $attrs, $escapedContent);
+ $codeId = 'code-' . substr(hash('xxh3', $node->getLiteral()), 0, 12);
- // Render as content
- return new HtmlElement('pre', array_merge($attrs, ['data-controller' => 'syntax-highlight']), $codeElement);
+ return new HtmlElement(
+ 'div',
+ ['class' => 'relative'],
+ [
+ new HtmlElement(
+ 'button',
+ [
+ 'class' => "absolute top-3 right-3 inline-flex items-center justify-center h-9 w-9 rounded-md border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 [&.copied]:before:content-['Copied!'] before:absolute before:-translate-x-20 dark:border-white/10 dark:bg-black/60 dark:hover:bg-black/80 dark:text-white",
+ 'data-controller' => 'clipboard',
+ 'data-clipboard-kind-value' => 'documentation',
+ 'data-clipboard-target' => '#' . $codeId,
+ 'aria-label' => 'Copy code',
+ ],
+ new HtmlElement(
+ 'img',
+ [
+ 'src' => $this->packages->getUrl('images/icons/copy.svg'),
+ 'alt' => '',
+ 'width' => '16',
+ 'height' => '16',
+ 'class' => 'dark:invert-0 invert',
+ ],
+ selfClosing: true,
+ ),
+ ),
+ new HtmlElement(
+ 'pre',
+ array_merge($attrs, ['id' => $codeId, 'data-controller' => 'syntax-highlight']),
+ new HtmlElement('code', $attrs, htmlspecialchars($node->getLiteral(), ENT_NOQUOTES, 'UTF-8')),
+ ),
+ ],
+ );
}
}
diff --git a/web/landing/src/Flow/Website/Service/Markdown/LeagueCommonMarkConverterFactory.php b/web/landing/src/Flow/Website/Service/Markdown/LeagueCommonMarkConverterFactory.php
index 25d4fa3587..4c02ddfde5 100644
--- a/web/landing/src/Flow/Website/Service/Markdown/LeagueCommonMarkConverterFactory.php
+++ b/web/landing/src/Flow/Website/Service/Markdown/LeagueCommonMarkConverterFactory.php
@@ -78,7 +78,7 @@ public function __invoke(): CommonMarkConverter
->addExtension(new MentionExtension())
->addExtension(new TableExtension())
->addRenderer(FencedCode::class, new MermaidCodeRenderer($this->packages), 100)
- ->addRenderer(FencedCode::class, new FlowCodeRenderer(), 0)
+ ->addRenderer(FencedCode::class, new FlowCodeRenderer($this->packages), 0)
->addRenderer(Link::class, new FlowLinkRenderer(), 0)
->addRenderer(TableOfContents::class, new TableOfContentsRenderer(), 10)
->addEventListener(
diff --git a/web/landing/templates/base.html.twig b/web/landing/templates/base.html.twig
index c68b3d373a..95b3836ada 100644
--- a/web/landing/templates/base.html.twig
+++ b/web/landing/templates/base.html.twig
@@ -54,21 +54,11 @@
{% block stylesheets %}
-
+
{% endblock %}
{% block tracking %}
- {% if posthog_key|length %}
-
- {% endif %}
+
{% endblock %}
{% block javascripts %}
diff --git a/web/landing/templates/documentation/dsl/function.html.twig b/web/landing/templates/documentation/dsl/function.html.twig
index 470c0383e7..6cf16edb32 100644
--- a/web/landing/templates/documentation/dsl/function.html.twig
+++ b/web/landing/templates/documentation/dsl/function.html.twig
@@ -92,7 +92,7 @@
title="copy code"
aria-label="Copy code"
data-clipboard-target="#example-code-{{ loop.index }}"
- {{ stimulus_controller('clipboard') }}>
+ {{ stimulus_controller('clipboard', { kind: 'dsl_function' }) }}>
diff --git a/web/landing/templates/documentation/example.html.twig b/web/landing/templates/documentation/example.html.twig
index 5e82fa080e..113d7623ef 100644
--- a/web/landing/templates/documentation/example.html.twig
+++ b/web/landing/templates/documentation/example.html.twig
@@ -71,10 +71,10 @@
- {{- code | escape('html') -}}
+ {{- code | escape('html') -}}
{% endapply %}
diff --git a/web/landing/templates/example/index.html.twig b/web/landing/templates/example/index.html.twig
index f442c7970d..09507e9b3b 100644
--- a/web/landing/templates/example/index.html.twig
+++ b/web/landing/templates/example/index.html.twig
@@ -98,6 +98,7 @@
-
-
+
+
{{- code | escape('html') -}}
diff --git a/web/landing/templates/main/_hero.html.twig b/web/landing/templates/main/_hero.html.twig
index 264c2a9a84..fbb7f04004 100644
--- a/web/landing/templates/main/_hero.html.twig
+++ b/web/landing/templates/main/_hero.html.twig
@@ -1,4 +1,4 @@
-
+
@@ -19,11 +19,11 @@
-
+
Try Playground
-
+
Read the docs
→
@@ -38,10 +38,12 @@
title="copy command"
aria-label="Copy install command"
data-clipboard-target="#command"
- {{ stimulus_controller('clipboard') }}>
+ {{ stimulus_controller('clipboard', { kind: 'install_command' }) }}>
+
View on Packagist
diff --git a/web/landing/templates/main/index.html.twig b/web/landing/templates/main/index.html.twig
index 4d833fdb52..7f3b8c51a5 100644
--- a/web/landing/templates/main/index.html.twig
+++ b/web/landing/templates/main/index.html.twig
@@ -203,11 +203,11 @@ data_frame()
diff --git a/web/landing/templates/main/not_found.html.twig b/web/landing/templates/main/not_found.html.twig
new file mode 100644
index 0000000000..f91dbe107c
--- /dev/null
+++ b/web/landing/templates/main/not_found.html.twig
@@ -0,0 +1,54 @@
+{% extends 'base.html.twig' %}
+
+{%- block title -%}
+ Page not found - Flow PHP - Data Processing Framework
+{%- endblock -%}
+
+{%- block description -%}
+ The page you are looking for does not exist. Search the Flow PHP documentation or browse the examples.
+{%- endblock -%}
+
+{% block stylesheets %}
+ {{ parent() }}
+
+{% endblock %}
+
+{%- block hero -%}{%- endblock -%}
+
+{%- block contributors -%}{%- endblock -%}
+
+{% block main %}
+
+
+
+
+ 404
+
+
+ Page not found.
+
+
+ The page you are looking for does not exist, or it moved.
+ Search the documentation, or start from the docs or the examples.
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/web/landing/templates/main/posthog.js.twig b/web/landing/templates/main/posthog.js.twig
new file mode 100644
index 0000000000..e15f7fffc4
--- /dev/null
+++ b/web/landing/templates/main/posthog.js.twig
@@ -0,0 +1,9 @@
+{% if posthog_key|length %}
+!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init capture register register_once register_for_session unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group identify setPersonProperties setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags resetGroups onFeatureFlags addFeatureFlagsHandler onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey getNextSurveyStep".split(" "),n=0;n
+