rampkit-expo-dev 0.0.28 → 0.0.30
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/build/RampkitOverlay.d.ts +1 -1
- package/build/RampkitOverlay.js +77 -121
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { RampKitContext } from "./types";
|
|
|
2
2
|
export declare const injectedHardening = "\n(function(){\n try {\n var meta = document.querySelector('meta[name=\"viewport\"]');\n if (!meta) { meta = document.createElement('meta'); meta.name = 'viewport'; document.head.appendChild(meta); }\n meta.setAttribute('content','width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover');\n var style = document.createElement('style');\n style.textContent='html,body{overflow-x:hidden!important;} html,body,*{-webkit-user-select:none!important;user-select:none!important;-webkit-touch-callout:none!important;-ms-user-select:none!important;touch-action: pan-y;} *{-webkit-tap-highlight-color: rgba(0,0,0,0)!important;} ::selection{background: transparent!important;} ::-moz-selection{background: transparent!important;} a,img{-webkit-user-drag:none!important;user-drag:none!important;-webkit-touch-callout:none!important} input,textarea{caret-color:transparent!important;-webkit-user-select:none!important;user-select:none!important}';\n document.head.appendChild(style);\n var prevent=function(e){e.preventDefault&&e.preventDefault();};\n document.addEventListener('gesturestart',prevent,{passive:false});\n document.addEventListener('gesturechange',prevent,{passive:false});\n document.addEventListener('gestureend',prevent,{passive:false});\n document.addEventListener('dblclick',prevent,{passive:false});\n document.addEventListener('wheel',function(e){ if(e.ctrlKey) e.preventDefault(); },{passive:false});\n document.addEventListener('touchmove',function(e){ if(e.scale && e.scale !== 1) e.preventDefault(); },{passive:false});\n document.addEventListener('selectstart',prevent,{passive:false,capture:true});\n document.addEventListener('contextmenu',prevent,{passive:false,capture:true});\n document.addEventListener('copy',prevent,{passive:false,capture:true});\n document.addEventListener('cut',prevent,{passive:false,capture:true});\n document.addEventListener('paste',prevent,{passive:false,capture:true});\n document.addEventListener('dragstart',prevent,{passive:false,capture:true});\n // Belt-and-suspenders: aggressively clear any attempted selection\n var clearSel=function(){\n try{var sel=window.getSelection&&window.getSelection(); if(sel&&sel.removeAllRanges) sel.removeAllRanges();}catch(_){} }\n document.addEventListener('selectionchange',clearSel,{passive:true,capture:true});\n document.onselectstart=function(){ clearSel(); return false; };\n try{ document.documentElement.style.webkitUserSelect='none'; document.documentElement.style.userSelect='none'; }catch(_){ }\n try{ document.body.style.webkitUserSelect='none'; document.body.style.userSelect='none'; }catch(_){ }\n var __selTimer = setInterval(clearSel, 160);\n window.addEventListener('pagehide',function(){ try{ clearInterval(__selTimer); }catch(_){} });\n // Continuously enforce no-select on all elements and new nodes\n var enforceNoSelect = function(el){\n try{\n el.style && (el.style.webkitUserSelect='none', el.style.userSelect='none', el.style.webkitTouchCallout='none');\n el.setAttribute && (el.setAttribute('unselectable','on'), el.setAttribute('contenteditable','false'));\n }catch(_){}\n }\n try{\n var all=document.getElementsByTagName('*');\n for(var i=0;i<all.length;i++){ enforceNoSelect(all[i]); }\n var obs = new MutationObserver(function(muts){\n for(var j=0;j<muts.length;j++){\n var m=muts[j];\n if(m.type==='childList'){\n m.addedNodes && m.addedNodes.forEach && m.addedNodes.forEach(function(n){ if(n && n.nodeType===1){ enforceNoSelect(n); var q=n.getElementsByTagName? n.getElementsByTagName('*'): []; for(var k=0;k<q.length;k++){ enforceNoSelect(q[k]); }}});\n } else if(m.type==='attributes'){\n enforceNoSelect(m.target);\n }\n }\n });\n obs.observe(document.documentElement,{ childList:true, subtree:true, attributes:true, attributeFilter:['contenteditable','style'] });\n }catch(_){ }\n } catch(_) {}\n})(); true;\n";
|
|
3
3
|
export declare const injectedNoSelect = "\n(function(){\n try {\n if (window.__rkNoSelectApplied) return true;\n window.__rkNoSelectApplied = true;\n var style = document.getElementById('rk-no-select-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'rk-no-select-style';\n style.innerHTML = \"\n * {\n user-select: none !important;\n -webkit-user-select: none !important;\n -webkit-touch-callout: none !important;\n }\n ::selection {\n background: transparent !important;\n }\n \";\n document.head.appendChild(style);\n }\n var prevent = function(e){ if(e && e.preventDefault) e.preventDefault(); return false; };\n document.addEventListener('contextmenu', prevent, { passive: false, capture: true });\n document.addEventListener('selectstart', prevent, { passive: false, capture: true });\n } catch (_) {}\n true;\n})();\n";
|
|
4
4
|
export declare const injectedVarsHandler = "\n(function(){\n try {\n if (window.__rkVarsHandlerApplied) return true;\n window.__rkVarsHandlerApplied = true;\n \n // Handler function that updates variables and notifies the page\n window.__rkHandleVarsUpdate = function(vars) {\n if (!vars || typeof vars !== 'object') return;\n // Update the global variables object\n window.__rampkitVariables = vars;\n // Dispatch a custom event that the page's JS can listen to for re-rendering\n try {\n document.dispatchEvent(new CustomEvent('rampkit:vars-updated', { detail: vars }));\n } catch(e) {}\n // Also try calling a global handler if the page defined one\n try {\n if (typeof window.onRampkitVarsUpdate === 'function') {\n window.onRampkitVarsUpdate(vars);\n }\n } catch(e) {}\n };\n \n // Listen for message events from React Native\n document.addEventListener('message', function(event) {\n try {\n var data = event.data;\n if (data && data.type === 'rampkit:variables' && data.vars) {\n window.__rkHandleVarsUpdate(data.vars);\n }\n } catch(e) {}\n }, false);\n \n // Also listen on window for compatibility\n window.addEventListener('message', function(event) {\n try {\n var data = event.data;\n if (data && data.type === 'rampkit:variables' && data.vars) {\n window.__rkHandleVarsUpdate(data.vars);\n }\n } catch(e) {}\n }, false);\n } catch (_) {}\n true;\n})();\n";
|
|
5
|
-
export declare const injectedTemplateResolver
|
|
5
|
+
export declare const injectedTemplateResolver: string;
|
|
6
6
|
export type ScreenPayload = {
|
|
7
7
|
id: string;
|
|
8
8
|
html: string;
|
package/build/RampkitOverlay.js
CHANGED
|
@@ -174,127 +174,83 @@ exports.injectedVarsHandler = `
|
|
|
174
174
|
})();
|
|
175
175
|
`;
|
|
176
176
|
// Template resolution script that replaces ${device.xxx} and ${user.xxx} with actual values
|
|
177
|
-
//
|
|
178
|
-
exports.injectedTemplateResolver =
|
|
179
|
-
(function(){
|
|
180
|
-
try {
|
|
181
|
-
if (window.__rkTemplateResolverApplied) return true;
|
|
182
|
-
window.__rkTemplateResolverApplied = true;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
var
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (ctx.device) {
|
|
192
|
-
Object.keys(ctx.device).forEach(function(key) {
|
|
193
|
-
vars['device.' + key] = ctx.device[key];
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
//
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
for (var i = 0; i < allElements.length; i++) {
|
|
255
|
-
var el = allElements[i];
|
|
256
|
-
for (var j = 0; j < el.attributes.length; j++) {
|
|
257
|
-
var attr = el.attributes[j];
|
|
258
|
-
if (attr.value && attr.value.indexOf('\${') !== -1) {
|
|
259
|
-
var resolvedAttr = attr.value.replace(/\\$\\{([A-Za-z_][A-Za-z0-9_\\.]*)\\}/g, function(match, varName) {
|
|
260
|
-
if (vars.hasOwnProperty(varName)) {
|
|
261
|
-
return formatValue(vars[varName]);
|
|
262
|
-
}
|
|
263
|
-
return match;
|
|
264
|
-
});
|
|
265
|
-
if (resolvedAttr !== attr.value) {
|
|
266
|
-
el.setAttribute(attr.name, resolvedAttr);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Run on DOMContentLoaded
|
|
274
|
-
if (document.readyState === 'loading') {
|
|
275
|
-
document.addEventListener('DOMContentLoaded', resolveAllTemplates);
|
|
276
|
-
} else {
|
|
277
|
-
// DOM already ready, run immediately
|
|
278
|
-
resolveAllTemplates();
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Also run after a short delay to catch dynamically added content
|
|
282
|
-
setTimeout(resolveAllTemplates, 100);
|
|
283
|
-
|
|
284
|
-
// Expose for manual re-resolution
|
|
285
|
-
window.rampkitResolveTemplates = resolveAllTemplates;
|
|
286
|
-
|
|
287
|
-
// Re-resolve when variables update
|
|
288
|
-
document.addEventListener('rampkit:vars-updated', function() {
|
|
289
|
-
setTimeout(resolveAllTemplates, 0);
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
} catch(e) {
|
|
293
|
-
console.log('[Rampkit] Template resolver error:', e);
|
|
294
|
-
}
|
|
295
|
-
true;
|
|
296
|
-
})();
|
|
297
|
-
`;
|
|
177
|
+
// Built using string concatenation to avoid template literal escaping issues
|
|
178
|
+
exports.injectedTemplateResolver = [
|
|
179
|
+
"(function(){",
|
|
180
|
+
" try {",
|
|
181
|
+
" if (window.__rkTemplateResolverApplied) return true;",
|
|
182
|
+
" window.__rkTemplateResolverApplied = true;",
|
|
183
|
+
" ",
|
|
184
|
+
" console.log('[Rampkit] Template resolver starting...');",
|
|
185
|
+
" console.log('[Rampkit] rampkitContext:', JSON.stringify(window.rampkitContext));",
|
|
186
|
+
" ",
|
|
187
|
+
" function buildVarMap() {",
|
|
188
|
+
" var vars = {};",
|
|
189
|
+
" var ctx = window.rampkitContext || { device: {}, user: {} };",
|
|
190
|
+
" var state = window.__rampkitVariables || {};",
|
|
191
|
+
" if (ctx.device) {",
|
|
192
|
+
" Object.keys(ctx.device).forEach(function(key) {",
|
|
193
|
+
" vars['device.' + key] = ctx.device[key];",
|
|
194
|
+
" });",
|
|
195
|
+
" }",
|
|
196
|
+
" if (ctx.user) {",
|
|
197
|
+
" Object.keys(ctx.user).forEach(function(key) {",
|
|
198
|
+
" vars['user.' + key] = ctx.user[key];",
|
|
199
|
+
" });",
|
|
200
|
+
" }",
|
|
201
|
+
" Object.keys(state).forEach(function(key) {",
|
|
202
|
+
" vars[key] = state[key];",
|
|
203
|
+
" });",
|
|
204
|
+
" console.log('[Rampkit] Variable map:', JSON.stringify(vars));",
|
|
205
|
+
" return vars;",
|
|
206
|
+
" }",
|
|
207
|
+
" ",
|
|
208
|
+
" function formatValue(value) {",
|
|
209
|
+
" if (value === undefined || value === null) return '';",
|
|
210
|
+
" if (typeof value === 'boolean') return value ? 'true' : 'false';",
|
|
211
|
+
" if (typeof value === 'object') return JSON.stringify(value);",
|
|
212
|
+
" return String(value);",
|
|
213
|
+
" }",
|
|
214
|
+
" ",
|
|
215
|
+
" function resolveAllTemplates() {",
|
|
216
|
+
" console.log('[Rampkit] Resolving templates...');",
|
|
217
|
+
" var vars = buildVarMap();",
|
|
218
|
+
" var pattern = /\\$\\{([A-Za-z_][A-Za-z0-9_.]*)\\}/g;",
|
|
219
|
+
" var bodyHtml = document.body.innerHTML;",
|
|
220
|
+
" var marker = String.fromCharCode(36, 123);", // $ = 36, { = 123
|
|
221
|
+
" var hasTemplates = bodyHtml.indexOf(marker) !== -1;",
|
|
222
|
+
" console.log('[Rampkit] Body has templates:', hasTemplates);",
|
|
223
|
+
" if (hasTemplates) {",
|
|
224
|
+
" var newHtml = bodyHtml.replace(pattern, function(match, varName) {",
|
|
225
|
+
" console.log('[Rampkit] Found template:', match, 'varName:', varName);",
|
|
226
|
+
" if (vars.hasOwnProperty(varName)) {",
|
|
227
|
+
" var value = formatValue(vars[varName]);",
|
|
228
|
+
" console.log('[Rampkit] Replacing with:', value);",
|
|
229
|
+
" return value;",
|
|
230
|
+
" }",
|
|
231
|
+
" console.log('[Rampkit] No value found for:', varName);",
|
|
232
|
+
" return match;",
|
|
233
|
+
" });",
|
|
234
|
+
" if (newHtml !== bodyHtml) {",
|
|
235
|
+
" document.body.innerHTML = newHtml;",
|
|
236
|
+
" console.log('[Rampkit] Templates resolved!');",
|
|
237
|
+
" }",
|
|
238
|
+
" }",
|
|
239
|
+
" }",
|
|
240
|
+
" ",
|
|
241
|
+
" setTimeout(resolveAllTemplates, 50);",
|
|
242
|
+
" setTimeout(resolveAllTemplates, 200);",
|
|
243
|
+
" window.rampkitResolveTemplates = resolveAllTemplates;",
|
|
244
|
+
" document.addEventListener('rampkit:vars-updated', function() {",
|
|
245
|
+
" setTimeout(resolveAllTemplates, 0);",
|
|
246
|
+
" });",
|
|
247
|
+
" console.log('[Rampkit] Template resolver initialized');",
|
|
248
|
+
" } catch(e) {",
|
|
249
|
+
" console.log('[Rampkit] Template resolver error:', e);",
|
|
250
|
+
" }",
|
|
251
|
+
" true;",
|
|
252
|
+
"})();",
|
|
253
|
+
].join("\n");
|
|
298
254
|
function performRampkitHaptic(event) {
|
|
299
255
|
if (!event || event.action !== "haptic") {
|
|
300
256
|
// Backwards compatible default
|
package/package.json
CHANGED