handler-playable-sdk 0.3.8 → 0.3.10
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/README.md +19 -1
- package/dist/AssetTextures-CWUQXU5Q.js +1 -0
- package/dist/{ConfigOverride-DFTDUTRQ.js → ConfigOverride-C26KK6X2.js} +1 -1
- package/dist/chunk-I5OOVR5U.js +1 -0
- package/dist/chunk-JI2DLZF4.js +1398 -0
- package/dist/chunk-LV4HGC5G.js +1 -0
- package/dist/chunk-ZLL42OOV.js +1 -0
- package/dist/{config-7DI6U2YD.js → config-44AFSRES.js} +1 -1
- package/dist/index.cjs +124 -51
- package/dist/index.d.cts +29 -5
- package/dist/index.d.ts +29 -5
- package/dist/index.js +1 -1
- package/dist/{loader-object-centric-Ce6MVkQw.d.cts → loader-object-centric-BeVsUAXI.d.cts} +4 -0
- package/dist/{loader-object-centric-Ce6MVkQw.d.ts → loader-object-centric-BeVsUAXI.d.ts} +4 -0
- package/dist/pixi/index.cjs +17 -17
- package/dist/pixi/index.d.cts +41 -2
- package/dist/pixi/index.d.ts +41 -2
- package/dist/pixi/index.js +1 -1
- package/dist/three/index.cjs +36 -36
- package/dist/three/index.js +1 -1
- package/package.json +1 -1
- package/dist/AssetTextures-NWHSMZNV.js +0 -1
- package/dist/chunk-BC5GBAMY.js +0 -1325
- package/dist/chunk-DHSGG7NF.js +0 -1
- package/dist/chunk-J2CL6VOZ.js +0 -1
- package/dist/chunk-PWGHKK3J.js +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Contract-aligned Handler Playable SDK v0.1. Surface is fixed: `init`, `getRoot`,
|
|
|
4
4
|
|
|
5
5
|
## API (v0.1)
|
|
6
6
|
|
|
7
|
-
- `Handler.init({ root?, ids, profile, consent })`: creates or adopts a single root. `ids` must include mechanic_id, variant_id, deployment_id, export_id, profile_id, instance_id (instance default
|
|
7
|
+
- `Handler.init({ root?, ids, profile, consent })`: creates or adopts a single root. `ids` must include mechanic_id, variant_id, deployment_id, export_id, profile_id, instance_id (instance default "default" only allowed in dev). Consent/telemetry pulled from export profile.
|
|
8
8
|
- `Handler.getRoot()`: returns the sandbox root element.
|
|
9
9
|
- `Handler.on(name, cb)`, `Handler.off(name, cb)`: subscribe/unsubscribe to canonical events or custom namespaced ones.
|
|
10
10
|
- `Handler.start()`, `Handler.finish()`: lifecycle markers.
|
|
@@ -13,6 +13,24 @@ Contract-aligned Handler Playable SDK v0.1. Surface is fixed: `init`, `getRoot`,
|
|
|
13
13
|
|
|
14
14
|
Canonical event mapping from Smoud: `interaction -> engagement`, `finish -> complete`, `install -> cta_click (+conversion policy)`, `pause/resume/resize/volume` mapped 1:1 inside the envelope. Custom events must use `custom.<mechanic_id>.<event>`.
|
|
15
15
|
|
|
16
|
+
## Vite Configuration (Required)
|
|
17
|
+
|
|
18
|
+
When using this SDK with Vite, you **must** exclude it from dependency pre-bundling. The SDK uses code protection that is incompatible with Vite's optimization process.
|
|
19
|
+
|
|
20
|
+
Add this to your `vite.config.ts`:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
// ... your other config
|
|
25
|
+
optimizeDeps: {
|
|
26
|
+
include: ['pixi.js', 'lottie-web'],
|
|
27
|
+
exclude: ['handler-playable-sdk'] // Required!
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> ⚠️ **Important:** Without this configuration, the page may hang or fail to load. This is because Vite's pre-bundling modifies the code structure, which triggers the SDK's anti-tampering protection.
|
|
33
|
+
|
|
16
34
|
## Build
|
|
17
35
|
|
|
18
36
|
```bash
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as a,e as b}from"./chunk-I5OOVR5U.js";import"./chunk-Q7FPWOA3.js";export{a as AssetTextures,b as initAssetTextures};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-ZLL42OOV.js";import"./chunk-Q7FPWOA3.js";export{c as applyConfigOverride,d as applyConfigOverrides,m as applyConfigsToDisk,e as clearConfigOverrides,f as clearConfigOverridesForObject,i as configOverrideManager,j as deepClone,k as exportConfigsAsJSON,h as getConfigOverrides,l as getConfigStateSummary,a as getOverrideMode,g as removeConfigOverride,n as resetToApplied,o as resetToOriginal,b as setOverrideMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Assets as m,Texture as v}from"pixi.js";var g=class{static get(e){var s;return(s=this.store.get(e))==null?void 0:s.data}static set(e,s){this.store.set(e,{data:s})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};g.store=new Map;function $(){var t,e;try{let s=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(t=document.querySelector("script"))==null?void 0:t.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),i=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(s&&!i)}catch{return!1}}async function O(){try{if(typeof window!="undefined"){let t=await fetch("./build-settings.json");if(t.ok){let e=await t.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function _(){try{if(typeof window!="undefined"){let t=new XMLHttpRequest;if(t.open("GET","./build-settings.json",!1),t.send(),t.status===200&&t.responseText){let e=JSON.parse(t.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}var T=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",I=$(),A=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,l=I?"publish":T,y=A==null?void 0:A.assetsInlined;A!=null&&A.buildMode&&(l=A.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${l}`));var w=_();w!=null&&w.buildMode&&(l=w.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${l}`));(w==null?void 0:w.assetsInlined)!==void 0&&(y=w.assetsInlined);O().then(t=>{t!=null&&t.buildMode&&t.buildMode!==l&&(l=t.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${l}`)),(t==null?void 0:t.assetsInlined)!==void 0&&(y=t.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${T}, Runtime: ${I?"publish":"dev"}, Effective: ${l}`);var p={},L=null;async function R(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${l}`),Object.keys(p).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(p)),p;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),p={...window.INLINE_ASSETS},p;if(!(l==="publish"&&y!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),p;if(!L){let e=typeof window!="undefined"?new URL("inline-assets.js",window.location.href).href:"./inline-assets.js";console.log("[AssetLoader] Loading inline assets from:",e),L=(async()=>{try{try{let o=await import(e+"?t="+Date.now());if(o.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(o.INLINE_ASSETS)),o.INLINE_ASSETS}catch(o){console.warn("[AssetLoader] ES module import failed, trying text parse:",o)}let s=await fetch(e);if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let i=await s.text();console.log("[AssetLoader] Received JS code, length:",i.length);let r=i.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(r)try{let o=r[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let a=new Function("return "+o)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(a)),a}catch(o){return console.warn("[AssetLoader] Failed to parse inline assets:",o),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",i.substring(0,500)),{}}catch(s){return console.warn("[AssetLoader] Failed to load inline assets:",s),{}}})()}return p=await L,console.log("[AssetLoader] Final inline assets cache:",Object.keys(p)),p}var x=new Map;function E(t){return t===null||typeof t!="object"||(Object.freeze(t),Object.values(t).forEach(e=>E(e))),t}function B(t=64,e=64,s=16711680){let i=document.createElement("canvas");i.width=t,i.height=e;let r=i.getContext("2d");return r.fillStyle=`#${s.toString(16).padStart(6,"0")}`,r.fillRect(0,0,t,e),r.strokeStyle="#000",r.strokeRect(0,0,t,e),r.fillStyle="#fff",r.font="10px sans-serif",r.textAlign="center",r.fillText("MISSING",t/2,e/2),v.from(i)}function N(t,e){x.set(t,e)}var S=class{static async load(e,s,i,r){let o=`${e}:${s.path}`,a=g.get(o);if(a!==void 0)return a;console.log(`[AssetLoader] Loading asset: ${e}, type: ${s.type}, Effective mode: ${l}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let n=await R(),c=n[e];if(!c&&r&&(c=n[r],c&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${r}`)),!c&&s.path){let d=s.path.split("/");if(d.length>=2){let f=d[d.length-1].split(".")[0];n[f]&&(c=n[f],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${f}`))}}if(console.log("[AssetLoader] Inline data for",e,":",c?"FOUND":"NOT FOUND"),l==="publish"&&y!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!c))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${s.path}`);let h=x.get(s.type);if(h)try{let d=await h(s.path,c,e,i);return g.set(o,d),d}catch(d){return this.handleFailure(e,s.type,d)}try{let d;switch(s.type){case"image":d=await this.loadImage(s.path,c);break;case"json":d=await this.loadJSON(s.path,c),d=E(d);break;default:throw new Error(`Unknown asset type: ${s.type}`)}return g.set(o,d),d}catch(d){return this.handleFailure(e,s.type,d)}}static async loadImage(e,s){let i=l==="publish",r=i&&y!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${l}, isPublishMode: ${i}, inlineData: ${s?"EXISTS":"MISSING"}`),r){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!s)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof s!="string"||!s.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof s}`);try{return await m.load(s)}catch(o){throw console.error("[AssetLoader] Failed to load texture from data URI:",o),o}}if(s&&typeof s=="string"&&s.startsWith("data:"))try{return await m.load(s)}catch(o){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",o),await m.load(e)}return await m.load(e)}static async loadJSON(e,s){let i=l==="publish",r=i&&y!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${l}, isPublishMode: ${i}, inlineData: ${s?"EXISTS":"MISSING"}`),r){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!s)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof s=="object"&&s!==null)return s;if(typeof s=="string"&&s.startsWith("data:")){let a=atob(s.split(",")[1]);return JSON.parse(a)}return JSON.parse(s)}if(s){if(typeof s=="object"&&s!==null)return s;if(typeof s=="string"&&s.startsWith("data:")){let a=atob(s.split(",")[1]);return JSON.parse(a)}return JSON.parse(s)}let o=await fetch(e);if(!o.ok)throw new Error(`JSON fetch failed: ${e}`);return o.json()}static handleFailure(e,s,i){if(l==="dev"){let o=s==="image"?B():E({__placeholder:!0,type:s});return g.set(e+":"+((i==null?void 0:i.path)||"missing"),o),o}throw i}};N("image",async(t,e)=>{let s=l==="publish",i=s&&y!==!1,r=l==="brand",o=s&&y===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${l}, isPublishMode: ${s}, isBrandMode: ${r}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return m.load(e)}let a=t;return(r||o)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(a=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(a=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${a}"`))),m.load(e||a)});N("json",async(t,e)=>{let s=l==="publish",i=s&&y!==!1,r=l==="brand",o=s&&y===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${l}, isPublishMode: ${s}, isBrandMode: ${r}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let a=t;if((r||o)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(a=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(a=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${a}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let n=await fetch(a);if(!n.ok)throw new Error(`JSON fetch failed: ${t}`);return n.json()});var b=class{constructor(){this.textures=new Map;this.readyPromise=null;this.priorityReadyPromise=null;this.priorityReadyResolve=null;this.config=null;this.app=null;this.attempted=new Set;this.waiters=new Set}init(e,s){if(this.config===e&&this.app===s&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.attempted.clear(),this.waiters.clear(),this.priorityReadyPromise=new Promise(i=>{this.priorityReadyResolve=i}),this.config=e,this.app=s,console.log("[AssetTextures] Initialized with config, cleared previous textures")}async ready(){if(this.readyPromise){await this.readyPromise;return}if(!this.config)throw new Error("[AssetTextures] Must call init() before ready() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before ready() - app is null");let e=this.config,s=this.app;return this.readyPromise=(async()=>{var a;console.log("[AssetTextures] Loading all assets...");let i=new Set(["background_loading_1"]),r=[],o=[];for(let[n,c]of e.objects.entries()){let u=(a=c.render)==null?void 0:a.asset;if(!u)continue;let h=async()=>{var d;try{let f=(d=c.identity)==null?void 0:d.id;console.log(`[AssetTextures] Loading ${u.type}: ${n} (${f})`);let M=await S.load(n,u,s,f);this.textures.set(n,M),console.log(`[AssetTextures] \u2713 Loaded: ${n}`)}catch(f){console.error(`[AssetTextures] \u2717 Failed to load: ${n}`,f)}finally{this.attempted.add(n);try{for(let f of Array.from(this.waiters))f()}catch{}}};i.has(n)?r.push(h()):o.push(h())}r.length>0&&(console.log("[AssetTextures] Phase 1: Loading priority assets (loading screen)..."),await Promise.all(r),console.log("[AssetTextures] Phase 1: Priority assets ready")),this.priorityReadyResolve&&this.priorityReadyResolve(),console.log("[AssetTextures] Phase 2: Loading remaining assets..."),await Promise.all(o),console.log("[AssetTextures] All textures loaded:",Array.from(this.textures.keys()))})(),this.readyPromise}async priorityReady(){return this.priorityReadyPromise?this.priorityReadyPromise:Promise.resolve()}async waitFor(e,s={}){if(!this.config)throw new Error("[AssetTextures] Must call init() before waitFor() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before waitFor() - app is null");let r=Array.from(new Set((e||[]).filter(n=>typeof n=="string"&&n))).filter(n=>{var c,u,h,d;try{let f=(h=(u=(c=this.config)==null?void 0:c.objects)==null?void 0:u.get)==null?void 0:h.call(u,n);return!!((d=f==null?void 0:f.render)!=null&&d.asset)}catch{return!1}});if(r.length===0)return;this.ready().catch(()=>{});let o=()=>r.every(n=>this.textures.has(n)||this.attempted.has(n));if(o())return;let a=typeof s.timeoutMs=="number"?s.timeoutMs:15e3;await new Promise(n=>{let c=!1,u=()=>{c||o()&&(c=!0,this.waiters.delete(u),n())};this.waiters.add(u),u(),a>0&&setTimeout(()=>{c||(c=!0,this.waiters.delete(u),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:r}),n())},a)})}get(e){return this.textures.get(e)}set(e,s){this.textures.set(e,s),console.log(`[AssetTextures] Updated texture: ${e}`)}clear(){this.textures.clear(),this.readyPromise=null,console.log("[AssetTextures] Cleared all textures")}getAllIds(){return Array.from(this.textures.keys())}},P=new b,k=new Proxy(P,{get(t,e){return e in t&&typeof t[e]=="function"?t[e].bind(t):t.get(e)},set(t,e,s){return t.set(e,s),!0}});function J(t,e){P.init(t,e),typeof window!="undefined"&&(window.__AssetTextures=k)}export{g as a,N as b,S as c,k as d,J as e};
|