@wix/himalaya-cli 0.1633.0 → 0.1634.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/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-feed-viewer/src/index.d.ts +10 -6
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-v1/src/index.d.ts +34 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members-feed-viewer.mjs +8 -7
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members.mjs +29 -0
- package/dist/browser-plane/assets.json +166 -0
- package/dist/browser-plane/host.html +156 -0
- package/dist/browser-plane/package-reader.js +4 -0
- package/dist/browser-plane/preview-deferred/368faca44fb9f7207e4af784e94750b1ee59c1098b8689e0f4a918926f244fb5.bin +0 -0
- package/dist/browser-plane/preview-deferred/37c179b4fefb63ea9637322b84583a2df53aa226c150294eea1675c14b1b8e29.bin +0 -0
- package/dist/browser-plane/preview-deferred/4ecf270136af928612c76fe4ebade91d8156975e5ea4c0cf9225501dd1788e02.bin +0 -0
- package/dist/browser-plane/preview-deferred/521a0e528916d678d7588b2cddf3dadd3bb959a6d62426382f61c77a82017e35.bin +1 -0
- package/dist/browser-plane/preview-deferred/62e2fe4718129f36ecdb0ae4de385bd6b81ecc876146447167c6c140fad699a9.bin +0 -0
- package/dist/browser-plane/preview-deferred/642feab8a48ddf6c7a89d7c2a7c0edfa0e6e773f671287e460e222703563191e.bin +0 -0
- package/dist/browser-plane/preview-deferred/97ed8f1a6772abe26e3d8af5cecfc4b02faa94497d585b0398b5053b739a70c1.bin +0 -0
- package/dist/browser-plane/preview-deferred/a33cfe728c584fdba4fcc1fd54bcdc2f9f2f13889ddbb5b2bd1d0f8cbe49b84e.bin +28 -0
- package/dist/browser-plane/preview-deferred/bf4c16a2774edd38a921edf3099469866cd74c094fd596f3fa4e81f54a04dfaa.bin +0 -0
- package/dist/browser-plane/preview-deferred/c3457ce58c96b65f303fec0ddf5f06733004eaf9e21e62302b155ec63a7765f7.bin +56 -0
- package/dist/browser-plane/preview-deferred/d7598e12c5dbef095ff8272cfc55da0250bd07fbdecbac8a530b9b277872a134.bin +0 -0
- package/dist/browser-plane/preview-deferred/dced97a77624bc5f8b1ae65850360908297f4588e09feb6f22792d29dc7e765b.bin +0 -0
- package/dist/browser-plane/preview-deferred/dee56f09fd3efc127c1ea95557edc74110c1460a46287da36e0af25efd341ef5.bin +0 -0
- package/dist/browser-plane/preview-deferred/ec4c7d63772d980d6e147b2df6215fd2737e4b04cebe0cf7e11dc695fb63cdcf.bin +0 -0
- package/dist/browser-plane/sw.js +13 -0
- package/dist/browser-plane/t5-frame.html +350 -0
- package/dist/browser-plane/t5-worker-frame.html +350 -0
- package/dist/cli.mjs +6412 -5067
- package/dist/preview-assets.generated.bin +0 -0
- package/fixtures/wix-canned.json +31 -1
- package/guides/himi-json-output.md +2 -0
- package/guides/one-app-to-himi-app.md +81 -5
- package/guides/sdk-reference.json +34 -3
- package/package.json +3 -3
- package/templates/beauty-salon/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/branded-lite/config.ts +7 -0
- package/templates/branded-lite/dev/index.ts +719 -83
- package/templates/branded-lite/himalaya.content.json +3 -0
- package/templates/branded-lite/l10n/en.json +4 -2
- package/templates/branded-lite/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/branded-lite/tier5-src/_shared/business-chat-history.ts +4 -1
- package/templates/branded-lite/tier5-src/_shared/business-chat-presenter.ts +2 -7
- package/templates/branded-lite/tier5-src/_shared/header-badges.ts +1 -1
- package/templates/branded-lite/tier5-src/_shared/inbox-rooms.ts +68 -0
- package/templates/branded-lite/tier5-src/_shared/member-activity.ts +34 -0
- package/templates/branded-lite/tier5-src/_shared/member-row-extras.ts +167 -0
- package/templates/branded-lite/tier5-src/_shared/notification-target.ts +141 -0
- package/templates/branded-lite/tier5-src/_shared/source-badges.ts +6 -4
- package/templates/branded-lite/tier5-src/_shared/wix-member-links.ts +114 -0
- package/templates/branded-lite/tier5-src/business-chat/index.ts +114 -59
- package/templates/branded-lite/tier5-src/himi-branded-lite-inbox/index.ts +83 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-notifications/index.ts +62 -7
- package/templates/branded-lite/tier5-src/wix-spaces-members/index.ts +60 -12
- package/templates/community-club/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/events-meetups/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/gym-fitness/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/nonprofit-cause/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/podcast-creator/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/portfolio-creative/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/restaurant/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/retail-store/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/salon-spa/dev/index.ts +112 -70
- package/templates/salon-spa/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/salon-spa/tier5-src/_shared/business-chat-history.ts +4 -1
- package/templates/salon-spa/tier5-src/_shared/business-chat-presenter.ts +2 -7
- package/templates/salon-spa/tier5-src/_shared/inbox-rooms.ts +68 -0
- package/templates/salon-spa/tier5-src/business-chat/index.ts +114 -59
- package/templates/yoga-studio/tier5-src/_shared/branded-lite-hosted.ts +1 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
<!doctype html><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; worker-src blob:; connect-src 'none'; img-src 'none'; media-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'"><script>(function(){
|
|
2
|
+
var token=decodeURIComponent(location.hash.slice(1));
|
|
3
|
+
function run(token,privateWorker){
|
|
4
|
+
var port;var protocol="himi.t5.frame/1";var chunks={runtime:[],bundle:[],handler:[]};var handlers=Object.create(null);var pushReady=false;
|
|
5
|
+
var CHUNK_CHARS=12288;var CHUNK_AT=20480;var CHUNK_MAX=4194304;var CHUNK_PARTS=1024;
|
|
6
|
+
var inCid="",inRid=undefined,inParts=null,inFilled=0,inBytes=0,outCid=0;
|
|
7
|
+
var kv=Object.create(null),kvPending=Object.create(null),kvSeq=0;
|
|
8
|
+
// The SAME conservative UTF-8 measure protocol.ts's `utf8Budget` uses. This realm
|
|
9
|
+
// has no TextEncoder, and a budget the two sides compute differently is a budget
|
|
10
|
+
// one side silently violates.
|
|
11
|
+
function u8(s){var n=0;for(var i=0;i<s.length;i++){var c=s.charCodeAt(i);n+=c<0x80?1:c<0x800?2:3;}return n;}
|
|
12
|
+
function post(m){try{port.postMessage(m);return true;}catch(e){return false;}}
|
|
13
|
+
// #2497 — an oversize message used to be posted anyway and DROPPED by the parent's
|
|
14
|
+
// size validator with no trace at all (a ~80 KB service snapshot for a 595-entry
|
|
15
|
+
// Wix response is enough). Ride the chunk envelope instead, and when even that is
|
|
16
|
+
// refused say so on the protocol rather than going quiet.
|
|
17
|
+
// Returns whether the message was handed to the port, so a caller that has to
|
|
18
|
+
// account for its own in-flight messages (storage_set) can tell one that never left.
|
|
19
|
+
function send(type,payload,requestId){
|
|
20
|
+
if(!port)return false;
|
|
21
|
+
var message={protocol:protocol,type:type};
|
|
22
|
+
if(requestId)message.requestId=requestId;
|
|
23
|
+
if(payload!==undefined)message.payload=payload;
|
|
24
|
+
var json;try{json=JSON.stringify(message);}catch(e){json=null;}
|
|
25
|
+
// The protocol is JSON-only. MessagePort preserves undefined object fields,
|
|
26
|
+
// which the parent rejects; normalize small messages just like chunked ones.
|
|
27
|
+
if(json!==null&&json.length<=CHUNK_AT)return post(JSON.parse(json));
|
|
28
|
+
var body;try{body=payload===undefined?null:JSON.stringify(payload);}catch(e){body=null;}
|
|
29
|
+
if(body===null||body===undefined)return post(message);
|
|
30
|
+
var bytes=u8(body);
|
|
31
|
+
if(bytes>CHUNK_MAX){
|
|
32
|
+
var over="frame payload of "+bytes+" bytes exceeds the "+CHUNK_MAX+"-byte bridge ceiling";
|
|
33
|
+
var fail={protocol:protocol,type:"error",payload:over};
|
|
34
|
+
if(requestId)fail.requestId=requestId;
|
|
35
|
+
post(fail);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
var cid="c"+(++outCid);var spans=[];var at=0;
|
|
39
|
+
while(at<body.length){
|
|
40
|
+
var end=Math.min(body.length,at+CHUNK_CHARS);
|
|
41
|
+
var code=body.charCodeAt(end-1);
|
|
42
|
+
// Never cut a surrogate pair: each part is JSON-serialized on its own.
|
|
43
|
+
if(end<body.length&&code>=0xd800&&code<=0xdbff)end++;
|
|
44
|
+
spans.push([at,end]);at=end;
|
|
45
|
+
}
|
|
46
|
+
if(!spans.length)spans.push([0,0]);
|
|
47
|
+
var sent=true;
|
|
48
|
+
for(var i=0;i<spans.length;i++){
|
|
49
|
+
var env={op:"frame_chunk",cid:cid,type:type,index:i,total:spans.length,part:body.slice(spans[i][0],spans[i][1])};
|
|
50
|
+
if(requestId)env.requestId=requestId;
|
|
51
|
+
sent=post({protocol:protocol,type:"bridge",payload:env})&&sent;
|
|
52
|
+
}
|
|
53
|
+
return sent;
|
|
54
|
+
}
|
|
55
|
+
if(privateWorker){
|
|
56
|
+
var closeWorker=globalThis.close.bind(globalThis);
|
|
57
|
+
globalThis.close=function(){send("teardown","private frame worker closed");closeWorker();};
|
|
58
|
+
}
|
|
59
|
+
// Every arm here REPORTS. A part dropped on a silent `return` leaves the bundle's
|
|
60
|
+
// `wixApi.call`/`dispatch` promise unsettled forever with nothing on the wire —
|
|
61
|
+
// the exact failure #2497 is, reintroduced one layer down.
|
|
62
|
+
function chunkFail(reason,requestId){
|
|
63
|
+
inCid="";inRid=undefined;inParts=null;inFilled=0;inBytes=0;
|
|
64
|
+
send("error",reason,requestId);
|
|
65
|
+
}
|
|
66
|
+
function chunkIn(p){
|
|
67
|
+
var rid=typeof p.requestId==="string"?p.requestId:undefined;
|
|
68
|
+
if(typeof p.cid!=="string"||!p.cid||typeof p.type!=="string"){chunkFail("malformed chunked frame message",rid);return;}
|
|
69
|
+
if(typeof p.index!=="number"||typeof p.total!=="number"||typeof p.part!=="string"){chunkFail("malformed chunked frame message",rid);return;}
|
|
70
|
+
if(p.total<1||p.total>CHUNK_PARTS||p.index<0||p.index>=p.total){chunkFail("malformed chunked frame message",rid);return;}
|
|
71
|
+
if(p.cid!==inCid){
|
|
72
|
+
// A new group supersedes an incomplete one; tell whoever awaited it.
|
|
73
|
+
if(inCid&&inRid)send("error","chunked frame message was superseded before it completed",inRid);
|
|
74
|
+
inCid=p.cid;inRid=rid;inParts=new Array(p.total);inFilled=0;inBytes=0;
|
|
75
|
+
}
|
|
76
|
+
if(!inParts||inParts.length!==p.total){chunkFail("inconsistent chunked frame message",rid);return;}
|
|
77
|
+
// Charge the DELTA: a re-sent index with a bigger part must move the budget,
|
|
78
|
+
// or the ceiling below can be walked straight past.
|
|
79
|
+
var previous=inParts[p.index];
|
|
80
|
+
if(previous===undefined)inFilled++;else inBytes-=u8(previous);
|
|
81
|
+
inBytes+=u8(p.part);
|
|
82
|
+
inParts[p.index]=p.part;
|
|
83
|
+
if(inBytes>CHUNK_MAX){chunkFail("frame payload exceeds the bridge ceiling",rid);return;}
|
|
84
|
+
if(inFilled!==p.total)return;
|
|
85
|
+
var joined=inParts.join("");inCid="";inRid=undefined;inParts=null;inFilled=0;inBytes=0;
|
|
86
|
+
var payload;try{payload=JSON.parse(joined);}catch(e){send("error","invalid chunked frame payload",rid);return;}
|
|
87
|
+
var whole={protocol:protocol,type:p.type,payload:payload};
|
|
88
|
+
if(rid)whole.requestId=rid;
|
|
89
|
+
command(whole);
|
|
90
|
+
}
|
|
91
|
+
function state(){
|
|
92
|
+
// RFC 0074 §5 — `exports` rides every state message: the parent's AppServiceStore reads the
|
|
93
|
+
// export catalog off the worker, and a contained app worker has no other channel to carry it.
|
|
94
|
+
try{var h=globalThis.himalaya;send("state",{snapshot:JSON.parse(h.__snapshotForAgent()),persisted:typeof h.__snapshotForPersistence==="function"?JSON.parse(h.__snapshotForPersistence()):undefined,services:globalThis.himalaya.__listServices(true),actions:globalThis.himalaya.__listActions(true),exports:typeof h.__listExports==="function"?h.__listExports():undefined});}catch(e){send("error",String(e&&e.message||e));}
|
|
95
|
+
}
|
|
96
|
+
function bridge(op,payload){return send("bridge",Object.assign({op:op},payload||{}));}
|
|
97
|
+
// The parent has applied every write of this frame numbered <= seq — or never will: the
|
|
98
|
+
// port is ordered, so one it dropped cannot arrive later. Either way it is not in flight.
|
|
99
|
+
function kvApplied(seq){if(typeof seq!=="number")return;for(var k in kvPending){if(kvPending[k]<=seq)delete kvPending[k];}}
|
|
100
|
+
// Replace the storage copy with the parent's `values` — except a key this frame still
|
|
101
|
+
// has a write in flight for: that write reaches the parent's store AFTER the snapshot
|
|
102
|
+
// was taken, so the local value is the one the store is about to hold.
|
|
103
|
+
function kvSeed(values,seq){
|
|
104
|
+
kvApplied(seq);
|
|
105
|
+
var next=Object.create(null);
|
|
106
|
+
if(values&&typeof values==="object"){for(var k in values){if(Object.prototype.hasOwnProperty.call(values,k)&&typeof values[k]==="string"&&values[k])next[k]=values[k];}}
|
|
107
|
+
for(var p in kvPending){if(p in kv)next[p]=kv[p];else delete next[p];}
|
|
108
|
+
kv=next;
|
|
109
|
+
}
|
|
110
|
+
function installBridges(storage,observe,webview){
|
|
111
|
+
kvSeed(storage);
|
|
112
|
+
// Gated on `pushReady` so boot's own subscription pass — which seeds each
|
|
113
|
+
// subscriber's equality baseline through this same bridge — does not re-send
|
|
114
|
+
// the snapshot the trailing state() has already delivered.
|
|
115
|
+
globalThis.__himalaya_native_notify=function(){if(pushReady)state();};
|
|
116
|
+
globalThis.__himalaya_native_notify_batch=function(){if(pushReady)state();};
|
|
117
|
+
if(observe&&observe.snapshot){globalThis.__himalaya_native_snapshot_request=function(json){bridge("snapshot",{json:String(json||"")});};}
|
|
118
|
+
globalThis.__himalaya_native_dispatch=function(id,handlerId,paramsJson){
|
|
119
|
+
var params={};try{params=JSON.parse(paramsJson||"{}");}catch(e){}
|
|
120
|
+
bridge("dispatch",{id:id,handlerId:String(handlerId||""),params:params});
|
|
121
|
+
};
|
|
122
|
+
globalThis.__himalaya_native_wix_call=function(id,method,path,body,headers,expectation,readOptions){bridge("wix",{id:id,method:String(method||"GET"),path:String(path||"/"),body:String(body||""),headers:String(headers||""),readOptions:String(readOptions||"")});};
|
|
123
|
+
// RFC 0074 §4/§5 — the app-service bridges @himalaya/state calls, forwarded like wix.
|
|
124
|
+
// Installed always: the GATE is in the host (allows("app_services")), which answers a
|
|
125
|
+
// coded envelope — a missing function would read as a pre-0074 runtime instead.
|
|
126
|
+
(function(){
|
|
127
|
+
var appPending={},appSeq=0;
|
|
128
|
+
function appCall(kind,a,b){
|
|
129
|
+
var id=++appSeq;
|
|
130
|
+
return new Promise(function(resolve){
|
|
131
|
+
appPending[id]=resolve;
|
|
132
|
+
bridge("app",{id:id,kind:kind,target:String(a==null?"":a),argsJson:String(b==null?"":b)});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
globalThis.__himalaya_app_read=function(path){return appCall("read",path,"");};
|
|
136
|
+
globalThis.__himalaya_app_dispatch=function(action,argsJson){return appCall("dispatch",action,argsJson);};
|
|
137
|
+
globalThis.__himalaya_app_result=function(id,envelopeJson){
|
|
138
|
+
var r=appPending[id];
|
|
139
|
+
if(!r)return;
|
|
140
|
+
delete appPending[id];
|
|
141
|
+
r(envelopeJson);
|
|
142
|
+
};
|
|
143
|
+
})();
|
|
144
|
+
globalThis.__himalaya_native_storage_get=function(key){var v=kv[String(key||"")];return typeof v==="string"?v:"";};
|
|
145
|
+
globalThis.__himalaya_native_storage_set=function(key,value){
|
|
146
|
+
key=String(key||"");value=value==null?"":String(value);
|
|
147
|
+
var had=key in kv,was=kv[key];
|
|
148
|
+
if(value)kv[key]=value;else delete kv[key];
|
|
149
|
+
// Marked BEFORE the send: the parent's ack can arrive the moment the port delivers.
|
|
150
|
+
var seq=++kvSeq,prior=kvPending[key];
|
|
151
|
+
kvPending[key]=seq;
|
|
152
|
+
// The request id names the write, so a parent that refuses it (a chunk group it
|
|
153
|
+
// cannot reassemble) can say WHICH one and re-seed this copy — see storage_seed.
|
|
154
|
+
if(!send("bridge",{op:"storage_set",key:key,value:value,seq:seq},"kv"+seq)&&kvPending[key]===seq){
|
|
155
|
+
// The write never left this frame (e.g. past the bridge ceiling, which send()
|
|
156
|
+
// reports to the parent), so the store will never hold it: neither may this copy.
|
|
157
|
+
if(prior)kvPending[key]=prior;else delete kvPending[key];
|
|
158
|
+
if(had)kv[key]=was;else delete kv[key];
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
// The parent evaluates every stream request against signed endpoint policy.
|
|
162
|
+
// The child never receives fetch/network access of its own.
|
|
163
|
+
globalThis.__himalaya_native_stream_open=function(service,directive){bridge("stream_open",{service:String(service||""),directive:String(directive||"")});};
|
|
164
|
+
globalThis.__himalaya_native_poll_start=function(service,directive){bridge("poll_start",{service:String(service||""),directive:String(directive||"")});};
|
|
165
|
+
// #2288 — a rejected Tier-5 action. The child's unhandledrejection listener below
|
|
166
|
+
// catches the same rejection generically; this arrives ATTRIBUTED (which service,
|
|
167
|
+
// which action) and fires even for a rejection the bundle itself awaited, so the
|
|
168
|
+
// parent can report the failure rather than infer it from a bare message.
|
|
169
|
+
globalThis.__himalaya_native_read_recovery=function(outcome){bridge("read_recovery",{outcome:String(outcome)});};
|
|
170
|
+
globalThis.__himalaya_native_action_failed=function(service,action,message){bridge("action_failed",{service:String(service||""),action:String(action||""),message:String(message||"")});};
|
|
171
|
+
// RFC 0073 §8 — worker → embedded page, only when granted "webview" (the parent refuses it too).
|
|
172
|
+
if(webview){globalThis.__himalaya_native_webview_post=function(iid,json){bridge("webview_post",{iid:typeof iid==="string"?iid:"",json:typeof json==="string"?json:"null"});};}
|
|
173
|
+
// A capture SINK: the runtime bootstrap's console (#4546) formats each call to one line and hands
|
|
174
|
+
// it here. Without observe.console the frame keeps its own console, which the bootstrap only
|
|
175
|
+
// fills gaps in.
|
|
176
|
+
if(observe&&observe.console){
|
|
177
|
+
var log=function(level){return function(message){bridge("console",{level:level,message:String(message)});};};
|
|
178
|
+
globalThis.console={log:log("log"),info:log("info"),warn:log("warn"),error:log("error"),debug:log("debug"),__himalayaSink:true};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function sourceChunk(p){
|
|
182
|
+
if(!p||!((p.kind==="runtime")||(p.kind==="bundle")||(p.kind==="handler"))||typeof p.index!=="number"||typeof p.total!=="number"||typeof p.source!=="string"||p.index<0||p.index>=p.total||p.total>4096)return;
|
|
183
|
+
var a=chunks[p.kind];a[p.index]=p.source;a.length=p.total;
|
|
184
|
+
}
|
|
185
|
+
function complete(a){for(var i=0;i<a.length;i++){if(typeof a[i]!=="string")return false;}return a.length>0;}
|
|
186
|
+
function boot(p){
|
|
187
|
+
if(!p||typeof p!=="object")return;
|
|
188
|
+
var runtime=chunks.runtime.join(""),bundle=chunks.bundle.join("");
|
|
189
|
+
if(!runtime||!bundle||!complete(chunks.runtime)||!complete(chunks.bundle)){send("error","incomplete frame source");return;}
|
|
190
|
+
try{
|
|
191
|
+
installBridges(p.storage,p.observe,p.webview===true);
|
|
192
|
+
// W3a — the last-known state the runtime's defineService overlays (plain JSON, structured-cloned).
|
|
193
|
+
if(p.persistedState&&typeof p.persistedState==="object"&&!Array.isArray(p.persistedState))globalThis.__himalaya_persisted_state=p.persistedState;
|
|
194
|
+
// Evaluation is intentionally confined to this opaque, network-denied realm.
|
|
195
|
+
(new Function(runtime))();
|
|
196
|
+
if(typeof p.online==="boolean")globalThis.himalaya.__setConnectivity(p.online);
|
|
197
|
+
globalThis.himalaya.input=p.input&&typeof p.input==="object"?p.input:{};
|
|
198
|
+
globalThis.himalaya.capabilities=Array.isArray(p.capabilities)?p.capabilities.filter(function(c){return typeof c==="string";}):[];
|
|
199
|
+
(new Function(bundle))();
|
|
200
|
+
state();
|
|
201
|
+
// #2282 — bind every service to the notify bridges. They are the child's ONLY
|
|
202
|
+
// worker-initiated state push, and runtimeBootstrap fires them only when a
|
|
203
|
+
// service has subscribers. Nothing in the contained realm ever subscribed, so
|
|
204
|
+
// an async module-eval load() resolving after this point never reached the
|
|
205
|
+
// parent's snapshot and the screen stayed on its loading state until the user
|
|
206
|
+
// dispatched an action. The empty path resolves to the whole service state,
|
|
207
|
+
// which is exactly what the parent mirrors.
|
|
208
|
+
var names=globalThis.himalaya.__listServices(true);
|
|
209
|
+
for(var i=0;i<names.length;i++)globalThis.himalaya.__subscribe(names[i],"",i+1);
|
|
210
|
+
pushReady=true;
|
|
211
|
+
}catch(e){send("error",String(e&&e.message||e));}
|
|
212
|
+
}
|
|
213
|
+
function bootHandler(data){
|
|
214
|
+
var source=chunks.handler.join("");
|
|
215
|
+
if(!source||!complete(chunks.handler)){send("error","incomplete handler source",data.requestId);return;}
|
|
216
|
+
try{
|
|
217
|
+
globalThis.himalaya={registerHandler:function(id,fn){if(typeof id==="string"&&typeof fn==="function")handlers[id]=fn;}};
|
|
218
|
+
// Served handlers are evaluated only in this opaque, network-denied realm.
|
|
219
|
+
(new Function(source))();
|
|
220
|
+
send("result",{handlers:Object.keys(handlers)},data.requestId);
|
|
221
|
+
}catch(e){send("error",String(e&&e.message||e),data.requestId);}
|
|
222
|
+
}
|
|
223
|
+
function invokeHandler(data,p){
|
|
224
|
+
var fn=handlers[String(p.handlerId||"")];
|
|
225
|
+
if(typeof fn!=="function"){send("error","handler not found",data.requestId);return;}
|
|
226
|
+
try{
|
|
227
|
+
Promise.resolve(fn(p.params&&typeof p.params==="object"?p.params:{},p.context&&typeof p.context==="object"?p.context:{}))
|
|
228
|
+
.then(function(value){send("result",value,data.requestId);},function(error){send("error",String(error&&error.message||error),data.requestId);});
|
|
229
|
+
}catch(e){send("error",String(e&&e.message||e),data.requestId);}
|
|
230
|
+
}
|
|
231
|
+
function command(data){
|
|
232
|
+
if(!data||data.protocol!==protocol)return;
|
|
233
|
+
if(data.type==="teardown"){himalaya.__disposeReads();try{port.close();}catch(e){};port=null;return;}
|
|
234
|
+
if(data.type!=="bridge"||!data.payload||typeof data.payload!=="object")return;
|
|
235
|
+
var p=data.payload;
|
|
236
|
+
if(p.op==="frame_chunk"){chunkIn(p);return;}
|
|
237
|
+
if(p.op==="source_chunk"){sourceChunk(p);return;}
|
|
238
|
+
if(p.op==="handler_boot"){bootHandler(data);return;}
|
|
239
|
+
if(p.op==="handler_invoke"){invokeHandler(data,p);return;}
|
|
240
|
+
if(p.op==="boot_complete"){boot(p);return;}
|
|
241
|
+
if(p.op==="input_update"){
|
|
242
|
+
if(!globalThis.himalaya||!p.input||typeof p.input!=="object"||Array.isArray(p.input)){
|
|
243
|
+
send("error","invalid worker input",data.requestId);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
globalThis.himalaya.input=p.input;
|
|
247
|
+
send("result",null,data.requestId);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
// #3048 — another writer changed a key. Skipped while this frame's own write to the
|
|
251
|
+
// key is unacknowledged: the parent applied the foreign write first, so ours is the
|
|
252
|
+
// store's value and will be announced to everyone else.
|
|
253
|
+
if(p.op==="storage_sync"){var sk=String(p.key||"");if(!kvPending[sk]){var sv=typeof p.value==="string"?p.value:"";if(sv)kv[sk]=sv;else delete kv[sk];}return;}
|
|
254
|
+
// Our write is applied. A `value` means the store holds something else (it refused
|
|
255
|
+
// the write, or a listener overwrote it); adopt it unless a later own write is in flight.
|
|
256
|
+
if(p.op==="storage_ack"){var ak=String(p.key||"");if(typeof p.value==="string"&&kvPending[ak]===p.seq){if(p.value)kv[ak]=p.value;else delete kv[ak];}kvApplied(p.seq);return;}
|
|
257
|
+
if(p.op==="storage_seed"){kvSeed(p.values,p.seq);return;}
|
|
258
|
+
// Our write numbered seq never reached the store. If it is still this key's latest
|
|
259
|
+
// own write, the copy holds a value nothing else does: ask for the store's.
|
|
260
|
+
if(p.op==="storage_refused"){var rk=null;for(var k in kvPending){if(kvPending[k]===p.seq)rk=k;}kvApplied(p.seq);if(rk!==null)bridge("storage_resync",{key:rk});return;}
|
|
261
|
+
if(p.op==="connectivity"&&globalThis.himalaya){Promise.resolve(globalThis.himalaya.__setConnectivity(p.online)).then(state);return;}
|
|
262
|
+
if(p.op==="read_active"&&globalThis.himalaya){Promise.resolve(globalThis.himalaya.__setReadActive(p.active)).then(state);return;}
|
|
263
|
+
if(p.op==="invoke"){
|
|
264
|
+
try{
|
|
265
|
+
var result=globalThis.himalaya.__invokeAction(String(p.service||""),String(p.action||""),JSON.stringify(Array.isArray(p.args)?p.args:[]));
|
|
266
|
+
if(result==null){send("error","action not found",data.requestId);return;}
|
|
267
|
+
Promise.resolve(result).then(function(value){state();send("result",value,data.requestId);},function(error){send("error",String(error&&error.message||error),data.requestId);});
|
|
268
|
+
}catch(e){send("error",String(e&&e.message||e),data.requestId);}
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if(p.op==="webview_message"&&globalThis.himalaya&&typeof p.iid==="string"&&typeof p.json==="string"){globalThis.himalaya.__deliverWebViewMessage(p.json,p.iid);return;}
|
|
272
|
+
if(p.op==="webview_lifecycle"&&globalThis.himalaya&&typeof p.iid==="string"&&typeof p.json==="string"&&globalThis.himalaya.__deliverWebViewLifecycle){globalThis.himalaya.__deliverWebViewLifecycle(p.json,p.iid);return;}
|
|
273
|
+
if(p.op==="dispatch_result"&&globalThis.himalaya){globalThis.himalaya.__resolveDispatch(p.id,!!p.ok,String(p.payload||""));return;}
|
|
274
|
+
if(p.op==="app_result"&&typeof globalThis.__himalaya_app_result==="function"){globalThis.__himalaya_app_result(p.id,String(p.payload||""));return;}
|
|
275
|
+
if(p.op==="wix_result"&&globalThis.himalaya){globalThis.himalaya.__resolveWixCall(p.id,!!p.ok,String(p.payload||""));}
|
|
276
|
+
}
|
|
277
|
+
addEventListener("message",function(event){
|
|
278
|
+
var data=event.data;
|
|
279
|
+
if(port||!data||data.type!=="himi.t5.frame.connect"||data.token!==token||!event.ports||event.ports.length!==1)return;
|
|
280
|
+
port=event.ports[0];
|
|
281
|
+
port.onmessage=function(event){command(event.data);};
|
|
282
|
+
port.start&&port.start();
|
|
283
|
+
port.postMessage({protocol:protocol,type:"ready"});
|
|
284
|
+
},{once:false});
|
|
285
|
+
// Partial #2288 — the host page installs its unhandledrejection handler on the
|
|
286
|
+
// PARENT window (core/web-host/src/telemetry/globalErrorHandlers.ts). The bundle
|
|
287
|
+
// runs in THIS document, so a rejecting module-eval load() was swallowed here:
|
|
288
|
+
// no request to fail, no console line, nothing. Report it out of band instead.
|
|
289
|
+
addEventListener("unhandledrejection",function(event){
|
|
290
|
+
var reason=event&&event.reason;
|
|
291
|
+
// #2288 - a Tier-5 action rejection the runtime ALREADY reported, attributed, through
|
|
292
|
+
// __himalaya_native_action_failed carries a mark. Sending it again here would hand the
|
|
293
|
+
// parent one failure twice, the bare copy carrying strictly less than the attributed
|
|
294
|
+
// one. The mark is set only after that bridge actually delivered, so a rejection
|
|
295
|
+
// nobody reported still reaches the parent through this net.
|
|
296
|
+
if(reason&&typeof reason==="object"&&reason.__himalayaReported)return;
|
|
297
|
+
// A PRIMITIVE reason, or a FROZEN Error, cannot carry the mark, so those are reported
|
|
298
|
+
// twice: once attributed, once bare. That is deliberate. Matching on message TEXT
|
|
299
|
+
// instead would suppress them - but the runtime reports EVERY rejected action, including
|
|
300
|
+
// one its caller awaited and handled, and a handled rejection fires no event here to
|
|
301
|
+
// consume its entry. The entry would go stale and silently eat a LATER, unrelated
|
|
302
|
+
// rejection that happened to share the text. This PR exists because a rejection went
|
|
303
|
+
// unreported; trading a duplicate line for a lost failure is the wrong direction.
|
|
304
|
+
send("error",String(reason&&reason.message||reason||"unhandledrejection"));
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if(!(true)){run(token);return;}
|
|
308
|
+
var worker=null,workerURL=null,parentPort=null,innerPort=null,stopped=false;
|
|
309
|
+
function stop(){
|
|
310
|
+
if(stopped)return;stopped=true;
|
|
311
|
+
if(worker)worker.terminate();
|
|
312
|
+
if(workerURL)URL.revokeObjectURL(workerURL);workerURL=null;
|
|
313
|
+
try{if(innerPort)innerPort.close();}catch(e){}
|
|
314
|
+
try{if(parentPort)parentPort.close();}catch(e){}
|
|
315
|
+
worker=null;innerPort=null;parentPort=null;
|
|
316
|
+
}
|
|
317
|
+
function fail(message){
|
|
318
|
+
try{if(parentPort)parentPort.postMessage({protocol:"himi.t5.frame/1",type:"teardown",payload:String(message).slice(0,1024)});}catch(e){}
|
|
319
|
+
stop();
|
|
320
|
+
}
|
|
321
|
+
addEventListener("pagehide",function(){fail("private frame worker page hidden");},{once:true});
|
|
322
|
+
addEventListener("message",function(event){
|
|
323
|
+
var data=event.data;
|
|
324
|
+
if(stopped||parentPort||!data||data.type!=="himi.t5.frame.connect"||data.token!==token||!event.ports||event.ports.length!==1)return;
|
|
325
|
+
parentPort=event.ports[0];
|
|
326
|
+
var url;
|
|
327
|
+
try{
|
|
328
|
+
url=URL.createObjectURL(new Blob(["("+run.toString()+")("+JSON.stringify(token)+",true);"],{type:"text/javascript"}));
|
|
329
|
+
worker=new Worker(url);
|
|
330
|
+
// WebKit needs this URL alive to read cloned catalog Blobs in the Worker.
|
|
331
|
+
// stop() revokes it after terminating the private realm on every exit path.
|
|
332
|
+
workerURL=url;url=null;
|
|
333
|
+
worker.onerror=function(event){event.preventDefault();fail("private frame worker failed: "+String(event.message||"worker error"));};
|
|
334
|
+
worker.onmessageerror=function(){fail("private frame worker message could not be decoded");};
|
|
335
|
+
var channel=new MessageChannel();innerPort=channel.port1;
|
|
336
|
+
innerPort.onmessage=function(event){if(parentPort)parentPort.postMessage(event.data);};
|
|
337
|
+
innerPort.onmessageerror=function(){fail("private frame worker channel could not be decoded");};
|
|
338
|
+
innerPort.start();
|
|
339
|
+
parentPort.onmessage=function(event){
|
|
340
|
+
if(!innerPort)return;
|
|
341
|
+
var data=event.data;
|
|
342
|
+
if(data&&data.protocol==="himi.t5.frame/1"&&data.type==="teardown"){stop();return;}
|
|
343
|
+
try{innerPort.postMessage(data);}catch(e){fail("private frame worker command could not be delivered");}
|
|
344
|
+
};
|
|
345
|
+
parentPort.onmessageerror=function(){fail("private frame parent channel could not be decoded");};
|
|
346
|
+
parentPort.start();
|
|
347
|
+
worker.postMessage({type:"himi.t5.frame.connect",token:token},[channel.port2]);
|
|
348
|
+
}catch(e){if(url)URL.revokeObjectURL(url);fail("private frame worker could not start: "+String(e&&e.message||e));}
|
|
349
|
+
},{once:false});
|
|
350
|
+
})();</script>
|