@ewe-studios/foundation-wasm-ui 0.0.0-stage → 0.1.13
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/LICENSE +201 -0
- package/README.md +11 -2
- package/bundle.js +15565 -0
- package/bundle.min.js +2 -0
- package/foundation_wasm/runtime/foundation-wasm.js +2449 -0
- package/index.js +3 -0
- package/package.json +12 -4
- package/ui/runtimes/foundation-ui-actions.js +698 -0
- package/ui/runtimes/foundation-ui-behaviours.js +792 -0
- package/ui/runtimes/foundation-ui-bootstrap.js +13 -0
- package/ui/runtimes/foundation-ui-connections.js +99 -0
- package/ui/runtimes/foundation-ui-frames.js +1023 -0
- package/ui/runtimes/foundation-ui-live.js +186 -0
- package/ui/runtimes/foundation-ui-recovery.js +66 -0
- package/ui/runtimes/foundation-ui-vocab.js +262 -0
- package/ui/runtimes/foundation-ui-wire.js +1 -0
- package/ui/runtimes/foundation-wasm-ui.js +2164 -0
- package/ui/runtimes/platform-scheme-interceptor.js +124 -0
- package/ui/runtimes/runtime-entry.js +4 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Platform scheme interceptor — foundation_wasm_ui (spec-52).
|
|
2
|
+
//
|
|
3
|
+
// Android WebView has no API for custom URI scheme handlers. wry works around
|
|
4
|
+
// this by converting custom-scheme URLs to HTTP URLs during initial load and
|
|
5
|
+
// intercepting them in shouldInterceptRequest. But link clicks and
|
|
6
|
+
// programmatic navigations to ewe:// URLs are NOT converted — Android's
|
|
7
|
+
// shouldOverrideUrlLoading lets them fall through to the OS, which has no
|
|
8
|
+
// handler for them.
|
|
9
|
+
//
|
|
10
|
+
// This script intercepts clicks and navigations to platform schemes
|
|
11
|
+
// (ewe://, foundation://, platform://) and rewrites them to
|
|
12
|
+
// http://{scheme}.localhost/... — the format wry's shouldInterceptRequest
|
|
13
|
+
// recognizes and routes to the registered protocol handler.
|
|
14
|
+
//
|
|
15
|
+
// Desktop engines (WebKit, WebView2) support custom schemes natively through
|
|
16
|
+
// register_uri_scheme_protocol — this script is a no-op on those platforms.
|
|
17
|
+
//
|
|
18
|
+
// Usage: include this script BEFORE any other application code.
|
|
19
|
+
// foundation_platform's builder injects it automatically; foundation_wasm_ui
|
|
20
|
+
// embeds it in the core JS runtime for standalone WASM apps.
|
|
21
|
+
|
|
22
|
+
;(function () {
|
|
23
|
+
'use strict';
|
|
24
|
+
|
|
25
|
+
var PLATFORM_SCHEMES = ['ewe', 'foundation', 'platform'];
|
|
26
|
+
var PREFIX = 'http://';
|
|
27
|
+
|
|
28
|
+
function isPlatformScheme(href) {
|
|
29
|
+
if (!href) return false;
|
|
30
|
+
for (var i = 0; i < PLATFORM_SCHEMES.length; i++) {
|
|
31
|
+
var prefix = PLATFORM_SCHEMES[i] + '://';
|
|
32
|
+
if (href.indexOf(prefix) === 0) return PLATFORM_SCHEMES[i];
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function toWorkaroundUrl(href) {
|
|
38
|
+
var scheme = isPlatformScheme(href);
|
|
39
|
+
if (!scheme) return null;
|
|
40
|
+
return href.replace(scheme + '://', PREFIX + scheme + '.');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isAndroid() {
|
|
44
|
+
return /android/i.test(navigator.userAgent);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Only activate on Android — desktop engines handle custom schemes natively.
|
|
48
|
+
if (!isAndroid()) return;
|
|
49
|
+
|
|
50
|
+
// ── Intercept <a> clicks ──────────────────────────────────────────
|
|
51
|
+
document.addEventListener('click', function (e) {
|
|
52
|
+
var a = e.target.closest('a');
|
|
53
|
+
if (!a) return;
|
|
54
|
+
var href = a.getAttribute('href') || a.href;
|
|
55
|
+
var newUrl = toWorkaroundUrl(href);
|
|
56
|
+
if (!newUrl) return;
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
e.stopImmediatePropagation();
|
|
59
|
+
location.href = newUrl;
|
|
60
|
+
}, true); // capture phase — beats user-land listeners
|
|
61
|
+
|
|
62
|
+
// ── Intercept programmatic navigations ────────────────────────────
|
|
63
|
+
var _origAssign = location.assign;
|
|
64
|
+
var _origReplace = location.replace;
|
|
65
|
+
var _origSetHref = Object.getOwnPropertyDescriptor(Location.prototype, 'href');
|
|
66
|
+
|
|
67
|
+
function wrap(fn) {
|
|
68
|
+
return function (url) {
|
|
69
|
+
var rewritten = toWorkaroundUrl(url);
|
|
70
|
+
if (rewritten) {
|
|
71
|
+
url = rewritten;
|
|
72
|
+
}
|
|
73
|
+
return fn.call(this, url);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Android WebView may make location.assign / location.replace read-only.
|
|
78
|
+
// Try direct assignment first; fall back to defineProperty if that throws.
|
|
79
|
+
try {
|
|
80
|
+
location.assign = wrap(_origAssign);
|
|
81
|
+
} catch (_) {
|
|
82
|
+
try {
|
|
83
|
+
Object.defineProperty(location, 'assign', {
|
|
84
|
+
value: wrap(_origAssign),
|
|
85
|
+
writable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
});
|
|
88
|
+
} catch (__) { /* best-effort */ }
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
location.replace = wrap(_origReplace);
|
|
92
|
+
} catch (_) {
|
|
93
|
+
try {
|
|
94
|
+
Object.defineProperty(location, 'replace', {
|
|
95
|
+
value: wrap(_origReplace),
|
|
96
|
+
writable: true,
|
|
97
|
+
configurable: true,
|
|
98
|
+
});
|
|
99
|
+
} catch (__) { /* best-effort */ }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (_origSetHref && _origSetHref.set) {
|
|
103
|
+
var _set = _origSetHref.set;
|
|
104
|
+
Object.defineProperty(location, 'href', {
|
|
105
|
+
get: _origSetHref.get,
|
|
106
|
+
set: function (url) {
|
|
107
|
+
var rewritten = toWorkaroundUrl(url);
|
|
108
|
+
_set.call(this, rewritten || url);
|
|
109
|
+
},
|
|
110
|
+
configurable: true,
|
|
111
|
+
enumerable: true,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ── Intercept window.open ─────────────────────────────────────────
|
|
116
|
+
var _origOpen = window.open;
|
|
117
|
+
window.open = function (url) {
|
|
118
|
+
var rewritten = toWorkaroundUrl(url);
|
|
119
|
+
if (rewritten) {
|
|
120
|
+
arguments[0] = rewritten;
|
|
121
|
+
}
|
|
122
|
+
return _origOpen.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
})();
|