@altertable/data-app-worker 0.72.0 → 0.73.0
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 +1 -2
- package/dist/index.js +9 -9
- package/dist/index.js.map +5 -5
- package/dist/types/index.d.ts +8 -5
- package/package.json +4 -3
- package/dist/types/trusted-parent.d.ts +0 -1
package/README.md
CHANGED
|
@@ -25,8 +25,7 @@ Upload `workerScript` as the deployment's main module. Configure the string
|
|
|
25
25
|
bindings `DOMAIN_NAME` (runtime domain) and `PARENT_ORIGINS` (trusted host origins),
|
|
26
26
|
plus your deployment's domains and routes.
|
|
27
27
|
|
|
28
|
-
The
|
|
29
|
-
The deployed Worker requires no React or Bun. Data queries go through the host's
|
|
28
|
+
The asset includes its bootstrap and HTML. Data queries go through the host's
|
|
30
29
|
authorized message router.
|
|
31
30
|
|
|
32
31
|
## Documentation
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// packages/data-app-embed/dist/
|
|
2
|
-
var
|
|
3
|
-
var inlineBootstrap = '(()=>{function pe(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&Number.isFinite(e)}function G(e){return!!e&&typeof e==="object"&&!Array.isArray(e)&&Object.values(e).every(pe)}var Ee=Symbol("data-app.dimensionSource");var H=Symbol.for("@altertable/data-app/MessageRoutingError");class I extends Error{code;requestId;[H]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[H]===!0}constructor(e,n,t,r){super(n,r);this.code=e,this.requestId=t,this.name="MessageRoutingError"}}function fe(e){return e}function C(e){return{operations:e,input(n){if(!n||typeof n!=="object")throw Error("Invalid query.");let t=n;if(typeof t.operation!=="string"||!t.operation||t.operation.length>256||t.operation.includes("/"))throw Error("Invalid operation.");let r=e&&Object.hasOwn(e,t.operation)?e[t.operation]:void 0;if(e&&!r)throw Error("Unknown operation.");return{operation:t.operation,input:r?r.input(t.input):t.input}},output(n){if(!n||typeof n!=="object")throw Error("Invalid data response.");let t=n;if(!Number.isInteger(t.status)||t.status<100||t.status>599||!t.body||typeof t.body!=="object"||Array.isArray(t.body))throw Error("Invalid data response.");let r=t.body;if(t.status<200||t.status>=300){let o=r.error;throw new I(typeof o?.code==="string"?o.code:"request_failed",typeof o?.message==="string"?o.message:"Could not load data.",typeof o?.requestId==="string"?o.requestId:void 0)}if(!("data"in r)||typeof r.requestId!=="string"||typeof r.queriedAt!=="string"||!Array.isArray(r.queryIds)||!r.queryIds.every((o)=>typeof o==="string"))throw Error("Invalid data envelope.");if(r.queries!==void 0&&(!Array.isArray(r.queries)||!r.queries.every((o)=>o&&typeof o==="object"&&typeof o.name==="string"&&typeof o.statement==="string"&&(o.params===void 0||G(o.params))&&(o.queryId===void 0||typeof o.queryId==="string"))))throw Error("Invalid query evidence.");return{status:t.status,body:r}}}}var V=fe({input(e){if(!e||typeof e!=="object")throw Error("Invalid SQL query.");let n=e;if(typeof n.statement!=="string"||!n.statement.trim()||typeof n.limit!=="number"||!Number.isSafeInteger(n.limit)||n.limit<1||n.params!==void 0&&!G(n.params))throw Error("Invalid SQL query.");return{statement:n.statement,limit:n.limit,...n.params===void 0?{}:{params:n.params}}},output(e,n){if(!e||typeof e!=="object")throw Error("Invalid query result.");let t=e;if(!Array.isArray(t.columns)||!t.columns.every((r)=>r&&typeof r.name==="string"&&(r.type===void 0||typeof r.type==="string"))||!Array.isArray(t.rows)||t.rows.length>n.limit||!t.rows.every((r)=>Array.isArray(r)&&r.length===t.columns.length)||t.queryId!==void 0&&typeof t.queryId!=="string")throw Error("Invalid query result.");return{columns:t.columns,rows:t.rows,...t.queryId===void 0?{}:{queryId:t.queryId}}}});function N(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let n=Array.from(e,(t)=>t.toString(16).padStart(2,"0"));return[n.slice(0,4),n.slice(4,6),n.slice(6,8),n.slice(8,10),n.slice(10)].map((t)=>t.join("")).join("-")}var X=Symbol.for("@altertable/data-app/DataAppError");class A extends Error{code;requestId;[X]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[X]===!0}constructor(e,n,t){super(e);this.code=n,this.requestId=t,this.name="DataAppError"}}function me(e){if(!e||typeof e!=="object")return!1;let n=e;return(n.method==="log"||n.method==="info"||n.method==="warn"||n.method==="error")&&Array.isArray(n.args)&&n.args.length<=128}var K="altertable:data-app";var te=128,re=60000;function T(e){return typeof e==="string"&&/^[a-zA-Z0-9_-]{1,128}$/.test(e)}function b({wire:e,from:n,session:t,parse:r}){return{wire:e,from:n,session:t,parse:r}}function M(e){if(!T(e.id))throw Error("Invalid request ID.");return e.id}function P(e,n){let t=e[n];if(typeof t!=="string")throw Error(`Invalid ${n}.`);return t}function _(){return{}}var w={channel:K,version:1,events:{connect:b({wire:"bridge:connect",from:"host",session:"none",parse:_}),ready:b({wire:"bridge:ready",from:"app",session:"none",parse:_}),initialize:b({wire:"bridge:initialize",from:"host",session:"establish",parse:(e)=>({state:e.state})}),request:b({wire:"bridge:request",from:"app",session:"current",parse:(e)=>{let n=P(e,"route");if(!n||n.length>256)throw Error("Invalid message route.");return{id:M(e),route:n,payload:e.payload}}}),result:b({wire:"bridge:result",from:"host",session:"current",parse:(e)=>{if(!Object.hasOwn(e,"response"))throw Error("Missing response.");return{id:M(e),response:e.response}}}),error:b({wire:"bridge:error",from:"host",session:"current",parse:(e)=>{if(e.requestId!==void 0&&typeof e.requestId!=="string")throw Error("Invalid requestId.");return{id:M(e),code:P(e,"code"),message:P(e,"message"),...e.requestId===void 0?{}:{requestId:e.requestId}}}}),cancel:b({wire:"bridge:cancel",from:"app",session:"current",parse:(e)=>({id:M(e)})}),disconnect:b({wire:"bridge:disconnect",from:"app",session:"current",parse:_}),scriptLoad:b({wire:"script:load",from:"host",session:"current",parse:(e)=>({javascript:P(e,"javascript")})}),stateUpdate:b({wire:"state:update",from:"host",session:"current",parse:(e)=>({state:e.state})}),runtimeLog:b({wire:"runtime:log",from:"app",session:"current",parse:(e)=>{if(!me(e.payload))throw Error("Invalid log entry.");return{payload:e.payload}}}),runtimeReady:b({wire:"runtime:ready",from:"app",session:"current",parse:_}),runtimeError:b({wire:"runtime:error",from:"app",session:"current",parse:_})}};function ee(e){let n={type:e.type};if("id"in e)n.id=e.id;if(e.type==="bridge:request"){n.route=e.route;let t=e.payload;if(e.route==="data:query"&&t&&typeof t==="object"&&"operation"in t&&typeof t.operation==="string")n.operation=t.operation.slice(0,256)}if(e.type==="bridge:error")n.error={code:e.code,message:e.message,...e.requestId===void 0?{}:{requestId:e.requestId}};return n}var z=new Map;for(let e of Object.keys(w.events)){let n=w.events[e].wire;if(z.has(n))throw Error(`Duplicate bridge event: ${n}`);z.set(n,e)}function oe(e){return z.get(e)}function ie(e){if(!e||typeof e!=="object")return;let n=e;if(n.channel!==K||n.version!==w.version||typeof n.type!=="string"||typeof n.documentId!=="string"||!n.documentId||n.documentId.length>128||n.sessionId!==void 0&&!T(n.sessionId)||n.token!==void 0&&typeof n.token!=="string")return;return n}function se(e,n){try{return{channel:K,version:w.version,documentId:e.documentId,...e.sessionId===void 0?{}:{sessionId:e.sessionId},...e.token===void 0?{}:{token:e.token},type:n.wire,...n.parse(e)}}catch{return}}function ye(e){let n=ie(e);if(!n)return;let t=oe(n.type);if(!t)return;let r=w.events[t];if(r.session!=="none"&&n.sessionId===void 0)return;return se(n,r)}function ae({role:e,origin:n,source:t,opaque:r,context:o,post:a,diagnostic:p,invalidRequest:u,handlers:f}){let l=!1;function s(y,c){p?.({direction:"drop",reason:y,...typeof c==="string"?{type:c.slice(0,64)}:{}})}function g(y,c){if(l)throw Error("The bridge endpoint has closed.");let d=w.events[y],m=o(),q=ye({...c,channel:w.channel,version:w.version,type:d.wire,documentId:y==="connect"?"host":m.documentId,sessionId:m.sessionId,token:r?m.token:void 0});if(!q||r&&!T(m.token))throw Error("The bridge is not ready to send this event.");if(p?.({direction:"send",...ee(q)}),l)return;a(q)}function k(y){let c=t();if(l||!c||y.origin!==n||y.source!==c)return;let d=ie(y.data);if(!d){let S=y.data;if(S&&typeof S==="object"&&"channel"in S&&S.channel===w.channel)s("invalid_envelope","type"in S?S.type:void 0);return}let m=o(),q=e==="app"&&d.type===w.events.connect.wire;if(r&&(q?!T(d.token):!m.token||d.token!==m.token))return s("token_mismatch",d.type);let j=oe(d.type);if(!j)return s("unexpected_type",d.type);let D=w.events[j];if(D.from===e)return s("unexpected_type",d.type);if(D.session==="establish"){if(d.documentId!==m.documentId||d.sessionId===void 0)return s("session_mismatch",d.type)}else if(D.session==="current"){if(!m.sessionId||d.sessionId!==m.sessionId||d.documentId!==m.documentId)return s("session_mismatch",d.type)}let O=se(d,D);if(!O){if(s("invalid_payload",d.type),e==="host"&&j==="request"&&T(d.id))u?.(d.id);return}if(p?.({direction:"receive",...ee(O)}),l)return;let x=f[j];x(O)}return{send:g,receive:k,dispose(){l=!0}}}function de(e,n){return{async request(t,r,{signal:o}={}){if(o?.throwIfAborted(),!Object.hasOwn(e,t))throw new I("unknown_route","Unknown message route.");let a=e[t],p;try{p=a.input(r)}catch{throw new I("invalid_payload","Invalid message payload.")}let u=await n({route:t,payload:p},o);o?.throwIfAborted();try{return a.output(u,p)}catch(f){if(f instanceof I)throw f;throw new I("invalid_response","Invalid message response.")}}}}function he(e,n){function t(o){if(o.length===1&&typeof o[0]==="function"){let a=o[0]();return Array.isArray(a)?a:[a]}return o.map((a)=>typeof a==="function"?a():a)}function r(o,a){if(!e())return;try{n({method:o,args:t(a)})}catch{}}return{log:(...o)=>r("log",o),info:(...o)=>r("info",o),warn:(...o)=>r("warn",o),error:(...o)=>r("error",o)}}var be={send:"Sending message to parent",receive:"Received message from parent",drop:"Ignored message from parent"};function ge(e,{direction:n,...t}){if(t.type==="runtime:log")return;e.log(be[n],t)}function we(e){if(e instanceof Error)return{name:e.name,message:e.message,...e.stack?{stack:e.stack}:{}};return{message:String(e)}}function ne(e){if(e instanceof I)throw new A(e.message,e.code,e.requestId);throw e}function J({parentOrigin:e,window:n=window,timeoutMs:t=re,mode:r="url",loadScript:o}){if(new URL(e).origin!==e)throw Error("Expected an exact parent origin.");let a=N(),p,u,f=!1,l=new Map,s,g=new Set,k=he(()=>!f&&!!u&&!!s&&typeof s==="object"&&("logging"in s)&&s.logging===!0,(i)=>c("runtimeLog",{payload:i})),y=ae({role:"app",origin:e,source:()=>n.parent,opaque:r==="bundle",context:()=>({documentId:a,sessionId:u,token:p}),post(i){n.parent.postMessage(i,e)},diagnostic:(i)=>ge(k,i),handlers:{connect(i){if(r==="bundle")p=i.token;c("ready",{})},initialize(i){if(u&&u!==i.sessionId){if(l.size)k.warn("Preview reconnected; rejecting pending requests",{count:l.size});for(let E of l.values())E.reject(new A("The preview reconnected. Retry the request.","bridge_reset"))}let h=!u;if(u=i.sessionId,m(i.state),h)for(let E of l.values())E.start();if(f)return;if(r==="url")c("runtimeReady",{})},stateUpdate(i){m(i.state)},scriptLoad(i){if(r==="bundle")o?.(i.javascript)},result(i){l.get(i.id)?.resolve(i.response)},error(i){l.get(i.id)?.reject(new I(i.code,i.message,i.requestId))}}}),{send:c,receive:d}=y;function m(i){s=i;for(let h of g)h(i)}n.addEventListener("message",d);function q(i,h){return new Promise((E,v)=>{if(f)return v(new A("The preview has closed.","bridge_closed"));if(h?.aborted)return v(h.reason);if(l.size>=te)return v(new A("Too many pending data requests.","bridge_busy"));let R=N(),U=!1;function L(){clearTimeout(le),h?.removeEventListener("abort",Y),l.delete(R)}function Y(){if(U)c("cancel",{id:R});L(),v(h?.reason)}let le=setTimeout(()=>{if(k.warn("Message request timed out",{id:R,route:i.route,timeoutMs:t,sent:U}),U)c("cancel",{id:R});L(),v(new A(u?"The data request timed out.":"The preview shell is unavailable. Reload the preview.",u?"timeout":"bridge_unavailable"))},t),W={start(){if(U)return;try{c("request",{id:R,route:i.route,payload:i.payload}),U=!0}catch{L(),v(new A("The message payload could not be sent.","invalid_payload"))}},resolve(Q){L(),E(Q)},reject(Q){L(),v(Q)}};if(l.set(R,W),h?.addEventListener("abort",Y,{once:!0}),u)W.start();else if(r==="url"||p)c("ready",{})})}let j=de({"data:query":C(),"data:sql":V},q);function D(i,h,E){return j.request("data:query",{operation:i,input:h},{signal:E}).catch(ne)}function O(){if(u)c("disconnect",{});u=void 0;for(let i of l.values())i.reject(new A("The preview has closed.","bridge_closed"))}function x(i){if(i.persisted&&(r==="url"||p))c("ready",{})}function S(){if(f)return;O(),f=!0,y.dispose(),n.removeEventListener("message",d),n.removeEventListener("pagehide",O),n.removeEventListener("pageshow",x),g.clear()}if(n.addEventListener("pagehide",O),n.addEventListener("pageshow",x),r==="url")c("ready",{});return{logger:k,request:q,transport:D,lakehouse:{queryAll(i,{limit:h,signal:E,params:v}){return j.request("data:sql",{statement:i,limit:h,...v===void 0?{}:{params:v}},{signal:E}).catch(ne)}},dispose:S,mode:r,snapshot(){return s},subscribe(i){return g.add(i),()=>{g.delete(i)}},ready(){if(!f&&u)c("runtimeReady",{})},fail(i){if(f||!u)return;if(i!==void 0)k.error(()=>["Data app failed",we(i)]);c("runtimeError",{})}}}var F=Symbol.for("altertable.localFrameBridge"),B=Symbol.for("altertable.installedTransport");function Z(e,n=window){let t=n;if(t[B])throw Error("A data app transport is already installed.");return t[F]=e,t[B]=e,()=>{if(t[F]===e)delete t[F];if(t[B]===e)delete t[B];e.dispose()}}var je=Symbol("data-app.facetSource");var Be=C();function ue({parentOrigin:e,window:n=window}){let t,r,o=`altertable-data-app-${N()}.js`,a=J({parentOrigin:e,window:n,mode:"bundle",loadScript(s){if(t!==void 0){if(s!==t)a.fail(Error("This frame already evaluated a different app script."));else if(r)a.fail(r.cause);else a.ready();return}t=s;try{let g=n.document.createElement("script");if(g.textContent=`${s}\n//# sourceURL=${o}`,n.document.body.append(g),!r)a.ready()}catch(g){p(g)}}});function p(s){r={cause:s},a.fail(s)}function u(s){if(s.filename===o)p(s.error??s.message)}function f(s){if(s.reason instanceof Error&&s.reason.stack?.includes(o))p(s.reason)}n.addEventListener("error",u),n.addEventListener("unhandledrejection",f);let l=Z(a,n);return()=>{n.removeEventListener("error",u),n.removeEventListener("unhandledrejection",f),l()}}var ce=document.currentScript?.dataset.parentOrigin;if(!ce)throw Error("Missing trusted parent origin.");ue({parentOrigin:ce});})();\n'.replace(/<\/script/gi, (match) => `<\\${match.slice(1)}`);
|
|
4
|
-
function
|
|
1
|
+
// packages/data-app-embed/dist/runtime-html.js
|
|
2
|
+
var PAGE_CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; connect-src 'none'; form-action 'none'; base-uri 'none'";
|
|
3
|
+
var inlineBootstrap = '(()=>{function ye(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&Number.isFinite(e)}function Q(e){return!!e&&typeof e==="object"&&!Array.isArray(e)&&Object.values(e).every(ye)}var ke=Symbol("data-app.dimensionSource");var G=Symbol.for("@altertable/data-app/MessageRoutingError"),S=class extends Error{code;requestId;[G]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[G]===!0}constructor(e,t,n,r){super(t,r);this.code=e,this.requestId=n,this.name="MessageRoutingError"}};function he(e){return e}function M(e){return{operations:e,input(t){if(!t||typeof t!=="object")throw Error("Invalid query.");let n=t;if(typeof n.operation!=="string"||!n.operation||n.operation.length>256||n.operation.includes("/"))throw Error("Invalid operation.");let r=e&&Object.hasOwn(e,n.operation)?e[n.operation]:void 0;if(e&&!r)throw Error("Unknown operation.");return{operation:n.operation,input:r?r.input(n.input):n.input}},output(t){if(!t||typeof t!=="object")throw Error("Invalid data response.");let n=t;if(!Number.isInteger(n.status)||n.status<100||n.status>599||!n.body||typeof n.body!=="object"||Array.isArray(n.body))throw Error("Invalid data response.");let r=n.body;if(n.status<200||n.status>=300){let o=r.error;throw new S(typeof o?.code==="string"?o.code:"request_failed",typeof o?.message==="string"?o.message:"Could not load data.",typeof o?.requestId==="string"?o.requestId:void 0)}if(!("data"in r)||typeof r.requestId!=="string"||typeof r.queriedAt!=="string"||!Array.isArray(r.queryIds)||!r.queryIds.every((o)=>typeof o==="string"))throw Error("Invalid data envelope.");if(r.queries!==void 0&&(!Array.isArray(r.queries)||!r.queries.every((o)=>o&&typeof o==="object"&&typeof o.name==="string"&&typeof o.statement==="string"&&(o.params===void 0||Q(o.params))&&(o.queryId===void 0||typeof o.queryId==="string"))))throw Error("Invalid query evidence.");return{status:n.status,body:r}}}}var X=he({input(e){if(!e||typeof e!=="object")throw Error("Invalid SQL query.");let t=e;if(typeof t.statement!=="string"||!t.statement.trim()||typeof t.limit!=="number"||!Number.isSafeInteger(t.limit)||t.limit<1||t.params!==void 0&&!Q(t.params))throw Error("Invalid SQL query.");return{statement:t.statement,limit:t.limit,...t.params===void 0?{}:{params:t.params}}},output(e,t){if(!e||typeof e!=="object")throw Error("Invalid query result.");let n=e;if(!Array.isArray(n.columns)||!n.columns.every((r)=>r&&typeof r.name==="string"&&(r.type===void 0||typeof r.type==="string"))||!Array.isArray(n.rows)||n.rows.length>t.limit||!n.rows.every((r)=>Array.isArray(r)&&r.length===n.columns.length)||n.queryId!==void 0&&typeof n.queryId!=="string")throw Error("Invalid query result.");return{columns:n.columns,rows:n.rows,...n.queryId===void 0?{}:{queryId:n.queryId}}}});function ee(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.enabled==="boolean"&&(t.active===void 0||typeof t.active==="boolean")&&(t.pinsVisible===void 0||typeof t.pinsVisible==="boolean")&&(t.showHint===void 0||typeof t.showHint==="boolean")&&(t.readOnly===void 0||typeof t.readOnly==="boolean")&&(t.selectedAnnotationId===void 0||typeof t.selectedAnnotationId==="string"&&t.selectedAnnotationId.length<=128)&&(t.dismissal===void 0||t.dismissal!==null&&typeof t.dismissal==="object"&&typeof t.dismissal.id==="string"&&t.dismissal.id.length<=128&&typeof t.dismissal.occurredAt==="number"&&Number.isFinite(t.dismissal.occurredAt))&&(t.selectionId===void 0||typeof t.selectionId==="string"&&t.selectionId.length<=128)&&(t.selectedTargetId===void 0||typeof t.selectedTargetId==="string"&&t.selectedTargetId.length<=128)&&(t.targets===void 0||Array.isArray(t.targets)&&t.targets.length<=50&&t.targets.every((n)=>n&&typeof n.id==="string"&&n.id.length<=128&&typeof n.targetId==="string"&&n.targetId.length<=128&&Number.isSafeInteger(n.number)&&n.number>0&&(n.anchor===void 0||typeof n.anchor.x==="number"&&Number.isFinite(n.anchor.x)&&n.anchor.x>=0&&n.anchor.x<=1&&typeof n.anchor.y==="number"&&Number.isFinite(n.anchor.y)&&n.anchor.y>=0&&n.anchor.y<=1)&&(n.region===void 0||typeof n.region==="object"&&n.region!==null&&["x","y","width","height"].every((r)=>{let o=n.region[r];return typeof o==="number"&&Number.isFinite(o)&&o>=0&&o<=1})&&n.region.width>0&&n.region.height>0&&n.region.x+n.region.width<=1.000001&&n.region.y+n.region.height<=1.000001)&&(n.comment===void 0||typeof n.comment==="string"&&n.comment.length<=2000)))}function T(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,(n)=>n.toString(16).padStart(2,"0"));return[t.slice(0,4),t.slice(4,6),t.slice(6,8),t.slice(8,10),t.slice(10)].map((n)=>n.join("")).join("-")}function be(e){if(!e||typeof e!=="object")return!1;let t=e;return(t.method==="log"||t.method==="info"||t.method==="warn"||t.method==="error")&&Array.isArray(t.args)&&t.args.length<=128}var Z="altertable:data-app";var oe=60000;function R(e){return typeof e==="string"&&/^[a-zA-Z0-9_-]{1,128}$/.test(e)}function h({wire:e,from:t,session:n,parse:r}){return{wire:e,from:t,session:n,parse:r}}function C(e){if(!R(e.id))throw Error("Invalid request ID.");return e.id}function P(e,t){let n=e[t];if(typeof n!=="string")throw Error(`Invalid ${t}.`);return n}function B(e,t){let n=e[t];if(typeof n!=="number"||!Number.isFinite(n)||n<0)throw Error(`Invalid ${t}.`);return n}function _(){return{}}var I={channel:Z,version:1,events:{connect:h({wire:"bridge:connect",from:"host",session:"none",parse:_}),ready:h({wire:"bridge:ready",from:"app",session:"none",parse:_}),initialize:h({wire:"bridge:initialize",from:"host",session:"establish",parse:(e)=>({state:e.state})}),request:h({wire:"bridge:request",from:"app",session:"current",parse:(e)=>{let t=P(e,"route");if(!t||t.length>256)throw Error("Invalid message route.");return{id:C(e),route:t,payload:e.payload}}}),result:h({wire:"bridge:result",from:"host",session:"current",parse:(e)=>{if(!Object.hasOwn(e,"response"))throw Error("Missing response.");return{id:C(e),response:e.response}}}),error:h({wire:"bridge:error",from:"host",session:"current",parse:(e)=>{if(e.requestId!==void 0&&typeof e.requestId!=="string")throw Error("Invalid requestId.");return{id:C(e),code:P(e,"code"),message:P(e,"message"),...e.requestId===void 0?{}:{requestId:e.requestId}}}}),cancel:h({wire:"bridge:cancel",from:"app",session:"current",parse:(e)=>({id:C(e)})}),disconnect:h({wire:"bridge:disconnect",from:"app",session:"current",parse:_}),scriptLoad:h({wire:"script:load",from:"host",session:"current",parse:(e)=>({javascript:P(e,"javascript")})}),stateUpdate:h({wire:"state:update",from:"host",session:"current",parse:(e)=>({state:e.state})}),runtimeLog:h({wire:"runtime:log",from:"app",session:"current",parse:(e)=>{if(!be(e.payload))throw Error("Invalid log entry.");return{payload:e.payload}}}),runtimeReady:h({wire:"runtime:ready",from:"app",session:"current",parse:_}),runtimeError:h({wire:"runtime:error",from:"app",session:"current",parse:_}),runtimeResize:h({wire:"runtime:resize",from:"app",session:"current",parse:(e)=>({height:B(e,"height")})}),viewportUpdate:h({wire:"viewport:update",from:"host",session:"current",parse:(e)=>({top:B(e,"top"),bottom:B(e,"bottom")})})}};function te(e){let t={type:e.type};if("id"in e)t.id=e.id;if(e.type==="bridge:request"){t.route=e.route;let n=e.payload;if(e.route==="data:query"&&n&&typeof n==="object"&&"operation"in n&&typeof n.operation==="string")t.operation=n.operation.slice(0,256)}if(e.type==="bridge:error")t.error={code:e.code,message:e.message,...e.requestId===void 0?{}:{requestId:e.requestId}};return t}var J=new Map;for(let e of Object.keys(I.events)){let t=I.events[e].wire;if(J.has(t))throw Error(`Duplicate bridge event: ${t}`);J.set(t,e)}function ie(e){return J.get(e)}function se(e){if(!e||typeof e!=="object")return;let t=e;if(t.channel!==Z||t.version!==I.version||typeof t.type!=="string"||typeof t.documentId!=="string"||!t.documentId||t.documentId.length>128||t.sessionId!==void 0&&!R(t.sessionId)||t.token!==void 0&&typeof t.token!=="string")return;return t}function ae(e,t){try{return{channel:Z,version:I.version,documentId:e.documentId,...e.sessionId===void 0?{}:{sessionId:e.sessionId},...e.token===void 0?{}:{token:e.token},type:t.wire,...t.parse(e)}}catch{return}}function ge(e){let t=se(e);if(!t)return;let n=ie(t.type);if(!n)return;let r=I.events[n];if(r.session!=="none"&&t.sessionId===void 0)return;return ae(t,r)}function ce({role:e,origin:t,source:n,opaque:r,context:o,post:a,diagnostic:p,invalidRequest:u,handlers:f}){let m=!1;function s(c,l){p?.({direction:"drop",reason:c,...typeof l==="string"?{type:l.slice(0,64)}:{}})}function b(c,l){if(m)throw Error("The bridge endpoint has closed.");let d=I.events[c],y=o(),q=ge({...l,channel:I.channel,version:I.version,type:d.wire,documentId:c==="connect"?"host":y.documentId,sessionId:y.sessionId,token:r?y.token:void 0});if(!q||r&&!R(y.token))throw Error("The bridge is not ready to send this event.");if(p?.({direction:"send",...te(q)}),m)return;a(q)}function w(c){let l=n();if(m||!l||c.origin!==t||c.source!==l)return;let d=se(c.data);if(!d){let A=c.data;if(A&&typeof A==="object"&&"channel"in A&&A.channel===I.channel)s("invalid_envelope","type"in A?A.type:void 0);return}let y=o(),q=e==="app"&&d.type===I.events.connect.wire;if(r&&(q?!R(d.token):!y.token||d.token!==y.token))return s("token_mismatch",d.type);let j=ie(d.type);if(!j)return s("unexpected_type",d.type);let D=I.events[j];if(D.from===e)return s("unexpected_type",d.type);if(D.session==="establish"){if(d.documentId!==y.documentId||d.sessionId===void 0)return s("session_mismatch",d.type)}else if(D.session==="current"){if(!y.sessionId||d.sessionId!==y.sessionId||d.documentId!==y.documentId)return s("session_mismatch",d.type)}let N=ae(d,D);if(!N){if(s("invalid_payload",d.type),e==="host"&&j==="request"&&R(d.id))u?.(d.id);return}if(p?.({direction:"receive",...te(N)}),m)return;let L=f[j];L(N)}return{send:b,receive:w,dispose(){m=!0}}}function ue(e){if(!e||typeof e!=="object")return!1;let t=e;return(t.surface==="embedded"||t.surface==="standalone")&&(t.theme==="light"||t.theme==="dark")&&(t.annotations===void 0||ee(t.annotations))&&(t.sizing===void 0||t.sizing==="frame"||t.sizing==="content")}function we(e,t){let{documentElement:n,defaultView:r}=e,o,a,p=!1,u=0,f;function m(){let c=Math.ceil(n.getBoundingClientRect().height);if(c===a&&c!==r?.innerHeight)return;a=c,t(c)}function s(){o?.disconnect(),o=void 0,r?.removeEventListener("resize",m),a=void 0,delete n.dataset.atblFrameSizing,n.style.removeProperty("--atbl-frame-inset-top"),n.style.removeProperty("--atbl-frame-inset-bottom")}function b(){if(!o||!f)return;n.style.setProperty("--atbl-frame-inset-top",`${f.top}px`),n.style.setProperty("--atbl-frame-inset-bottom",`${f.bottom}px`)}function w(){if(!p||!u)return s();if(o)return;n.dataset.atblFrameSizing="content",o=new(e.defaultView??globalThis).ResizeObserver(m),o.observe(n),r?.addEventListener("resize",m),b()}return{update(c,l){let d=c&&typeof c==="object"&&"presentation"in c?c.presentation:void 0;if(p=ue(d)&&d.sizing==="content",!p)f=void 0;if(l==="new")a=void 0;if(o&&p)m();w()},support(){u++,w();let c=!1;return()=>{if(c)return;c=!0,u--,w()}},viewport(c,l){if(!p)return;f={top:c,bottom:l},b()},dispose(){p=!1,f=void 0,u=0,s()}}}function ve(e,t){function n(o){if(o.length===1&&typeof o[0]==="function"){let a=o[0]();return Array.isArray(a)?a:[a]}return o.map((a)=>typeof a==="function"?a():a)}function r(o,a){if(!e())return;try{t({method:o,args:n(a)})}catch{}}return{log:(...o)=>r("log",o),info:(...o)=>r("info",o),warn:(...o)=>r("warn",o),error:(...o)=>r("error",o)}}var Ie={send:"Sending message to parent",receive:"Received message from parent",drop:"Ignored message from parent"};function Ee(e,{direction:t,...n}){if(n.type==="runtime:log"||n.type==="runtime:resize"||n.type==="viewport:update")return;e.log(Ie[t],n)}function Ae(e){if(e instanceof Error)return{name:e.name,message:e.message,...e.stack?{stack:e.stack}:{}};return{message:String(e)}}function de(e,t){return{async request(n,r,{signal:o}={}){if(o?.throwIfAborted(),!Object.hasOwn(e,n))throw new S("unknown_route","Unknown message route.");let a=e[n],p;try{p=a.input(r)}catch{throw new S("invalid_payload","Invalid message payload.")}let u=await t({route:n,payload:p},o);o?.throwIfAborted();try{return a.output(u,p)}catch(f){if(f instanceof S)throw f;throw new S("invalid_response","Invalid message response.")}}}}var ne=Symbol.for("@altertable/data-app/DataAppError"),k=class extends Error{code;requestId;[ne]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[ne]===!0}constructor(e,t,n){super(e);this.code=t,this.requestId=n,this.name="DataAppError"}};function re(e){if(e instanceof S)throw new k(e.message,e.code,e.requestId);throw e}function W({parentOrigin:e,window:t=window,timeoutMs:n=oe,mode:r="url",loadScript:o}){if(new URL(e).origin!==e)throw Error("Expected an exact parent origin.");let a=T(),p,u,f=!1,m=new Map,s,b=new Set,w=ve(()=>!f&&!!u&&!!s&&typeof s==="object"&&("logging"in s)&&s.logging===!0,(i)=>l("runtimeLog",{payload:i})),c=ce({role:"app",origin:e,source:()=>t.parent,opaque:r==="bundle",context:()=>({documentId:a,sessionId:u,token:p}),post(i){t.parent.postMessage(i,e)},diagnostic:(i)=>Ee(w,i),handlers:{connect(i){if(r==="bundle")p=i.token;l("ready",{})},initialize(i){if(u&&u!==i.sessionId){if(m.size)w.warn("Preview reconnected; rejecting pending requests",{count:m.size});for(let v of m.values())v.reject(new k("The preview reconnected. Retry the request.","bridge_reset"))}let g=!u;if(u=i.sessionId,q(i.state,"new"),g)for(let v of m.values())v.start();if(f)return;if(r==="url")l("runtimeReady",{})},stateUpdate(i){q(i.state,"current")},viewportUpdate(i){y.viewport(i.top,i.bottom)},scriptLoad(i){if(r==="bundle")o?.(i.javascript)},result(i){m.get(i.id)?.resolve(i.response)},error(i){m.get(i.id)?.reject(new S(i.code,i.message,i.requestId))}}}),{send:l,receive:d}=c,y=we(t.document,(i)=>{if(!f&&u)l("runtimeResize",{height:i})});function q(i,g){s=i,y.update(i,g);for(let v of b)v(i)}t.addEventListener("message",d);function j(i,g){return new Promise((v,E)=>{if(f)return E(new k("The preview has closed.","bridge_closed"));if(g?.aborted)return E(g.reason);if(m.size>=128)return E(new k("Too many pending data requests.","bridge_busy"));let O=T(),U=!1;function x(){clearTimeout(me),g?.removeEventListener("abort",H),m.delete(O)}function H(){if(U)l("cancel",{id:O});x(),E(g?.reason)}let me=setTimeout(()=>{if(w.warn("Message request timed out",{id:O,route:i.route,timeoutMs:n,sent:U}),U)l("cancel",{id:O});x(),E(new k(u?"The data request timed out.":"The preview shell is unavailable. Reload the preview.",u?"timeout":"bridge_unavailable"))},n),V={start(){if(U)return;try{l("request",{id:O,route:i.route,payload:i.payload}),U=!0}catch{x(),E(new k("The message payload could not be sent.","invalid_payload"))}},resolve(F){x(),v(F)},reject(F){x(),E(F)}};if(m.set(O,V),g?.addEventListener("abort",H,{once:!0}),u)V.start();else if(r==="url"||p)l("ready",{})})}let D=de({"data:query":M(),"data:sql":X},j);function N(i,g,v){return D.request("data:query",{operation:i,input:g},{signal:v}).catch(re)}function L(){if(u)l("disconnect",{});u=void 0;for(let i of m.values())i.reject(new k("The preview has closed.","bridge_closed"))}function A(i){if(i.persisted&&(r==="url"||p))l("ready",{})}function fe(){if(f)return;L(),f=!0,c.dispose(),y.dispose(),t.removeEventListener("message",d),t.removeEventListener("pagehide",L),t.removeEventListener("pageshow",A),b.clear()}if(t.addEventListener("pagehide",L),t.addEventListener("pageshow",A),r==="url")l("ready",{});return{logger:w,request:j,transport:N,lakehouse:{queryAll(i,{limit:g,signal:v,params:E}){return D.request("data:sql",{statement:i,limit:g,...E===void 0?{}:{params:E}},{signal:v}).catch(re)}},dispose:fe,mode:r,snapshot(){return s},subscribe(i){return b.add(i),()=>{b.delete(i)}},ready(){if(!f&&u)l("runtimeReady",{})},supportContentSizing(){return y.support()},fail(i){if(f||!u)return;if(i!==void 0)w.error(()=>["Data app failed",Ae(i)]);l("runtimeError",{})}}}var K=Symbol.for("altertable.localFrameBridge"),z=Symbol.for("altertable.installedTransport");function Y(e,t=window){let n=t;if(n[z])throw Error("A data app transport is already installed.");return n[K]=e,n[z]=e,()=>{if(n[K]===e)delete n[K];if(n[z]===e)delete n[z];e.dispose()}}var Je=M();var He=Symbol("data-app.facetSource");function le({parentOrigin:e,window:t=window}){let n,r,o=`altertable-data-app-${T()}.js`,a=W({parentOrigin:e,window:t,mode:"bundle",loadScript(s){if(n!==void 0){if(s!==n)a.fail(Error("This frame already evaluated a different app script."));else if(r)a.fail(r.cause);else a.ready();return}n=s;try{let b=t.document.createElement("script");if(b.textContent=`${s}\n//# sourceURL=${o}`,t.document.body.append(b),!r)a.ready()}catch(b){p(b)}}});function p(s){r={cause:s},a.fail(s)}function u(s){if(s.filename===o)p(s.error??s.message)}function f(s){if(s.reason instanceof Error&&s.reason.stack?.includes(o))p(s.reason)}t.addEventListener("error",u),t.addEventListener("unhandledrejection",f);let m=Y(a,t);return()=>{t.removeEventListener("error",u),t.removeEventListener("unhandledrejection",f),m()}}var pe=document.currentScript?.dataset.parentOrigin;if(!pe)throw Error("Missing trusted parent origin.");le({parentOrigin:pe});})();\n'.replace(/<\/script/gi, (match) => `<\\${match.slice(1)}`);
|
|
4
|
+
function runtimeHtml(parentOrigin) {
|
|
5
5
|
const attribute = parentOrigin.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">").replaceAll("'", "'");
|
|
6
6
|
return `<!doctype html>
|
|
7
7
|
<html>
|
|
8
8
|
<head>
|
|
9
9
|
<meta charset="utf-8">
|
|
10
10
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
11
|
-
<meta http-equiv="Content-Security-Policy" content="${
|
|
11
|
+
<meta http-equiv="Content-Security-Policy" content="${PAGE_CSP}">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="root"></div>
|
|
@@ -71,7 +71,7 @@ function isPreviewHost(hostname, domainName) {
|
|
|
71
71
|
return hostname.endsWith(suffix) && TOKEN_RE.test(hostname.slice(0, -suffix.length));
|
|
72
72
|
}
|
|
73
73
|
var worker = {
|
|
74
|
-
runtimeHtml
|
|
74
|
+
runtimeHtml,
|
|
75
75
|
fetch(request, env) {
|
|
76
76
|
const url = new URL(request.url);
|
|
77
77
|
if (!isPreviewHost(url.hostname, env.DOMAIN_NAME) || url.pathname !== "/") {
|
|
@@ -91,10 +91,10 @@ var worker = {
|
|
|
91
91
|
}
|
|
92
92
|
if (!parent)
|
|
93
93
|
return new Response(null, { status: 403 });
|
|
94
|
-
return new Response(request.method === "HEAD" ? null :
|
|
94
|
+
return new Response(request.method === "HEAD" ? null : runtimeHtml(parent), {
|
|
95
95
|
headers: {
|
|
96
96
|
"Content-Type": "text/html; charset=utf-8",
|
|
97
|
-
"Content-Security-Policy": `${
|
|
97
|
+
"Content-Security-Policy": `${PAGE_CSP}; frame-ancestors ${env.PARENT_ORIGINS.trim().split(/\s+/).join(" ")}`,
|
|
98
98
|
"X-Content-Type-Options": "nosniff",
|
|
99
99
|
"Referrer-Policy": "no-referrer"
|
|
100
100
|
}
|
|
@@ -106,4 +106,4 @@ export {
|
|
|
106
106
|
src_default as default
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
//# debugId=
|
|
109
|
+
//# debugId=F48BFCF99E3508F964756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../data-app-embed/dist/
|
|
3
|
+
"sources": ["../../data-app-embed/dist/runtime-html.js", "../src/trusted-parent.ts", "../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"// packages/data-app-embed/src/runtime-html.ts\nvar PAGE_CSP2 = \"default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; connect-src 'none'; form-action 'none'; base-uri 'none'\";\nvar inlineBootstrap = '(()=>{function pe(e){return e===null||typeof e===\"string\"||typeof e===\"boolean\"||typeof e===\"number\"&&Number.isFinite(e)}function G(e){return!!e&&typeof e===\"object\"&&!Array.isArray(e)&&Object.values(e).every(pe)}var Ee=Symbol(\"data-app.dimensionSource\");var H=Symbol.for(\"@altertable/data-app/MessageRoutingError\");class I extends Error{code;requestId;[H]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[H]===!0}constructor(e,n,t,r){super(n,r);this.code=e,this.requestId=t,this.name=\"MessageRoutingError\"}}function fe(e){return e}function C(e){return{operations:e,input(n){if(!n||typeof n!==\"object\")throw Error(\"Invalid query.\");let t=n;if(typeof t.operation!==\"string\"||!t.operation||t.operation.length>256||t.operation.includes(\"/\"))throw Error(\"Invalid operation.\");let r=e&&Object.hasOwn(e,t.operation)?e[t.operation]:void 0;if(e&&!r)throw Error(\"Unknown operation.\");return{operation:t.operation,input:r?r.input(t.input):t.input}},output(n){if(!n||typeof n!==\"object\")throw Error(\"Invalid data response.\");let t=n;if(!Number.isInteger(t.status)||t.status<100||t.status>599||!t.body||typeof t.body!==\"object\"||Array.isArray(t.body))throw Error(\"Invalid data response.\");let r=t.body;if(t.status<200||t.status>=300){let o=r.error;throw new I(typeof o?.code===\"string\"?o.code:\"request_failed\",typeof o?.message===\"string\"?o.message:\"Could not load data.\",typeof o?.requestId===\"string\"?o.requestId:void 0)}if(!(\"data\"in r)||typeof r.requestId!==\"string\"||typeof r.queriedAt!==\"string\"||!Array.isArray(r.queryIds)||!r.queryIds.every((o)=>typeof o===\"string\"))throw Error(\"Invalid data envelope.\");if(r.queries!==void 0&&(!Array.isArray(r.queries)||!r.queries.every((o)=>o&&typeof o===\"object\"&&typeof o.name===\"string\"&&typeof o.statement===\"string\"&&(o.params===void 0||G(o.params))&&(o.queryId===void 0||typeof o.queryId===\"string\"))))throw Error(\"Invalid query evidence.\");return{status:t.status,body:r}}}}var V=fe({input(e){if(!e||typeof e!==\"object\")throw Error(\"Invalid SQL query.\");let n=e;if(typeof n.statement!==\"string\"||!n.statement.trim()||typeof n.limit!==\"number\"||!Number.isSafeInteger(n.limit)||n.limit<1||n.params!==void 0&&!G(n.params))throw Error(\"Invalid SQL query.\");return{statement:n.statement,limit:n.limit,...n.params===void 0?{}:{params:n.params}}},output(e,n){if(!e||typeof e!==\"object\")throw Error(\"Invalid query result.\");let t=e;if(!Array.isArray(t.columns)||!t.columns.every((r)=>r&&typeof r.name===\"string\"&&(r.type===void 0||typeof r.type===\"string\"))||!Array.isArray(t.rows)||t.rows.length>n.limit||!t.rows.every((r)=>Array.isArray(r)&&r.length===t.columns.length)||t.queryId!==void 0&&typeof t.queryId!==\"string\")throw Error(\"Invalid query result.\");return{columns:t.columns,rows:t.rows,...t.queryId===void 0?{}:{queryId:t.queryId}}}});function N(){if(typeof crypto.randomUUID===\"function\")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let n=Array.from(e,(t)=>t.toString(16).padStart(2,\"0\"));return[n.slice(0,4),n.slice(4,6),n.slice(6,8),n.slice(8,10),n.slice(10)].map((t)=>t.join(\"\")).join(\"-\")}var X=Symbol.for(\"@altertable/data-app/DataAppError\");class A extends Error{code;requestId;[X]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[X]===!0}constructor(e,n,t){super(e);this.code=n,this.requestId=t,this.name=\"DataAppError\"}}function me(e){if(!e||typeof e!==\"object\")return!1;let n=e;return(n.method===\"log\"||n.method===\"info\"||n.method===\"warn\"||n.method===\"error\")&&Array.isArray(n.args)&&n.args.length<=128}var K=\"altertable:data-app\";var te=128,re=60000;function T(e){return typeof e===\"string\"&&/^[a-zA-Z0-9_-]{1,128}$/.test(e)}function b({wire:e,from:n,session:t,parse:r}){return{wire:e,from:n,session:t,parse:r}}function M(e){if(!T(e.id))throw Error(\"Invalid request ID.\");return e.id}function P(e,n){let t=e[n];if(typeof t!==\"string\")throw Error(`Invalid ${n}.`);return t}function _(){return{}}var w={channel:K,version:1,events:{connect:b({wire:\"bridge:connect\",from:\"host\",session:\"none\",parse:_}),ready:b({wire:\"bridge:ready\",from:\"app\",session:\"none\",parse:_}),initialize:b({wire:\"bridge:initialize\",from:\"host\",session:\"establish\",parse:(e)=>({state:e.state})}),request:b({wire:\"bridge:request\",from:\"app\",session:\"current\",parse:(e)=>{let n=P(e,\"route\");if(!n||n.length>256)throw Error(\"Invalid message route.\");return{id:M(e),route:n,payload:e.payload}}}),result:b({wire:\"bridge:result\",from:\"host\",session:\"current\",parse:(e)=>{if(!Object.hasOwn(e,\"response\"))throw Error(\"Missing response.\");return{id:M(e),response:e.response}}}),error:b({wire:\"bridge:error\",from:\"host\",session:\"current\",parse:(e)=>{if(e.requestId!==void 0&&typeof e.requestId!==\"string\")throw Error(\"Invalid requestId.\");return{id:M(e),code:P(e,\"code\"),message:P(e,\"message\"),...e.requestId===void 0?{}:{requestId:e.requestId}}}}),cancel:b({wire:\"bridge:cancel\",from:\"app\",session:\"current\",parse:(e)=>({id:M(e)})}),disconnect:b({wire:\"bridge:disconnect\",from:\"app\",session:\"current\",parse:_}),scriptLoad:b({wire:\"script:load\",from:\"host\",session:\"current\",parse:(e)=>({javascript:P(e,\"javascript\")})}),stateUpdate:b({wire:\"state:update\",from:\"host\",session:\"current\",parse:(e)=>({state:e.state})}),runtimeLog:b({wire:\"runtime:log\",from:\"app\",session:\"current\",parse:(e)=>{if(!me(e.payload))throw Error(\"Invalid log entry.\");return{payload:e.payload}}}),runtimeReady:b({wire:\"runtime:ready\",from:\"app\",session:\"current\",parse:_}),runtimeError:b({wire:\"runtime:error\",from:\"app\",session:\"current\",parse:_})}};function ee(e){let n={type:e.type};if(\"id\"in e)n.id=e.id;if(e.type===\"bridge:request\"){n.route=e.route;let t=e.payload;if(e.route===\"data:query\"&&t&&typeof t===\"object\"&&\"operation\"in t&&typeof t.operation===\"string\")n.operation=t.operation.slice(0,256)}if(e.type===\"bridge:error\")n.error={code:e.code,message:e.message,...e.requestId===void 0?{}:{requestId:e.requestId}};return n}var z=new Map;for(let e of Object.keys(w.events)){let n=w.events[e].wire;if(z.has(n))throw Error(`Duplicate bridge event: ${n}`);z.set(n,e)}function oe(e){return z.get(e)}function ie(e){if(!e||typeof e!==\"object\")return;let n=e;if(n.channel!==K||n.version!==w.version||typeof n.type!==\"string\"||typeof n.documentId!==\"string\"||!n.documentId||n.documentId.length>128||n.sessionId!==void 0&&!T(n.sessionId)||n.token!==void 0&&typeof n.token!==\"string\")return;return n}function se(e,n){try{return{channel:K,version:w.version,documentId:e.documentId,...e.sessionId===void 0?{}:{sessionId:e.sessionId},...e.token===void 0?{}:{token:e.token},type:n.wire,...n.parse(e)}}catch{return}}function ye(e){let n=ie(e);if(!n)return;let t=oe(n.type);if(!t)return;let r=w.events[t];if(r.session!==\"none\"&&n.sessionId===void 0)return;return se(n,r)}function ae({role:e,origin:n,source:t,opaque:r,context:o,post:a,diagnostic:p,invalidRequest:u,handlers:f}){let l=!1;function s(y,c){p?.({direction:\"drop\",reason:y,...typeof c===\"string\"?{type:c.slice(0,64)}:{}})}function g(y,c){if(l)throw Error(\"The bridge endpoint has closed.\");let d=w.events[y],m=o(),q=ye({...c,channel:w.channel,version:w.version,type:d.wire,documentId:y===\"connect\"?\"host\":m.documentId,sessionId:m.sessionId,token:r?m.token:void 0});if(!q||r&&!T(m.token))throw Error(\"The bridge is not ready to send this event.\");if(p?.({direction:\"send\",...ee(q)}),l)return;a(q)}function k(y){let c=t();if(l||!c||y.origin!==n||y.source!==c)return;let d=ie(y.data);if(!d){let S=y.data;if(S&&typeof S===\"object\"&&\"channel\"in S&&S.channel===w.channel)s(\"invalid_envelope\",\"type\"in S?S.type:void 0);return}let m=o(),q=e===\"app\"&&d.type===w.events.connect.wire;if(r&&(q?!T(d.token):!m.token||d.token!==m.token))return s(\"token_mismatch\",d.type);let j=oe(d.type);if(!j)return s(\"unexpected_type\",d.type);let D=w.events[j];if(D.from===e)return s(\"unexpected_type\",d.type);if(D.session===\"establish\"){if(d.documentId!==m.documentId||d.sessionId===void 0)return s(\"session_mismatch\",d.type)}else if(D.session===\"current\"){if(!m.sessionId||d.sessionId!==m.sessionId||d.documentId!==m.documentId)return s(\"session_mismatch\",d.type)}let O=se(d,D);if(!O){if(s(\"invalid_payload\",d.type),e===\"host\"&&j===\"request\"&&T(d.id))u?.(d.id);return}if(p?.({direction:\"receive\",...ee(O)}),l)return;let x=f[j];x(O)}return{send:g,receive:k,dispose(){l=!0}}}function de(e,n){return{async request(t,r,{signal:o}={}){if(o?.throwIfAborted(),!Object.hasOwn(e,t))throw new I(\"unknown_route\",\"Unknown message route.\");let a=e[t],p;try{p=a.input(r)}catch{throw new I(\"invalid_payload\",\"Invalid message payload.\")}let u=await n({route:t,payload:p},o);o?.throwIfAborted();try{return a.output(u,p)}catch(f){if(f instanceof I)throw f;throw new I(\"invalid_response\",\"Invalid message response.\")}}}}function he(e,n){function t(o){if(o.length===1&&typeof o[0]===\"function\"){let a=o[0]();return Array.isArray(a)?a:[a]}return o.map((a)=>typeof a===\"function\"?a():a)}function r(o,a){if(!e())return;try{n({method:o,args:t(a)})}catch{}}return{log:(...o)=>r(\"log\",o),info:(...o)=>r(\"info\",o),warn:(...o)=>r(\"warn\",o),error:(...o)=>r(\"error\",o)}}var be={send:\"Sending message to parent\",receive:\"Received message from parent\",drop:\"Ignored message from parent\"};function ge(e,{direction:n,...t}){if(t.type===\"runtime:log\")return;e.log(be[n],t)}function we(e){if(e instanceof Error)return{name:e.name,message:e.message,...e.stack?{stack:e.stack}:{}};return{message:String(e)}}function ne(e){if(e instanceof I)throw new A(e.message,e.code,e.requestId);throw e}function J({parentOrigin:e,window:n=window,timeoutMs:t=re,mode:r=\"url\",loadScript:o}){if(new URL(e).origin!==e)throw Error(\"Expected an exact parent origin.\");let a=N(),p,u,f=!1,l=new Map,s,g=new Set,k=he(()=>!f&&!!u&&!!s&&typeof s===\"object\"&&(\"logging\"in s)&&s.logging===!0,(i)=>c(\"runtimeLog\",{payload:i})),y=ae({role:\"app\",origin:e,source:()=>n.parent,opaque:r===\"bundle\",context:()=>({documentId:a,sessionId:u,token:p}),post(i){n.parent.postMessage(i,e)},diagnostic:(i)=>ge(k,i),handlers:{connect(i){if(r===\"bundle\")p=i.token;c(\"ready\",{})},initialize(i){if(u&&u!==i.sessionId){if(l.size)k.warn(\"Preview reconnected; rejecting pending requests\",{count:l.size});for(let E of l.values())E.reject(new A(\"The preview reconnected. Retry the request.\",\"bridge_reset\"))}let h=!u;if(u=i.sessionId,m(i.state),h)for(let E of l.values())E.start();if(f)return;if(r===\"url\")c(\"runtimeReady\",{})},stateUpdate(i){m(i.state)},scriptLoad(i){if(r===\"bundle\")o?.(i.javascript)},result(i){l.get(i.id)?.resolve(i.response)},error(i){l.get(i.id)?.reject(new I(i.code,i.message,i.requestId))}}}),{send:c,receive:d}=y;function m(i){s=i;for(let h of g)h(i)}n.addEventListener(\"message\",d);function q(i,h){return new Promise((E,v)=>{if(f)return v(new A(\"The preview has closed.\",\"bridge_closed\"));if(h?.aborted)return v(h.reason);if(l.size>=te)return v(new A(\"Too many pending data requests.\",\"bridge_busy\"));let R=N(),U=!1;function L(){clearTimeout(le),h?.removeEventListener(\"abort\",Y),l.delete(R)}function Y(){if(U)c(\"cancel\",{id:R});L(),v(h?.reason)}let le=setTimeout(()=>{if(k.warn(\"Message request timed out\",{id:R,route:i.route,timeoutMs:t,sent:U}),U)c(\"cancel\",{id:R});L(),v(new A(u?\"The data request timed out.\":\"The preview shell is unavailable. Reload the preview.\",u?\"timeout\":\"bridge_unavailable\"))},t),W={start(){if(U)return;try{c(\"request\",{id:R,route:i.route,payload:i.payload}),U=!0}catch{L(),v(new A(\"The message payload could not be sent.\",\"invalid_payload\"))}},resolve(Q){L(),E(Q)},reject(Q){L(),v(Q)}};if(l.set(R,W),h?.addEventListener(\"abort\",Y,{once:!0}),u)W.start();else if(r===\"url\"||p)c(\"ready\",{})})}let j=de({\"data:query\":C(),\"data:sql\":V},q);function D(i,h,E){return j.request(\"data:query\",{operation:i,input:h},{signal:E}).catch(ne)}function O(){if(u)c(\"disconnect\",{});u=void 0;for(let i of l.values())i.reject(new A(\"The preview has closed.\",\"bridge_closed\"))}function x(i){if(i.persisted&&(r===\"url\"||p))c(\"ready\",{})}function S(){if(f)return;O(),f=!0,y.dispose(),n.removeEventListener(\"message\",d),n.removeEventListener(\"pagehide\",O),n.removeEventListener(\"pageshow\",x),g.clear()}if(n.addEventListener(\"pagehide\",O),n.addEventListener(\"pageshow\",x),r===\"url\")c(\"ready\",{});return{logger:k,request:q,transport:D,lakehouse:{queryAll(i,{limit:h,signal:E,params:v}){return j.request(\"data:sql\",{statement:i,limit:h,...v===void 0?{}:{params:v}},{signal:E}).catch(ne)}},dispose:S,mode:r,snapshot(){return s},subscribe(i){return g.add(i),()=>{g.delete(i)}},ready(){if(!f&&u)c(\"runtimeReady\",{})},fail(i){if(f||!u)return;if(i!==void 0)k.error(()=>[\"Data app failed\",we(i)]);c(\"runtimeError\",{})}}}var F=Symbol.for(\"altertable.localFrameBridge\"),B=Symbol.for(\"altertable.installedTransport\");function Z(e,n=window){let t=n;if(t[B])throw Error(\"A data app transport is already installed.\");return t[F]=e,t[B]=e,()=>{if(t[F]===e)delete t[F];if(t[B]===e)delete t[B];e.dispose()}}var je=Symbol(\"data-app.facetSource\");var Be=C();function ue({parentOrigin:e,window:n=window}){let t,r,o=`altertable-data-app-${N()}.js`,a=J({parentOrigin:e,window:n,mode:\"bundle\",loadScript(s){if(t!==void 0){if(s!==t)a.fail(Error(\"This frame already evaluated a different app script.\"));else if(r)a.fail(r.cause);else a.ready();return}t=s;try{let g=n.document.createElement(\"script\");if(g.textContent=`${s}\\n//# sourceURL=${o}`,n.document.body.append(g),!r)a.ready()}catch(g){p(g)}}});function p(s){r={cause:s},a.fail(s)}function u(s){if(s.filename===o)p(s.error??s.message)}function f(s){if(s.reason instanceof Error&&s.reason.stack?.includes(o))p(s.reason)}n.addEventListener(\"error\",u),n.addEventListener(\"unhandledrejection\",f);let l=Z(a,n);return()=>{n.removeEventListener(\"error\",u),n.removeEventListener(\"unhandledrejection\",f),l()}}var ce=document.currentScript?.dataset.parentOrigin;if(!ce)throw Error(\"Missing trusted parent origin.\");ue({parentOrigin:ce});})();\\n'.replace(/<\\/script/gi, (match) => `<\\\\${match.slice(1)}`);\nfunction runtimeHtml2(parentOrigin) {\n const attribute = parentOrigin.replaceAll(\"&\", \"&\").replaceAll('\"', \""\").replaceAll(\"<\", \"<\").replaceAll(\">\", \">\").replaceAll(\"'\", \"'\");\n return `<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <meta http-equiv=\"Content-Security-Policy\" content=\"${PAGE_CSP2}\">\n </head>\n <body>\n <div id=\"root\"></div>\n <script data-parent-origin=\"${attribute}\">${inlineBootstrap}</script>\n </body>\n</html>\n`;\n}\n\nexport { PAGE_CSP2, runtimeHtml2 };\n\n//# debugId=96DD2A8647500A6964756E2164756E21\n",
|
|
5
|
+
"//#region src/runtime-html.ts\nconst PAGE_CSP = \"default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; connect-src 'none'; form-action 'none'; base-uri 'none'\";\nconst inlineBootstrap = \"(()=>{function ye(e){return e===null||typeof e===\\\"string\\\"||typeof e===\\\"boolean\\\"||typeof e===\\\"number\\\"&&Number.isFinite(e)}function Q(e){return!!e&&typeof e===\\\"object\\\"&&!Array.isArray(e)&&Object.values(e).every(ye)}var ke=Symbol(\\\"data-app.dimensionSource\\\");var G=Symbol.for(\\\"@altertable/data-app/MessageRoutingError\\\"),S=class extends Error{code;requestId;[G]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[G]===!0}constructor(e,t,n,r){super(t,r);this.code=e,this.requestId=n,this.name=\\\"MessageRoutingError\\\"}};function he(e){return e}function M(e){return{operations:e,input(t){if(!t||typeof t!==\\\"object\\\")throw Error(\\\"Invalid query.\\\");let n=t;if(typeof n.operation!==\\\"string\\\"||!n.operation||n.operation.length>256||n.operation.includes(\\\"/\\\"))throw Error(\\\"Invalid operation.\\\");let r=e&&Object.hasOwn(e,n.operation)?e[n.operation]:void 0;if(e&&!r)throw Error(\\\"Unknown operation.\\\");return{operation:n.operation,input:r?r.input(n.input):n.input}},output(t){if(!t||typeof t!==\\\"object\\\")throw Error(\\\"Invalid data response.\\\");let n=t;if(!Number.isInteger(n.status)||n.status<100||n.status>599||!n.body||typeof n.body!==\\\"object\\\"||Array.isArray(n.body))throw Error(\\\"Invalid data response.\\\");let r=n.body;if(n.status<200||n.status>=300){let o=r.error;throw new S(typeof o?.code===\\\"string\\\"?o.code:\\\"request_failed\\\",typeof o?.message===\\\"string\\\"?o.message:\\\"Could not load data.\\\",typeof o?.requestId===\\\"string\\\"?o.requestId:void 0)}if(!(\\\"data\\\"in r)||typeof r.requestId!==\\\"string\\\"||typeof r.queriedAt!==\\\"string\\\"||!Array.isArray(r.queryIds)||!r.queryIds.every((o)=>typeof o===\\\"string\\\"))throw Error(\\\"Invalid data envelope.\\\");if(r.queries!==void 0&&(!Array.isArray(r.queries)||!r.queries.every((o)=>o&&typeof o===\\\"object\\\"&&typeof o.name===\\\"string\\\"&&typeof o.statement===\\\"string\\\"&&(o.params===void 0||Q(o.params))&&(o.queryId===void 0||typeof o.queryId===\\\"string\\\"))))throw Error(\\\"Invalid query evidence.\\\");return{status:n.status,body:r}}}}var X=he({input(e){if(!e||typeof e!==\\\"object\\\")throw Error(\\\"Invalid SQL query.\\\");let t=e;if(typeof t.statement!==\\\"string\\\"||!t.statement.trim()||typeof t.limit!==\\\"number\\\"||!Number.isSafeInteger(t.limit)||t.limit<1||t.params!==void 0&&!Q(t.params))throw Error(\\\"Invalid SQL query.\\\");return{statement:t.statement,limit:t.limit,...t.params===void 0?{}:{params:t.params}}},output(e,t){if(!e||typeof e!==\\\"object\\\")throw Error(\\\"Invalid query result.\\\");let n=e;if(!Array.isArray(n.columns)||!n.columns.every((r)=>r&&typeof r.name===\\\"string\\\"&&(r.type===void 0||typeof r.type===\\\"string\\\"))||!Array.isArray(n.rows)||n.rows.length>t.limit||!n.rows.every((r)=>Array.isArray(r)&&r.length===n.columns.length)||n.queryId!==void 0&&typeof n.queryId!==\\\"string\\\")throw Error(\\\"Invalid query result.\\\");return{columns:n.columns,rows:n.rows,...n.queryId===void 0?{}:{queryId:n.queryId}}}});function ee(e){if(!e||typeof e!==\\\"object\\\")return!1;let t=e;return typeof t.enabled===\\\"boolean\\\"&&(t.active===void 0||typeof t.active===\\\"boolean\\\")&&(t.pinsVisible===void 0||typeof t.pinsVisible===\\\"boolean\\\")&&(t.showHint===void 0||typeof t.showHint===\\\"boolean\\\")&&(t.readOnly===void 0||typeof t.readOnly===\\\"boolean\\\")&&(t.selectedAnnotationId===void 0||typeof t.selectedAnnotationId===\\\"string\\\"&&t.selectedAnnotationId.length<=128)&&(t.dismissal===void 0||t.dismissal!==null&&typeof t.dismissal===\\\"object\\\"&&typeof t.dismissal.id===\\\"string\\\"&&t.dismissal.id.length<=128&&typeof t.dismissal.occurredAt===\\\"number\\\"&&Number.isFinite(t.dismissal.occurredAt))&&(t.selectionId===void 0||typeof t.selectionId===\\\"string\\\"&&t.selectionId.length<=128)&&(t.selectedTargetId===void 0||typeof t.selectedTargetId===\\\"string\\\"&&t.selectedTargetId.length<=128)&&(t.targets===void 0||Array.isArray(t.targets)&&t.targets.length<=50&&t.targets.every((n)=>n&&typeof n.id===\\\"string\\\"&&n.id.length<=128&&typeof n.targetId===\\\"string\\\"&&n.targetId.length<=128&&Number.isSafeInteger(n.number)&&n.number>0&&(n.anchor===void 0||typeof n.anchor.x===\\\"number\\\"&&Number.isFinite(n.anchor.x)&&n.anchor.x>=0&&n.anchor.x<=1&&typeof n.anchor.y===\\\"number\\\"&&Number.isFinite(n.anchor.y)&&n.anchor.y>=0&&n.anchor.y<=1)&&(n.region===void 0||typeof n.region===\\\"object\\\"&&n.region!==null&&[\\\"x\\\",\\\"y\\\",\\\"width\\\",\\\"height\\\"].every((r)=>{let o=n.region[r];return typeof o===\\\"number\\\"&&Number.isFinite(o)&&o>=0&&o<=1})&&n.region.width>0&&n.region.height>0&&n.region.x+n.region.width<=1.000001&&n.region.y+n.region.height<=1.000001)&&(n.comment===void 0||typeof n.comment===\\\"string\\\"&&n.comment.length<=2000)))}function T(){if(typeof crypto.randomUUID===\\\"function\\\")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,(n)=>n.toString(16).padStart(2,\\\"0\\\"));return[t.slice(0,4),t.slice(4,6),t.slice(6,8),t.slice(8,10),t.slice(10)].map((n)=>n.join(\\\"\\\")).join(\\\"-\\\")}function be(e){if(!e||typeof e!==\\\"object\\\")return!1;let t=e;return(t.method===\\\"log\\\"||t.method===\\\"info\\\"||t.method===\\\"warn\\\"||t.method===\\\"error\\\")&&Array.isArray(t.args)&&t.args.length<=128}var Z=\\\"altertable:data-app\\\";var oe=60000;function R(e){return typeof e===\\\"string\\\"&&/^[a-zA-Z0-9_-]{1,128}$/.test(e)}function h({wire:e,from:t,session:n,parse:r}){return{wire:e,from:t,session:n,parse:r}}function C(e){if(!R(e.id))throw Error(\\\"Invalid request ID.\\\");return e.id}function P(e,t){let n=e[t];if(typeof n!==\\\"string\\\")throw Error(`Invalid ${t}.`);return n}function B(e,t){let n=e[t];if(typeof n!==\\\"number\\\"||!Number.isFinite(n)||n<0)throw Error(`Invalid ${t}.`);return n}function _(){return{}}var I={channel:Z,version:1,events:{connect:h({wire:\\\"bridge:connect\\\",from:\\\"host\\\",session:\\\"none\\\",parse:_}),ready:h({wire:\\\"bridge:ready\\\",from:\\\"app\\\",session:\\\"none\\\",parse:_}),initialize:h({wire:\\\"bridge:initialize\\\",from:\\\"host\\\",session:\\\"establish\\\",parse:(e)=>({state:e.state})}),request:h({wire:\\\"bridge:request\\\",from:\\\"app\\\",session:\\\"current\\\",parse:(e)=>{let t=P(e,\\\"route\\\");if(!t||t.length>256)throw Error(\\\"Invalid message route.\\\");return{id:C(e),route:t,payload:e.payload}}}),result:h({wire:\\\"bridge:result\\\",from:\\\"host\\\",session:\\\"current\\\",parse:(e)=>{if(!Object.hasOwn(e,\\\"response\\\"))throw Error(\\\"Missing response.\\\");return{id:C(e),response:e.response}}}),error:h({wire:\\\"bridge:error\\\",from:\\\"host\\\",session:\\\"current\\\",parse:(e)=>{if(e.requestId!==void 0&&typeof e.requestId!==\\\"string\\\")throw Error(\\\"Invalid requestId.\\\");return{id:C(e),code:P(e,\\\"code\\\"),message:P(e,\\\"message\\\"),...e.requestId===void 0?{}:{requestId:e.requestId}}}}),cancel:h({wire:\\\"bridge:cancel\\\",from:\\\"app\\\",session:\\\"current\\\",parse:(e)=>({id:C(e)})}),disconnect:h({wire:\\\"bridge:disconnect\\\",from:\\\"app\\\",session:\\\"current\\\",parse:_}),scriptLoad:h({wire:\\\"script:load\\\",from:\\\"host\\\",session:\\\"current\\\",parse:(e)=>({javascript:P(e,\\\"javascript\\\")})}),stateUpdate:h({wire:\\\"state:update\\\",from:\\\"host\\\",session:\\\"current\\\",parse:(e)=>({state:e.state})}),runtimeLog:h({wire:\\\"runtime:log\\\",from:\\\"app\\\",session:\\\"current\\\",parse:(e)=>{if(!be(e.payload))throw Error(\\\"Invalid log entry.\\\");return{payload:e.payload}}}),runtimeReady:h({wire:\\\"runtime:ready\\\",from:\\\"app\\\",session:\\\"current\\\",parse:_}),runtimeError:h({wire:\\\"runtime:error\\\",from:\\\"app\\\",session:\\\"current\\\",parse:_}),runtimeResize:h({wire:\\\"runtime:resize\\\",from:\\\"app\\\",session:\\\"current\\\",parse:(e)=>({height:B(e,\\\"height\\\")})}),viewportUpdate:h({wire:\\\"viewport:update\\\",from:\\\"host\\\",session:\\\"current\\\",parse:(e)=>({top:B(e,\\\"top\\\"),bottom:B(e,\\\"bottom\\\")})})}};function te(e){let t={type:e.type};if(\\\"id\\\"in e)t.id=e.id;if(e.type===\\\"bridge:request\\\"){t.route=e.route;let n=e.payload;if(e.route===\\\"data:query\\\"&&n&&typeof n===\\\"object\\\"&&\\\"operation\\\"in n&&typeof n.operation===\\\"string\\\")t.operation=n.operation.slice(0,256)}if(e.type===\\\"bridge:error\\\")t.error={code:e.code,message:e.message,...e.requestId===void 0?{}:{requestId:e.requestId}};return t}var J=new Map;for(let e of Object.keys(I.events)){let t=I.events[e].wire;if(J.has(t))throw Error(`Duplicate bridge event: ${t}`);J.set(t,e)}function ie(e){return J.get(e)}function se(e){if(!e||typeof e!==\\\"object\\\")return;let t=e;if(t.channel!==Z||t.version!==I.version||typeof t.type!==\\\"string\\\"||typeof t.documentId!==\\\"string\\\"||!t.documentId||t.documentId.length>128||t.sessionId!==void 0&&!R(t.sessionId)||t.token!==void 0&&typeof t.token!==\\\"string\\\")return;return t}function ae(e,t){try{return{channel:Z,version:I.version,documentId:e.documentId,...e.sessionId===void 0?{}:{sessionId:e.sessionId},...e.token===void 0?{}:{token:e.token},type:t.wire,...t.parse(e)}}catch{return}}function ge(e){let t=se(e);if(!t)return;let n=ie(t.type);if(!n)return;let r=I.events[n];if(r.session!==\\\"none\\\"&&t.sessionId===void 0)return;return ae(t,r)}function ce({role:e,origin:t,source:n,opaque:r,context:o,post:a,diagnostic:p,invalidRequest:u,handlers:f}){let m=!1;function s(c,l){p?.({direction:\\\"drop\\\",reason:c,...typeof l===\\\"string\\\"?{type:l.slice(0,64)}:{}})}function b(c,l){if(m)throw Error(\\\"The bridge endpoint has closed.\\\");let d=I.events[c],y=o(),q=ge({...l,channel:I.channel,version:I.version,type:d.wire,documentId:c===\\\"connect\\\"?\\\"host\\\":y.documentId,sessionId:y.sessionId,token:r?y.token:void 0});if(!q||r&&!R(y.token))throw Error(\\\"The bridge is not ready to send this event.\\\");if(p?.({direction:\\\"send\\\",...te(q)}),m)return;a(q)}function w(c){let l=n();if(m||!l||c.origin!==t||c.source!==l)return;let d=se(c.data);if(!d){let A=c.data;if(A&&typeof A===\\\"object\\\"&&\\\"channel\\\"in A&&A.channel===I.channel)s(\\\"invalid_envelope\\\",\\\"type\\\"in A?A.type:void 0);return}let y=o(),q=e===\\\"app\\\"&&d.type===I.events.connect.wire;if(r&&(q?!R(d.token):!y.token||d.token!==y.token))return s(\\\"token_mismatch\\\",d.type);let j=ie(d.type);if(!j)return s(\\\"unexpected_type\\\",d.type);let D=I.events[j];if(D.from===e)return s(\\\"unexpected_type\\\",d.type);if(D.session===\\\"establish\\\"){if(d.documentId!==y.documentId||d.sessionId===void 0)return s(\\\"session_mismatch\\\",d.type)}else if(D.session===\\\"current\\\"){if(!y.sessionId||d.sessionId!==y.sessionId||d.documentId!==y.documentId)return s(\\\"session_mismatch\\\",d.type)}let N=ae(d,D);if(!N){if(s(\\\"invalid_payload\\\",d.type),e===\\\"host\\\"&&j===\\\"request\\\"&&R(d.id))u?.(d.id);return}if(p?.({direction:\\\"receive\\\",...te(N)}),m)return;let L=f[j];L(N)}return{send:b,receive:w,dispose(){m=!0}}}function ue(e){if(!e||typeof e!==\\\"object\\\")return!1;let t=e;return(t.surface===\\\"embedded\\\"||t.surface===\\\"standalone\\\")&&(t.theme===\\\"light\\\"||t.theme===\\\"dark\\\")&&(t.annotations===void 0||ee(t.annotations))&&(t.sizing===void 0||t.sizing===\\\"frame\\\"||t.sizing===\\\"content\\\")}function we(e,t){let{documentElement:n,defaultView:r}=e,o,a,p=!1,u=0,f;function m(){let c=Math.ceil(n.getBoundingClientRect().height);if(c===a&&c!==r?.innerHeight)return;a=c,t(c)}function s(){o?.disconnect(),o=void 0,r?.removeEventListener(\\\"resize\\\",m),a=void 0,delete n.dataset.atblFrameSizing,n.style.removeProperty(\\\"--atbl-frame-inset-top\\\"),n.style.removeProperty(\\\"--atbl-frame-inset-bottom\\\")}function b(){if(!o||!f)return;n.style.setProperty(\\\"--atbl-frame-inset-top\\\",`${f.top}px`),n.style.setProperty(\\\"--atbl-frame-inset-bottom\\\",`${f.bottom}px`)}function w(){if(!p||!u)return s();if(o)return;n.dataset.atblFrameSizing=\\\"content\\\",o=new(e.defaultView??globalThis).ResizeObserver(m),o.observe(n),r?.addEventListener(\\\"resize\\\",m),b()}return{update(c,l){let d=c&&typeof c===\\\"object\\\"&&\\\"presentation\\\"in c?c.presentation:void 0;if(p=ue(d)&&d.sizing===\\\"content\\\",!p)f=void 0;if(l===\\\"new\\\")a=void 0;if(o&&p)m();w()},support(){u++,w();let c=!1;return()=>{if(c)return;c=!0,u--,w()}},viewport(c,l){if(!p)return;f={top:c,bottom:l},b()},dispose(){p=!1,f=void 0,u=0,s()}}}function ve(e,t){function n(o){if(o.length===1&&typeof o[0]===\\\"function\\\"){let a=o[0]();return Array.isArray(a)?a:[a]}return o.map((a)=>typeof a===\\\"function\\\"?a():a)}function r(o,a){if(!e())return;try{t({method:o,args:n(a)})}catch{}}return{log:(...o)=>r(\\\"log\\\",o),info:(...o)=>r(\\\"info\\\",o),warn:(...o)=>r(\\\"warn\\\",o),error:(...o)=>r(\\\"error\\\",o)}}var Ie={send:\\\"Sending message to parent\\\",receive:\\\"Received message from parent\\\",drop:\\\"Ignored message from parent\\\"};function Ee(e,{direction:t,...n}){if(n.type===\\\"runtime:log\\\"||n.type===\\\"runtime:resize\\\"||n.type===\\\"viewport:update\\\")return;e.log(Ie[t],n)}function Ae(e){if(e instanceof Error)return{name:e.name,message:e.message,...e.stack?{stack:e.stack}:{}};return{message:String(e)}}function de(e,t){return{async request(n,r,{signal:o}={}){if(o?.throwIfAborted(),!Object.hasOwn(e,n))throw new S(\\\"unknown_route\\\",\\\"Unknown message route.\\\");let a=e[n],p;try{p=a.input(r)}catch{throw new S(\\\"invalid_payload\\\",\\\"Invalid message payload.\\\")}let u=await t({route:n,payload:p},o);o?.throwIfAborted();try{return a.output(u,p)}catch(f){if(f instanceof S)throw f;throw new S(\\\"invalid_response\\\",\\\"Invalid message response.\\\")}}}}var ne=Symbol.for(\\\"@altertable/data-app/DataAppError\\\"),k=class extends Error{code;requestId;[ne]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&e[ne]===!0}constructor(e,t,n){super(e);this.code=t,this.requestId=n,this.name=\\\"DataAppError\\\"}};function re(e){if(e instanceof S)throw new k(e.message,e.code,e.requestId);throw e}function W({parentOrigin:e,window:t=window,timeoutMs:n=oe,mode:r=\\\"url\\\",loadScript:o}){if(new URL(e).origin!==e)throw Error(\\\"Expected an exact parent origin.\\\");let a=T(),p,u,f=!1,m=new Map,s,b=new Set,w=ve(()=>!f&&!!u&&!!s&&typeof s===\\\"object\\\"&&(\\\"logging\\\"in s)&&s.logging===!0,(i)=>l(\\\"runtimeLog\\\",{payload:i})),c=ce({role:\\\"app\\\",origin:e,source:()=>t.parent,opaque:r===\\\"bundle\\\",context:()=>({documentId:a,sessionId:u,token:p}),post(i){t.parent.postMessage(i,e)},diagnostic:(i)=>Ee(w,i),handlers:{connect(i){if(r===\\\"bundle\\\")p=i.token;l(\\\"ready\\\",{})},initialize(i){if(u&&u!==i.sessionId){if(m.size)w.warn(\\\"Preview reconnected; rejecting pending requests\\\",{count:m.size});for(let v of m.values())v.reject(new k(\\\"The preview reconnected. Retry the request.\\\",\\\"bridge_reset\\\"))}let g=!u;if(u=i.sessionId,q(i.state,\\\"new\\\"),g)for(let v of m.values())v.start();if(f)return;if(r===\\\"url\\\")l(\\\"runtimeReady\\\",{})},stateUpdate(i){q(i.state,\\\"current\\\")},viewportUpdate(i){y.viewport(i.top,i.bottom)},scriptLoad(i){if(r===\\\"bundle\\\")o?.(i.javascript)},result(i){m.get(i.id)?.resolve(i.response)},error(i){m.get(i.id)?.reject(new S(i.code,i.message,i.requestId))}}}),{send:l,receive:d}=c,y=we(t.document,(i)=>{if(!f&&u)l(\\\"runtimeResize\\\",{height:i})});function q(i,g){s=i,y.update(i,g);for(let v of b)v(i)}t.addEventListener(\\\"message\\\",d);function j(i,g){return new Promise((v,E)=>{if(f)return E(new k(\\\"The preview has closed.\\\",\\\"bridge_closed\\\"));if(g?.aborted)return E(g.reason);if(m.size>=128)return E(new k(\\\"Too many pending data requests.\\\",\\\"bridge_busy\\\"));let O=T(),U=!1;function x(){clearTimeout(me),g?.removeEventListener(\\\"abort\\\",H),m.delete(O)}function H(){if(U)l(\\\"cancel\\\",{id:O});x(),E(g?.reason)}let me=setTimeout(()=>{if(w.warn(\\\"Message request timed out\\\",{id:O,route:i.route,timeoutMs:n,sent:U}),U)l(\\\"cancel\\\",{id:O});x(),E(new k(u?\\\"The data request timed out.\\\":\\\"The preview shell is unavailable. Reload the preview.\\\",u?\\\"timeout\\\":\\\"bridge_unavailable\\\"))},n),V={start(){if(U)return;try{l(\\\"request\\\",{id:O,route:i.route,payload:i.payload}),U=!0}catch{x(),E(new k(\\\"The message payload could not be sent.\\\",\\\"invalid_payload\\\"))}},resolve(F){x(),v(F)},reject(F){x(),E(F)}};if(m.set(O,V),g?.addEventListener(\\\"abort\\\",H,{once:!0}),u)V.start();else if(r===\\\"url\\\"||p)l(\\\"ready\\\",{})})}let D=de({\\\"data:query\\\":M(),\\\"data:sql\\\":X},j);function N(i,g,v){return D.request(\\\"data:query\\\",{operation:i,input:g},{signal:v}).catch(re)}function L(){if(u)l(\\\"disconnect\\\",{});u=void 0;for(let i of m.values())i.reject(new k(\\\"The preview has closed.\\\",\\\"bridge_closed\\\"))}function A(i){if(i.persisted&&(r===\\\"url\\\"||p))l(\\\"ready\\\",{})}function fe(){if(f)return;L(),f=!0,c.dispose(),y.dispose(),t.removeEventListener(\\\"message\\\",d),t.removeEventListener(\\\"pagehide\\\",L),t.removeEventListener(\\\"pageshow\\\",A),b.clear()}if(t.addEventListener(\\\"pagehide\\\",L),t.addEventListener(\\\"pageshow\\\",A),r===\\\"url\\\")l(\\\"ready\\\",{});return{logger:w,request:j,transport:N,lakehouse:{queryAll(i,{limit:g,signal:v,params:E}){return D.request(\\\"data:sql\\\",{statement:i,limit:g,...E===void 0?{}:{params:E}},{signal:v}).catch(re)}},dispose:fe,mode:r,snapshot(){return s},subscribe(i){return b.add(i),()=>{b.delete(i)}},ready(){if(!f&&u)l(\\\"runtimeReady\\\",{})},supportContentSizing(){return y.support()},fail(i){if(f||!u)return;if(i!==void 0)w.error(()=>[\\\"Data app failed\\\",Ae(i)]);l(\\\"runtimeError\\\",{})}}}var K=Symbol.for(\\\"altertable.localFrameBridge\\\"),z=Symbol.for(\\\"altertable.installedTransport\\\");function Y(e,t=window){let n=t;if(n[z])throw Error(\\\"A data app transport is already installed.\\\");return n[K]=e,n[z]=e,()=>{if(n[K]===e)delete n[K];if(n[z]===e)delete n[z];e.dispose()}}var Je=M();var He=Symbol(\\\"data-app.facetSource\\\");function le({parentOrigin:e,window:t=window}){let n,r,o=`altertable-data-app-${T()}.js`,a=W({parentOrigin:e,window:t,mode:\\\"bundle\\\",loadScript(s){if(n!==void 0){if(s!==n)a.fail(Error(\\\"This frame already evaluated a different app script.\\\"));else if(r)a.fail(r.cause);else a.ready();return}n=s;try{let b=t.document.createElement(\\\"script\\\");if(b.textContent=`${s}\\n//# sourceURL=${o}`,t.document.body.append(b),!r)a.ready()}catch(b){p(b)}}});function p(s){r={cause:s},a.fail(s)}function u(s){if(s.filename===o)p(s.error??s.message)}function f(s){if(s.reason instanceof Error&&s.reason.stack?.includes(o))p(s.reason)}t.addEventListener(\\\"error\\\",u),t.addEventListener(\\\"unhandledrejection\\\",f);let m=Y(a,t);return()=>{t.removeEventListener(\\\"error\\\",u),t.removeEventListener(\\\"unhandledrejection\\\",f),m()}}var pe=document.currentScript?.dataset.parentOrigin;if(!pe)throw Error(\\\"Missing trusted parent origin.\\\");le({parentOrigin:pe});})();\\n\".replace(/<\\/script/gi, (match) => `<\\\\${match.slice(1)}`);\nfunction runtimeHtml(parentOrigin) {\n\tconst attribute = parentOrigin.replaceAll(\"&\", \"&\").replaceAll(\"\\\"\", \""\").replaceAll(\"<\", \"<\").replaceAll(\">\", \">\").replaceAll(\"'\", \"'\");\n\treturn `<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <meta http-equiv=\"Content-Security-Policy\" content=\"${PAGE_CSP}\">\n </head>\n <body>\n <div id=\"root\"></div>\n <script data-parent-origin=\"${attribute}\">${inlineBootstrap}<\\/script>\n </body>\n</html>\n`;\n}\n//#endregion\nexport { PAGE_CSP, runtimeHtml };\n\n//# sourceMappingURL=runtime-html.js.map",
|
|
6
6
|
"function exactOrigin(value: string) {\n const url = new URL(value);\n if (!/^https?:$/.test(url.protocol) || url.origin !== value) {\n throw new Error('Expected an exact HTTP(S) parent origin.');\n }\n\n return url;\n}\n\n// Selection can only choose an origin approved by deployment configuration.\nexport function trustedParent(config: string, searchParams: URLSearchParams) {\n if (typeof config !== 'string' || !config.trim()) {\n throw new Error('Missing trusted parent origins.');\n }\n const allowed = config\n .trim()\n .split(/\\s+/)\n .map(value => {\n const wildcard = value.startsWith('https://*.');\n const url = exactOrigin(wildcard ? value.replace('*.', '') : value);\n if (url.hostname.includes('*') || (wildcard && url.port)) {\n throw new Error('Invalid parent origin pattern.');\n }\n\n return { value, url, wildcard };\n });\n const requested = searchParams.getAll('__altertable_parent');\n if (!requested.length) {\n const fallback = allowed.find(origin => !origin.wildcard);\n if (!fallback)\n throw new Error('An exact default parent origin is required.');\n\n return fallback.value;\n }\n if (requested.length !== 1) return null;\n let url: URL;\n try {\n url = exactOrigin(requested[0]!);\n } catch {\n return null;\n }\n const permitted = allowed.some(origin => {\n if (!origin.wildcard) return origin.value === requested[0];\n if (url.protocol !== 'https:' || url.port) return false;\n const suffix = `.${origin.url.hostname}`;\n\n return (\n url.hostname.endsWith(suffix) &&\n /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(\n url.hostname.slice(0, -suffix.length)\n )\n );\n });\n\n return permitted ? requested[0]! : null;\n}\n",
|
|
7
|
-
"import { PAGE_CSP, runtimeHtml } from '@altertable/data-app-embed/runtime';\nimport { trustedParent } from './trusted-parent.ts';\n\ninterface WorkerBindings {\n DOMAIN_NAME: string;\n PARENT_ORIGINS: string;\n}\n\n// Hosts own the label format (e.g. `<prefix>-<base36 id>` or legacy `<prefix>-app-<n>`); accept any hyphenated DNS label.\nconst TOKEN_RE = /^(?=.{1,63}$)[a-z0-9]+(?:-+[a-z0-9]+)+$/;\nfunction isPreviewHost(hostname: string, domainName: string) {\n const suffix = `.${domainName}`;\n\n return (\n hostname.endsWith(suffix) &&\n TOKEN_RE.test(hostname.slice(0, -suffix.length))\n );\n}\n\nconst worker: {\n runtimeHtml(parentOrigin: string): string;\n fetch(request: Request, env: WorkerBindings): Response;\n} = {\n runtimeHtml,\n fetch(request: Request, env: WorkerBindings) {\n const url = new URL(request.url);\n if (!isPreviewHost(url.hostname, env.DOMAIN_NAME) || url.pathname !== '/') {\n return new Response(null, { status: 404 });\n }\n if (request.method !== 'GET' && request.method !== 'HEAD') {\n return new Response(null, {\n status: 405,\n headers: { Allow: 'GET, HEAD' },\n });\n }\n let parent: string | null;\n try {\n parent = trustedParent(env.PARENT_ORIGINS, url.searchParams);\n } catch {\n return new Response(null, { status: 503 });\n }\n if (!parent) return new Response(null, { status: 403 });\n\n return new Response(\n request.method === 'HEAD' ? null : runtimeHtml(parent),\n {\n headers: {\n 'Content-Type': 'text/html; charset=utf-8',\n 'Content-Security-Policy': `${PAGE_CSP}; frame-ancestors ${env.PARENT_ORIGINS.trim().split(/\\s+/).join(' ')}`,\n 'X-Content-Type-Options': 'nosniff',\n 'Referrer-Policy': 'no-referrer',\n },\n }\n );\n },\n};\n\nexport default worker;\n"
|
|
7
|
+
"import { PAGE_CSP, runtimeHtml } from '@altertable/data-app-embed/runtime';\n\nimport { trustedParent } from './trusted-parent.ts';\n\ninterface WorkerBindings {\n DOMAIN_NAME: string;\n PARENT_ORIGINS: string;\n}\n\n// Hosts own the label format (e.g. `<prefix>-<base36 id>` or legacy `<prefix>-app-<n>`); accept any hyphenated DNS label.\nconst TOKEN_RE = /^(?=.{1,63}$)[a-z0-9]+(?:-+[a-z0-9]+)+$/;\nfunction isPreviewHost(hostname: string, domainName: string) {\n const suffix = `.${domainName}`;\n\n return (\n hostname.endsWith(suffix) &&\n TOKEN_RE.test(hostname.slice(0, -suffix.length))\n );\n}\n\nconst worker: {\n runtimeHtml(parentOrigin: string): string;\n fetch(request: Request, env: WorkerBindings): Response;\n} = {\n runtimeHtml,\n fetch(request: Request, env: WorkerBindings) {\n const url = new URL(request.url);\n if (!isPreviewHost(url.hostname, env.DOMAIN_NAME) || url.pathname !== '/') {\n return new Response(null, { status: 404 });\n }\n if (request.method !== 'GET' && request.method !== 'HEAD') {\n return new Response(null, {\n status: 405,\n headers: { Allow: 'GET, HEAD' },\n });\n }\n let parent: string | null;\n try {\n parent = trustedParent(env.PARENT_ORIGINS, url.searchParams);\n } catch {\n return new Response(null, { status: 503 });\n }\n if (!parent) return new Response(null, { status: 403 });\n\n return new Response(\n request.method === 'HEAD' ? null : runtimeHtml(parent),\n {\n headers: {\n 'Content-Type': 'text/html; charset=utf-8',\n 'Content-Security-Policy': `${PAGE_CSP}; frame-ancestors ${env.PARENT_ORIGINS.trim().split(/\\s+/).join(' ')}`,\n 'X-Content-Type-Options': 'nosniff',\n 'Referrer-Policy': 'no-referrer',\n },\n }\n );\n },\n};\n\nexport default worker;\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";AACA,
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";AACA,IAAM,WAAW;AACjB,IAAM,kBAAkB,u9hBAAqgjB,QAAQ,eAAe,CAAC,UAAU,MAAM,MAAM,MAAM,CAAC,GAAG;AACrljB,SAAS,WAAW,CAAC,cAAc;AAAA,EAClC,MAAM,YAAY,aAAa,WAAW,KAAK,OAAO,EAAE,WAAW,KAAM,QAAQ,EAAE,WAAW,KAAK,MAAM,EAAE,WAAW,KAAK,MAAM,EAAE,WAAW,KAAK,OAAO;AAAA,EAC1J,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,0DAKkD;AAAA;AAAA;AAAA;AAAA,kCAIxB,cAAc;AAAA;AAAA;AAAA;AAAA;;;ACdhD,SAAS,WAAW,CAAC,OAAe;AAAA,EAClC,MAAM,MAAM,IAAI,IAAI,KAAK;AAAA,EACzB,IAAI,CAAC,YAAY,KAAK,IAAI,QAAQ,KAAK,IAAI,WAAW,OAAO;AAAA,IAC3D,MAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AAAA,EAEA,OAAO;AAAA;AAIF,SAAS,aAAa,CAAC,QAAgB,cAA+B;AAAA,EAC3E,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,KAAK,GAAG;AAAA,IAChD,MAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAAA,EACA,MAAM,UAAU,OACb,KAAK,EACL,MAAM,KAAK,EACX,IAAI,WAAS;AAAA,IACZ,MAAM,WAAW,MAAM,WAAW,YAAY;AAAA,IAC9C,MAAM,MAAM,YAAY,WAAW,MAAM,QAAQ,MAAM,EAAE,IAAI,KAAK;AAAA,IAClE,IAAI,IAAI,SAAS,SAAS,GAAG,KAAM,YAAY,IAAI,MAAO;AAAA,MACxD,MAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AAAA,IAEA,OAAO,EAAE,OAAO,KAAK,SAAS;AAAA,GAC/B;AAAA,EACH,MAAM,YAAY,aAAa,OAAO,qBAAqB;AAAA,EAC3D,IAAI,CAAC,UAAU,QAAQ;AAAA,IACrB,MAAM,WAAW,QAAQ,KAAK,YAAU,CAAC,OAAO,QAAQ;AAAA,IACxD,IAAI,CAAC;AAAA,MACH,MAAM,IAAI,MAAM,6CAA6C;AAAA,IAE/D,OAAO,SAAS;AAAA,EAClB;AAAA,EACA,IAAI,UAAU,WAAW;AAAA,IAAG,OAAO;AAAA,EACnC,IAAI;AAAA,EACJ,IAAI;AAAA,IACF,MAAM,YAAY,UAAU,EAAG;AAAA,IAC/B,MAAM;AAAA,IACN,OAAO;AAAA;AAAA,EAET,MAAM,YAAY,QAAQ,KAAK,YAAU;AAAA,IACvC,IAAI,CAAC,OAAO;AAAA,MAAU,OAAO,OAAO,UAAU,UAAU;AAAA,IACxD,IAAI,IAAI,aAAa,YAAY,IAAI;AAAA,MAAM,OAAO;AAAA,IAClD,MAAM,SAAS,IAAI,OAAO,IAAI;AAAA,IAE9B,OACE,IAAI,SAAS,SAAS,MAAM,KAC5B,oCAAoC,KAClC,IAAI,SAAS,MAAM,GAAG,CAAC,OAAO,MAAM,CACtC;AAAA,GAEH;AAAA,EAED,OAAO,YAAY,UAAU,KAAM;AAAA;;;AC5CrC,IAAM,WAAW;AACjB,SAAS,aAAa,CAAC,UAAkB,YAAoB;AAAA,EAC3D,MAAM,SAAS,IAAI;AAAA,EAEnB,OACE,SAAS,SAAS,MAAM,KACxB,SAAS,KAAK,SAAS,MAAM,GAAG,CAAC,OAAO,MAAM,CAAC;AAAA;AAInD,IAAM,SAGF;AAAA,EACF;AAAA,EACA,KAAK,CAAC,SAAkB,KAAqB;AAAA,IAC3C,MAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAAA,IAC/B,IAAI,CAAC,cAAc,IAAI,UAAU,IAAI,WAAW,KAAK,IAAI,aAAa,KAAK;AAAA,MACzE,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC3C;AAAA,IACA,IAAI,QAAQ,WAAW,SAAS,QAAQ,WAAW,QAAQ;AAAA,MACzD,OAAO,IAAI,SAAS,MAAM;AAAA,QACxB,QAAQ;AAAA,QACR,SAAS,EAAE,OAAO,YAAY;AAAA,MAChC,CAAC;AAAA,IACH;AAAA,IACA,IAAI;AAAA,IACJ,IAAI;AAAA,MACF,SAAS,cAAc,IAAI,gBAAgB,IAAI,YAAY;AAAA,MAC3D,MAAM;AAAA,MACN,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AAAA;AAAA,IAE3C,IAAI,CAAC;AAAA,MAAQ,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AAAA,IAEtD,OAAO,IAAI,SACT,QAAQ,WAAW,SAAS,OAAO,YAAY,MAAM,GACrD;AAAA,MACE,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,2BAA2B,GAAG,6BAA6B,IAAI,eAAe,KAAK,EAAE,MAAM,KAAK,EAAE,KAAK,GAAG;AAAA,QAC1G,0BAA0B;AAAA,QAC1B,mBAAmB;AAAA,MACrB;AAAA,IACF,CACF;AAAA;AAEJ;AAEA,IAAe;",
|
|
10
|
+
"debugId": "F48BFCF99E3508F964756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
1
2
|
interface WorkerBindings {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
DOMAIN_NAME: string;
|
|
4
|
+
PARENT_ORIGINS: string;
|
|
4
5
|
}
|
|
5
6
|
declare const worker: {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
runtimeHtml(parentOrigin: string): string;
|
|
8
|
+
fetch(request: Request, env: WorkerBindings): Response;
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
//#endregion
|
|
11
|
+
export { worker as default };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altertable/data-app-worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.73.0",
|
|
4
4
|
"description": "Self-contained sandbox Worker for serving Altertable data apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"altertable",
|
|
@@ -42,9 +42,10 @@
|
|
|
42
42
|
"registry": "https://registry.npmjs.org"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"build": "bun ../../scripts/build.ts data-app-worker"
|
|
45
|
+
"build": "bun ../../scripts/build.ts data-app-worker",
|
|
46
|
+
"typecheck": "bun ../../node_modules/typescript/bin/tsc --noEmit -p tsconfig.build.json"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@altertable/data-app-embed": "0.
|
|
49
|
+
"@altertable/data-app-embed": "0.73.0"
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function trustedParent(config: string, searchParams: URLSearchParams): string | null;
|