Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SEQUENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ sequenceDiagram

## Notes
- TSJS
- Served first-party at `/static/tsjs-core.min.js` (and `/static/tsjs-ext.min.js` if prebid auto-config is enabled).
- Served first-party at `/static/tsjs=tsjs-unified.min.js?v=<hash>`. The server dynamically concatenates core + enabled integration modules based on config.
- Discovers ad units and renders placeholders; either uses slot-level HTML (`/first-party/ad`) or JSON auction (`/auction`).
- Publisher HTML Rewriting
- Injects TSJS loader and rewrites absolute URLs from origin domain to first-party domain during streaming.
Expand Down
10 changes: 5 additions & 5 deletions crates/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ Helpers:
- `rewrite_srcset(settings, srcset) -> String` — proxy absolute candidates; preserve descriptors (`1x`, `1.5x`, `100w`)
- `split_srcset_candidates(srcset) -> Vec<&str>` — robust splitting for commas with/without spaces; avoids splitting the first `data:` mediatype comma

Static bundles (served by publisher module):
JS bundles (served by publisher module):

- Unified dynamic endpoint: `/static/tsjs=<filename>`
- `tsjs-core(.min).js` — core library
- `tsjs-ext(.min).js` — Prebid.js shim/extension
- `tsjs-creative(.min).js` — creative click‑guard injected into proxied creatives
- Dynamic endpoint: `/static/tsjs=tsjs-unified.min.js?v=<hash>`
- At build time, each integration is compiled as a separate IIFE (`tsjs-core.js`, `tsjs-prebid.js`, `tsjs-creative.js`, etc.)
- At runtime, the server concatenates `tsjs-core.js` + enabled integration modules based on `IntegrationRegistry` config
- The URL filename is fixed for backward compatibility; the `?v=` hash changes when modules change

Behavior is covered by an extensive test suite in `crates/common/src/creative.rs`.

Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/creative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ pub fn rewrite_creative_html(settings: &Settings, markup: &str) -> String {
let injected = injected_ts_creative.clone();
move |el| {
if !injected.get() {
let script_tag = tsjs::unified_script_tag();
let script_tag = tsjs::tsjs_script_tag_all();
el.prepend(&script_tag, ContentType::Html);
injected.set(true);
}
Expand Down
18 changes: 10 additions & 8 deletions crates/common/src/html_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,15 @@ pub fn create_html_processor(config: HtmlProcessorConfig) -> impl StreamProcesso
origin_host: &patterns.origin_host,
document_state: &document_state,
};
// First inject the unified TSJS bundle (defines tsjs.setConfig, etc.)
snippet.push_str(&tsjs::unified_script_tag());
// Then add any integration-specific head inserts (e.g., mode config)
// These run after the bundle so tsjs API is available
// First inject integration-specific config (e.g., window.__tsjs_prebid)
// so it's available when the bundle's auto-init code reads it.
for insert in integrations.head_inserts(&ctx) {
snippet.push_str(&insert);
}
// Then inject the TSJS bundle — its top-level init code can now
// read the config that was set by the inline scripts above.
let module_ids = integrations.js_module_ids();
snippet.push_str(&tsjs::tsjs_script_tag(&module_ids));
el.prepend(&snippet, ContentType::Html);
injected_tsjs.set(true);
}
Expand Down Expand Up @@ -607,12 +609,12 @@ mod tests {
.expect("should keep existing head content");

assert!(
tsjs_index < head_index,
"should inject head snippet after tsjs tag"
head_index < tsjs_index,
"should inject config before tsjs bundle so auto-init can read it"
);
assert!(
head_index < title_index,
"should prepend head snippet before existing head content"
tsjs_index < title_index,
"should prepend all injected content before existing head content"
);
}

Expand Down
Loading