@stacksjs/stx 0.2.465 → 0.2.466
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/{chunk-nmk9en1n.js → chunk-01zwbzyw.js} +324 -164
- package/dist/{chunk-qc7zybaa.js → chunk-02e24cym.js} +1 -1
- package/dist/{chunk-ag1v2tkm.js → chunk-0adxpd3e.js} +2321 -2321
- package/dist/{chunk-sgbgwezf.js → chunk-0v5dpk7r.js} +1 -1
- package/dist/chunk-1rbabtw0.js +2 -0
- package/dist/{chunk-n003eq8w.js → chunk-1sdtg9np.js} +2 -2
- package/dist/chunk-24xhcqt9.js +2 -0
- package/dist/{chunk-yc4hf2ea.js → chunk-2cqymwe8.js} +2 -2
- package/dist/{chunk-1byqqwgm.js → chunk-2tn3dkcy.js} +2 -2
- package/dist/{chunk-2nvnd83c.js → chunk-3ar8gdyd.js} +1 -1
- package/dist/{chunk-4xcypfmg.js → chunk-45ffx66n.js} +1 -1
- package/dist/chunk-4rnncksa.js +2 -0
- package/dist/{chunk-se9qddyx.js → chunk-544e2jvd.js} +4 -4
- package/dist/chunk-5xsd1dw1.js +2 -0
- package/dist/chunk-6qsvh58v.js +2 -0
- package/dist/chunk-6xd9qbve.js +2 -0
- package/dist/{chunk-y8h823cb.js → chunk-74j18qk0.js} +28 -28
- package/dist/chunk-7fjatz47.js +2 -0
- package/dist/chunk-7j1cpa9d.js +2 -0
- package/dist/chunk-812sn7d5.js +18 -0
- package/dist/{chunk-5zaj400e.js → chunk-8bpyr4az.js} +1 -1
- package/dist/chunk-8bsz3ky4.js +2 -0
- package/dist/{chunk-gm6g6gar.js → chunk-8efg91ak.js} +2 -2
- package/dist/{chunk-5mmqe3hj.js → chunk-9zx4p42m.js} +1 -1
- package/dist/{chunk-cstvhr0r.js → chunk-ars3cbs5.js} +1099 -1099
- package/dist/{chunk-7xckcy9x.js → chunk-bnemhyg2.js} +1 -1
- package/dist/{chunk-5e6p2ndj.js → chunk-cfk3skk4.js} +1 -1
- package/dist/chunk-cg8hg6cs.js +3 -0
- package/dist/{chunk-pw34r8r5.js → chunk-cmej3vrr.js} +1 -1
- package/dist/{chunk-gjrbnzap.js → chunk-d2zw2e5m.js} +3 -3
- package/dist/chunk-d78wbjkz.js +2 -0
- package/dist/{chunk-x9a5a282.js → chunk-e15a8txv.js} +2 -2
- package/dist/{chunk-4acykd9n.js → chunk-eanwntq4.js} +1 -1
- package/dist/{chunk-pxmbee61.js → chunk-ebp212na.js} +5 -5
- package/dist/chunk-f9c58ag8.js +30 -0
- package/dist/{chunk-769t2y70.js → chunk-fads0sap.js} +1 -1
- package/dist/chunk-fmtyrdgg.js +2 -0
- package/dist/chunk-gmccacxc.js +2 -0
- package/dist/{chunk-6bwe6vsc.js → chunk-h074e6w3.js} +1 -1
- package/dist/chunk-h6ayvmaj.js +2 -0
- package/dist/{chunk-gasb5fhy.js → chunk-hra6t4ch.js} +2 -2
- package/dist/{chunk-z14y48en.js → chunk-jkf5k215.js} +3 -3
- package/dist/chunk-k8smv0at.js +2 -0
- package/dist/{chunk-7knc20mz.js → chunk-k9sbgax8.js} +1 -1
- package/dist/{chunk-2e4pegf1.js → chunk-kax708d4.js} +1 -1
- package/dist/chunk-kca543an.js +2 -0
- package/dist/{chunk-27k24mk0.js → chunk-kkrmhb5b.js} +1 -1
- package/dist/chunk-m08fk6ds.js +12 -0
- package/dist/chunk-mdkj4jj1.js +2 -0
- package/dist/chunk-n39zm07w.js +2 -0
- package/dist/{chunk-en3e0y6m.js → chunk-na5evt2b.js} +1 -1
- package/dist/chunk-pbfwbtg4.js +2 -0
- package/dist/{chunk-j9y50qt9.js → chunk-ptek61ts.js} +1 -1
- package/dist/{chunk-xt4990k8.js → chunk-pyqh70k2.js} +1 -1
- package/dist/{chunk-abb9xmdg.js → chunk-q7bs39wj.js} +1 -1
- package/dist/chunk-qyq7j8hp.js +2 -0
- package/dist/{chunk-0avd5kkb.js → chunk-rdp06c4s.js} +20 -20
- package/dist/{chunk-32kk8y2r.js → chunk-rgwvqmhh.js} +1 -1
- package/dist/chunk-rx3rxfrj.js +2 -0
- package/dist/{chunk-n6p2at6g.js → chunk-sz1s3k89.js} +1 -1
- package/dist/{chunk-ysptfks9.js → chunk-t2hkwjvd.js} +1 -1
- package/dist/{chunk-ktvr45qg.js → chunk-t61vdbje.js} +6 -6
- package/dist/chunk-tejeej39.js +2 -0
- package/dist/{chunk-nmnbdtsq.js → chunk-v6qxmac5.js} +6 -6
- package/dist/{chunk-p7j2g8y2.js → chunk-v83bpj84.js} +4 -4
- package/dist/chunk-vcjfwjr8.js +2 -0
- package/dist/chunk-w7m1w5qt.js +2 -0
- package/dist/{chunk-jbdqs7t6.js → chunk-wfqnxb38.js} +1 -1
- package/dist/{chunk-1bazr47z.js → chunk-wx25t40k.js} +1 -1
- package/dist/chunk-xjb0yzvq.js +2 -0
- package/dist/chunk-xk3wf5sh.js +2 -0
- package/dist/chunk-xk5972g0.js +2 -0
- package/dist/{chunk-gj90pnre.js → chunk-y36av1ac.js} +7 -7
- package/dist/{chunk-3q3174cn.js → chunk-y63bv55f.js} +2 -2
- package/dist/{chunk-pfm6cfph.js → chunk-ynvce0q6.js} +2 -2
- package/dist/{chunk-9g339c7b.js → chunk-z80d9dd2.js} +2 -2
- package/dist/{chunk-vvb3wq2p.js → chunk-z990jtmx.js} +1 -1
- package/dist/{chunk-azcvytqc.js → chunk-zr2trjex.js} +1 -1
- package/dist/cli.js +43 -43
- package/dist/client-script-bundler.js +1 -1
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/database.js +2 -2
- package/dist/pwa.js +3 -3
- package/dist/signals.js +318 -158
- package/dist/ssg.js +2 -2
- package/dist/strip-literals.js +23 -8
- package/package.json +5 -5
- package/dist/chunk-0880qx3m.js +0 -2
- package/dist/chunk-0zf49qxk.js +0 -2
- package/dist/chunk-1tsz7v68.js +0 -2
- package/dist/chunk-2mv3wh0s.js +0 -2
- package/dist/chunk-4wjef6d8.js +0 -18
- package/dist/chunk-6ry01675.js +0 -2
- package/dist/chunk-97ezbs97.js +0 -2
- package/dist/chunk-99qf5fff.js +0 -2
- package/dist/chunk-a201b6rx.js +0 -2
- package/dist/chunk-aqdkct70.js +0 -2
- package/dist/chunk-bb7p822h.js +0 -2
- package/dist/chunk-bj31r6sj.js +0 -2
- package/dist/chunk-c1gp4xjy.js +0 -2
- package/dist/chunk-c8z3fghp.js +0 -2
- package/dist/chunk-esc6fahf.js +0 -2
- package/dist/chunk-f2rh0zhs.js +0 -2
- package/dist/chunk-h5k0c1jp.js +0 -2
- package/dist/chunk-hqfgbtsy.js +0 -30
- package/dist/chunk-j2pdtq0d.js +0 -2
- package/dist/chunk-kewh1a68.js +0 -2
- package/dist/chunk-kvfcm30m.js +0 -2
- package/dist/chunk-nahzfs7d.js +0 -2
- package/dist/chunk-s1075erh.js +0 -2
- package/dist/chunk-s2fpethy.js +0 -2
- package/dist/chunk-tps20cx5.js +0 -2
- package/dist/chunk-ts3jftxq.js +0 -2
- package/dist/chunk-wfmy7a0b.js +0 -2
- package/dist/chunk-xsdj6k6c.js +0 -2
- package/dist/chunk-y3cqh2jv.js +0 -12
- package/dist/chunk-yn2d8x8m.js +0 -3
package/dist/signals.js
CHANGED
|
@@ -7043,6 +7043,281 @@ catch (e) {} }
|
|
|
7043
7043
|
}
|
|
7044
7044
|
};
|
|
7045
7045
|
|
|
7046
|
+
// \u2500\u2500 Overlay stack \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
7047
|
+
//
|
|
7048
|
+
// One stack for everything that takes over the page: stxAlert/stxConfirm,
|
|
7049
|
+
// the runtime modal and drawer, @stacksjs/components' Dialog and Drawer, and
|
|
7050
|
+
// anything an app draws itself (window.stx.overlays). Each of those used to
|
|
7051
|
+
// keep its own listener, its own scroll lock and its own idea of whether it
|
|
7052
|
+
// was on top, so with one open over another a single Escape closed both, two
|
|
7053
|
+
// Tab traps fought over focus, and the first to close unlocked the page under
|
|
7054
|
+
// the one still open (stacksjs/stx#2057; #1998 fixed the same thing for the
|
|
7055
|
+
// confirm dialogs alone).
|
|
7056
|
+
//
|
|
7057
|
+
// Only the topmost overlay answers Escape and owns Tab. The page is locked
|
|
7058
|
+
// from the first open to the last close. Focus moves into an overlay when it
|
|
7059
|
+
// opens and back to whatever opened it when it closes.
|
|
7060
|
+
//
|
|
7061
|
+
// A popup - a menu, a listbox, a popover - goes on the same stack as a
|
|
7062
|
+
// non-modal layer (modal: false). It takes Escape while it is on top, so one
|
|
7063
|
+
// Escape inside a dialog closes the menu and leaves the dialog, but it does
|
|
7064
|
+
// not lock the page, trap Tab or move focus: those follow the topmost MODAL
|
|
7065
|
+
// layer. Each popup used to listen for Escape on the document itself, and
|
|
7066
|
+
// whichever listener was registered first won.
|
|
7067
|
+
var _overlays = [];
|
|
7068
|
+
var _overlayScroll = null;
|
|
7069
|
+
var _overlayInerted = [];
|
|
7070
|
+
var _overlayListening = false;
|
|
7071
|
+
var _OVERLAY_FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
7072
|
+
|
|
7073
|
+
function _overlayTop() {
|
|
7074
|
+
return _overlays.length ? _overlays[_overlays.length - 1] : null;
|
|
7075
|
+
}
|
|
7076
|
+
|
|
7077
|
+
// The layer that owns Tab and the page lock: the topmost modal one.
|
|
7078
|
+
function _overlayTopModal() {
|
|
7079
|
+
for (var i = _overlays.length - 1; i >= 0; i--) {
|
|
7080
|
+
if (_overlays[i].modal) return _overlays[i];
|
|
7081
|
+
}
|
|
7082
|
+
return null;
|
|
7083
|
+
}
|
|
7084
|
+
|
|
7085
|
+
function _overlayIndex(id) {
|
|
7086
|
+
for (var i = 0; i < _overlays.length; i++) {
|
|
7087
|
+
if (_overlays[i].id === id) return i;
|
|
7088
|
+
}
|
|
7089
|
+
return -1;
|
|
7090
|
+
}
|
|
7091
|
+
|
|
7092
|
+
// The panel is asked for, not held: a component's panel may not be rendered
|
|
7093
|
+
// yet on the frame it opens, and may be replaced while open.
|
|
7094
|
+
function _overlayPanel(entry) {
|
|
7095
|
+
var panel = entry && entry.panel;
|
|
7096
|
+
try {
|
|
7097
|
+
// A selector is looked up each time, like a function: the element it
|
|
7098
|
+
// names may be rendered after the overlay opens, or replaced while open.
|
|
7099
|
+
if (typeof panel === 'string') panel = document.querySelector(panel);
|
|
7100
|
+
else if (typeof panel === 'function') panel = panel();
|
|
7101
|
+
}
|
|
7102
|
+
catch (_e) { panel = null; }
|
|
7103
|
+
return panel || entry.root || null;
|
|
7104
|
+
}
|
|
7105
|
+
|
|
7106
|
+
function _overlayFocusable(panel) {
|
|
7107
|
+
return Array.prototype.filter.call(panel.querySelectorAll(_OVERLAY_FOCUSABLE), function(el) {
|
|
7108
|
+
return el.offsetParent !== null || el === document.activeElement;
|
|
7109
|
+
});
|
|
7110
|
+
}
|
|
7111
|
+
|
|
7112
|
+
// One listener for every overlay, in the bubble phase: a widget inside an
|
|
7113
|
+
// overlay that consumes Escape (a menu closing itself) calls preventDefault
|
|
7114
|
+
// and the overlay leaves it alone.
|
|
7115
|
+
function _overlayKey(e) {
|
|
7116
|
+
var top = _overlayTop();
|
|
7117
|
+
if (!top) return;
|
|
7118
|
+
if (e.key === 'Escape') {
|
|
7119
|
+
if (e.defaultPrevented || !top.onEscape) return;
|
|
7120
|
+
e.preventDefault();
|
|
7121
|
+
top.onEscape();
|
|
7122
|
+
return;
|
|
7123
|
+
}
|
|
7124
|
+
if (e.key !== 'Tab') return;
|
|
7125
|
+
var trap = _overlayTopModal();
|
|
7126
|
+
if (!trap) return;
|
|
7127
|
+
var panel = _overlayPanel(trap);
|
|
7128
|
+
if (!panel) return;
|
|
7129
|
+
var items = _overlayFocusable(panel);
|
|
7130
|
+
if (!items.length) {
|
|
7131
|
+
e.preventDefault();
|
|
7132
|
+
if (panel.focus) panel.focus();
|
|
7133
|
+
return;
|
|
7134
|
+
}
|
|
7135
|
+
var first = items[0];
|
|
7136
|
+
var last = items[items.length - 1];
|
|
7137
|
+
var active = document.activeElement;
|
|
7138
|
+
if (!panel.contains(active)) {
|
|
7139
|
+
e.preventDefault();
|
|
7140
|
+
(e.shiftKey ? last : first).focus();
|
|
7141
|
+
return;
|
|
7142
|
+
}
|
|
7143
|
+
if (e.shiftKey && active === first) {
|
|
7144
|
+
e.preventDefault();
|
|
7145
|
+
last.focus();
|
|
7146
|
+
}
|
|
7147
|
+
else if (!e.shiftKey && active === last) {
|
|
7148
|
+
e.preventDefault();
|
|
7149
|
+
first.focus();
|
|
7150
|
+
}
|
|
7151
|
+
}
|
|
7152
|
+
|
|
7153
|
+
// Lock, listen and inert to match the stack after any change.
|
|
7154
|
+
function _overlaySync() {
|
|
7155
|
+
for (var i = 0; i < _overlayInerted.length; i++) {
|
|
7156
|
+
try { _overlayInerted[i].inert = false; }
|
|
7157
|
+
catch (_e) { /* element may be gone */ }
|
|
7158
|
+
}
|
|
7159
|
+
_overlayInerted = [];
|
|
7160
|
+
|
|
7161
|
+
var top = _overlayTop();
|
|
7162
|
+
var modal = _overlayTopModal();
|
|
7163
|
+
if (!modal && _overlayScroll) {
|
|
7164
|
+
document.body.style.overflow = _overlayScroll.body;
|
|
7165
|
+
document.documentElement.style.overflow = _overlayScroll.html;
|
|
7166
|
+
document.body.style.paddingRight = _overlayScroll.pad;
|
|
7167
|
+
_overlayScroll = null;
|
|
7168
|
+
}
|
|
7169
|
+
if (!top) {
|
|
7170
|
+
if (_overlayScroll) {
|
|
7171
|
+
document.body.style.overflow = _overlayScroll.body;
|
|
7172
|
+
document.documentElement.style.overflow = _overlayScroll.html;
|
|
7173
|
+
document.body.style.paddingRight = _overlayScroll.pad;
|
|
7174
|
+
_overlayScroll = null;
|
|
7175
|
+
}
|
|
7176
|
+
if (_overlayListening) {
|
|
7177
|
+
document.removeEventListener('keydown', _overlayKey);
|
|
7178
|
+
_overlayListening = false;
|
|
7179
|
+
}
|
|
7180
|
+
return;
|
|
7181
|
+
}
|
|
7182
|
+
|
|
7183
|
+
if (modal && !_overlayScroll) {
|
|
7184
|
+
_overlayScroll = {
|
|
7185
|
+
body: document.body.style.overflow,
|
|
7186
|
+
html: document.documentElement.style.overflow,
|
|
7187
|
+
pad: document.body.style.paddingRight
|
|
7188
|
+
};
|
|
7189
|
+
// The scrollbar's width comes back as padding, so the page does not jump
|
|
7190
|
+
// sideways when it disappears.
|
|
7191
|
+
var gap = window.innerWidth - document.documentElement.clientWidth;
|
|
7192
|
+
if (gap > 0) {
|
|
7193
|
+
var existing = Number.parseFloat(window.getComputedStyle(document.body).paddingRight) || 0;
|
|
7194
|
+
document.body.style.paddingRight = (existing + gap) + 'px';
|
|
7195
|
+
}
|
|
7196
|
+
document.body.style.overflow = 'hidden';
|
|
7197
|
+
document.documentElement.style.overflow = 'hidden';
|
|
7198
|
+
}
|
|
7199
|
+
if (!_overlayListening) {
|
|
7200
|
+
document.addEventListener('keydown', _overlayKey);
|
|
7201
|
+
_overlayListening = true;
|
|
7202
|
+
}
|
|
7203
|
+
|
|
7204
|
+
// inert, rather than aria-hidden, takes the page behind out of the tab
|
|
7205
|
+
// order and the accessibility tree together (#1998). Only for an overlay
|
|
7206
|
+
// that is itself a child of the body element - one the runtime appended. An overlay
|
|
7207
|
+
// rendered inside the page's own markup would go inert with the page; its
|
|
7208
|
+
// Tab trap is what holds it.
|
|
7209
|
+
var root = modal && modal.root;
|
|
7210
|
+
if (root && root.parentNode === document.body) {
|
|
7211
|
+
var kids = document.body.children;
|
|
7212
|
+
for (var k = 0; k < kids.length; k++) {
|
|
7213
|
+
var kid = kids[k];
|
|
7214
|
+
if (kid === root || kid.inert) continue;
|
|
7215
|
+
try {
|
|
7216
|
+
kid.inert = true;
|
|
7217
|
+
_overlayInerted.push(kid);
|
|
7218
|
+
}
|
|
7219
|
+
catch (_e) { /* inert unsupported; the Tab trap still holds */ }
|
|
7220
|
+
}
|
|
7221
|
+
}
|
|
7222
|
+
}
|
|
7223
|
+
|
|
7224
|
+
// The next chance to act, whichever comes first: rAF is suspended in a
|
|
7225
|
+
// background tab, so a timer races it.
|
|
7226
|
+
function _overlaySoon(callback) {
|
|
7227
|
+
var done = false;
|
|
7228
|
+
var once = function() {
|
|
7229
|
+
if (done) return;
|
|
7230
|
+
done = true;
|
|
7231
|
+
callback();
|
|
7232
|
+
};
|
|
7233
|
+
if (typeof requestAnimationFrame === 'function') requestAnimationFrame(once);
|
|
7234
|
+
setTimeout(once, 32);
|
|
7235
|
+
}
|
|
7236
|
+
|
|
7237
|
+
// Retried, because focus() on an element that is not displayed yet is a
|
|
7238
|
+
// silent no-op. Stops once the overlay has closed.
|
|
7239
|
+
function _overlayFocusIn(entry, attempts) {
|
|
7240
|
+
if (_overlayIndex(entry.id) === -1) return;
|
|
7241
|
+
var target = null;
|
|
7242
|
+
try { target = typeof entry.initialFocus === 'function' ? entry.initialFocus() : entry.initialFocus; }
|
|
7243
|
+
catch (_e) { target = null; }
|
|
7244
|
+
var panel = _overlayPanel(entry);
|
|
7245
|
+
if (!target && panel) target = panel.querySelector('[autofocus]') || _overlayFocusable(panel)[0] || panel;
|
|
7246
|
+
if (target && target.focus) target.focus();
|
|
7247
|
+
if (target && document.activeElement === target) return;
|
|
7248
|
+
if (attempts > 0) _overlaySoon(function() { _overlayFocusIn(entry, attempts - 1); });
|
|
7249
|
+
}
|
|
7250
|
+
|
|
7251
|
+
var overlays = {
|
|
7252
|
+
/**
|
|
7253
|
+
* Put an overlay on top. Calling it again for an open id updates its
|
|
7254
|
+
* options and nothing else, so it is safe from an effect that re-runs.
|
|
7255
|
+
*
|
|
7256
|
+
* options: modal (default true; false for a popup, which takes Escape
|
|
7257
|
+
* while on top but does not lock, trap or move focus), panel (an element,
|
|
7258
|
+
* a selector, or a function returning one; focus stays inside it), root (the overlay's outermost element, if it is not the panel),
|
|
7259
|
+
* onEscape (leave out for one that must be answered), initialFocus
|
|
7260
|
+
* (element or function; defaults to [autofocus], then the first focusable,
|
|
7261
|
+
* then the panel), opener (where focus goes back; defaults to whatever had
|
|
7262
|
+
* it), restoreFocus (default true).
|
|
7263
|
+
*/
|
|
7264
|
+
open: function(id, options) {
|
|
7265
|
+
var opts = options || {};
|
|
7266
|
+
var at = _overlayIndex(id);
|
|
7267
|
+
if (at !== -1) {
|
|
7268
|
+
var existing = _overlays[at];
|
|
7269
|
+
for (var key in opts) {
|
|
7270
|
+
if (Object.prototype.hasOwnProperty.call(opts, key)) existing[key] = opts[key];
|
|
7271
|
+
}
|
|
7272
|
+
_overlaySync();
|
|
7273
|
+
return;
|
|
7274
|
+
}
|
|
7275
|
+
var isModal = opts.modal !== false;
|
|
7276
|
+
var entry = {
|
|
7277
|
+
id: id,
|
|
7278
|
+
modal: isModal,
|
|
7279
|
+
panel: opts.panel,
|
|
7280
|
+
root: opts.root || null,
|
|
7281
|
+
onEscape: opts.onEscape || null,
|
|
7282
|
+
initialFocus: opts.initialFocus || null,
|
|
7283
|
+
// A popup hands focus back itself, to its own trigger, and only when
|
|
7284
|
+
// focus was inside it; a modal layer always does.
|
|
7285
|
+
restoreFocus: opts.restoreFocus !== undefined ? opts.restoreFocus !== false : isModal,
|
|
7286
|
+
opener: opts.opener !== undefined ? opts.opener : document.activeElement
|
|
7287
|
+
};
|
|
7288
|
+
_overlays.push(entry);
|
|
7289
|
+
_overlaySync();
|
|
7290
|
+
// Synchronously first, so a caller that asserts focus straight after
|
|
7291
|
+
// opening sees it; then retried for a panel that is not displayed yet.
|
|
7292
|
+
// A popup keeps focus where its own keyboard handling puts it.
|
|
7293
|
+
if (isModal || opts.initialFocus) _overlayFocusIn(entry, 10);
|
|
7294
|
+
},
|
|
7295
|
+
/** Take an overlay off the stack, wherever it is in it. */
|
|
7296
|
+
close: function(id) {
|
|
7297
|
+
var at = _overlayIndex(id);
|
|
7298
|
+
if (at === -1) return;
|
|
7299
|
+
var wasTop = at === _overlays.length - 1;
|
|
7300
|
+
var entry = _overlays.splice(at, 1)[0];
|
|
7301
|
+
_overlaySync();
|
|
7302
|
+
// Only the overlay that had the keyboard gives it back. Closing one
|
|
7303
|
+
// underneath (its owner went away) must not pull focus out of the top.
|
|
7304
|
+
var opener = entry.opener;
|
|
7305
|
+
if (wasTop && entry.restoreFocus && opener && opener.isConnected !== false && typeof opener.focus === 'function') {
|
|
7306
|
+
try { opener.focus(); }
|
|
7307
|
+
catch (_e) { /* gone; nothing to give focus back to */ }
|
|
7308
|
+
}
|
|
7309
|
+
},
|
|
7310
|
+
/** Whether this overlay is the one that has the keyboard. */
|
|
7311
|
+
isTop: function(id) {
|
|
7312
|
+
var top = _overlayTop();
|
|
7313
|
+
return !!top && top.id === id;
|
|
7314
|
+
},
|
|
7315
|
+
/** Open overlay ids, outermost first. */
|
|
7316
|
+
list: function() {
|
|
7317
|
+
return _overlays.map(function(o) { return o.id; });
|
|
7318
|
+
}
|
|
7319
|
+
};
|
|
7320
|
+
|
|
7046
7321
|
// \u2500\u2500 Modal system \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
7047
7322
|
var modal = {
|
|
7048
7323
|
open: function(id) {
|
|
@@ -7052,16 +7327,14 @@ catch (e) {} }
|
|
|
7052
7327
|
// Force reflow then animate
|
|
7053
7328
|
void el.offsetHeight;
|
|
7054
7329
|
el.setAttribute('data-stx-modal-open', '');
|
|
7055
|
-
|
|
7056
|
-
//
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
}
|
|
7064
|
-
// Backdrop click
|
|
7330
|
+
// The lock, Escape for the topmost and the Tab trap come from the
|
|
7331
|
+
// overlay stack, shared with every other overlay (stacksjs/stx#2057).
|
|
7332
|
+
// Each modal used to bind its own Escape and set body overflow itself,
|
|
7333
|
+
// so two open closed together and the first to close unlocked the page.
|
|
7334
|
+
overlays.open('stx-modal:' + id, {
|
|
7335
|
+
panel: el,
|
|
7336
|
+
onEscape: el.getAttribute('data-close-escape') !== 'false' ? function() { modal.close(id); } : null
|
|
7337
|
+
});
|
|
7065
7338
|
if (el.getAttribute('data-close-backdrop') !== 'false') {
|
|
7066
7339
|
el.onclick = function(e) { if (e.target === el) modal.close(id); };
|
|
7067
7340
|
}
|
|
@@ -7070,12 +7343,10 @@ catch (e) {} }
|
|
|
7070
7343
|
var el = document.querySelector('[data-stx-modal="' + id + '"]');
|
|
7071
7344
|
if (!el) return;
|
|
7072
7345
|
el.removeAttribute('data-stx-modal-open');
|
|
7073
|
-
if (el._stxEscHandler) { document.removeEventListener('keydown', el._stxEscHandler); el._stxEscHandler = null; }
|
|
7074
7346
|
el.onclick = null;
|
|
7347
|
+
overlays.close('stx-modal:' + id);
|
|
7075
7348
|
setTimeout(function() {
|
|
7076
|
-
el.style.display = 'none';
|
|
7077
|
-
// Restore scroll if no other modals are open
|
|
7078
|
-
if (!document.querySelector('[data-stx-modal-open]')) document.body.style.overflow = '';
|
|
7349
|
+
if (!el.hasAttribute('data-stx-modal-open')) el.style.display = 'none';
|
|
7079
7350
|
}, 200);
|
|
7080
7351
|
},
|
|
7081
7352
|
toggle: function(id) {
|
|
@@ -7091,78 +7362,9 @@ catch (e) {} }
|
|
|
7091
7362
|
|
|
7092
7363
|
var _dialogId = 0;
|
|
7093
7364
|
|
|
7094
|
-
//
|
|
7095
|
-
//
|
|
7096
|
-
|
|
7097
|
-
// What WE set inert, so restoring never clears an app's own inert.
|
|
7098
|
-
var _dialogInerted = [];
|
|
7099
|
-
// Saved once, when the first dialog opens.
|
|
7100
|
-
var _dialogScrollLock = null;
|
|
7101
|
-
|
|
7102
|
-
/*
|
|
7103
|
-
* The page behind an aria-modal dialog does not scroll and is not reachable
|
|
7104
|
-
* by a virtual cursor (stacksjs/stx#1998, items 1 and 2).
|
|
7105
|
-
*
|
|
7106
|
-
* The backdrop is position:fixed;inset:0, so it stayed put while the content
|
|
7107
|
-
* behind it scrolled away underneath - the dialog claimed to be modal and the
|
|
7108
|
-
* page moved anyway. And the Tab trap, which #1875 added, only covers the
|
|
7109
|
-
* keyboard: aria-modal support for the virtual cursor is uneven, so a screen
|
|
7110
|
-
* reader could still browse the page behind the dialog.
|
|
7111
|
-
*
|
|
7112
|
-
* inert rather than aria-hidden on the siblings: aria-hidden on an element
|
|
7113
|
-
* that contains focus is itself a violation, and inert removes the subtree
|
|
7114
|
-
* from the tab order and the accessibility tree together. Everything except
|
|
7115
|
-
* the TOPMOST dialog goes inert, which also settles the two traps competing
|
|
7116
|
-
* for Tab while both were open - a backgrounded dialog's buttons stop being
|
|
7117
|
-
* focusable at all.
|
|
7118
|
-
*/
|
|
7119
|
-
function _dialogSyncModality() {
|
|
7120
|
-
var top = _dialogStack.length ? _dialogStack[_dialogStack.length - 1] : null;
|
|
7121
|
-
|
|
7122
|
-
for (var i = 0; i < _dialogInerted.length; i++) {
|
|
7123
|
-
try { _dialogInerted[i].inert = false; }
|
|
7124
|
-
catch (_e) { /* element may be gone */ }
|
|
7125
|
-
}
|
|
7126
|
-
_dialogInerted = [];
|
|
7127
|
-
|
|
7128
|
-
if (!top) {
|
|
7129
|
-
if (_dialogScrollLock) {
|
|
7130
|
-
document.body.style.overflow = _dialogScrollLock.body;
|
|
7131
|
-
document.documentElement.style.overflow = _dialogScrollLock.html;
|
|
7132
|
-
document.body.style.paddingRight = _dialogScrollLock.pad;
|
|
7133
|
-
_dialogScrollLock = null;
|
|
7134
|
-
}
|
|
7135
|
-
return;
|
|
7136
|
-
}
|
|
7137
|
-
|
|
7138
|
-
if (!_dialogScrollLock) {
|
|
7139
|
-
_dialogScrollLock = {
|
|
7140
|
-
body: document.body.style.overflow,
|
|
7141
|
-
html: document.documentElement.style.overflow,
|
|
7142
|
-
pad: document.body.style.paddingRight
|
|
7143
|
-
};
|
|
7144
|
-
// Compensate for the scrollbar the lock removes, or the whole page shifts
|
|
7145
|
-
// sideways the moment a dialog opens.
|
|
7146
|
-
var gap = window.innerWidth - document.documentElement.clientWidth;
|
|
7147
|
-
if (gap > 0) {
|
|
7148
|
-
var existing = Number.parseFloat(window.getComputedStyle(document.body).paddingRight) || 0;
|
|
7149
|
-
document.body.style.paddingRight = (existing + gap) + 'px';
|
|
7150
|
-
}
|
|
7151
|
-
document.body.style.overflow = 'hidden';
|
|
7152
|
-
document.documentElement.style.overflow = 'hidden';
|
|
7153
|
-
}
|
|
7154
|
-
|
|
7155
|
-
var kids = document.body.children;
|
|
7156
|
-
for (var k = 0; k < kids.length; k++) {
|
|
7157
|
-
var kid = kids[k];
|
|
7158
|
-
if (kid === top || kid.inert) continue;
|
|
7159
|
-
try {
|
|
7160
|
-
kid.inert = true;
|
|
7161
|
-
_dialogInerted.push(kid);
|
|
7162
|
-
}
|
|
7163
|
-
catch (_e) { /* inert unsupported; the Tab trap still holds */ }
|
|
7164
|
-
}
|
|
7165
|
-
}
|
|
7365
|
+
// Modality - the scroll lock, the inert page behind, the one Escape and the
|
|
7366
|
+
// one Tab trap - comes from the overlay stack above, which these dialogs
|
|
7367
|
+
// share with every other overlay on the page (#1998, stacksjs/stx#2057).
|
|
7166
7368
|
|
|
7167
7369
|
/** Dialogs animate unless the reader asked them not to (#1998 item 5). */
|
|
7168
7370
|
function _dialogReducedMotion() {
|
|
@@ -7256,13 +7458,6 @@ catch (e) {} }
|
|
|
7256
7458
|
// already closed the dialog, because the listener outlived it.
|
|
7257
7459
|
if (closed) return;
|
|
7258
7460
|
closed = true;
|
|
7259
|
-
document.removeEventListener('keydown', keyHandler, true);
|
|
7260
|
-
|
|
7261
|
-
// Out of the stack BEFORE resolving, so a caller that opens another
|
|
7262
|
-
// dialog the moment this one answers does not land under a backdrop
|
|
7263
|
-
// that is still fading.
|
|
7264
|
-
var at = _dialogStack.indexOf(backdrop);
|
|
7265
|
-
if (at !== -1) _dialogStack.splice(at, 1);
|
|
7266
7461
|
|
|
7267
7462
|
// The fade is 200ms and resolve() is immediate, so for those 200ms a
|
|
7268
7463
|
// full-viewport element at z-index 999999 was still hit-testing at the
|
|
@@ -7273,13 +7468,12 @@ catch (e) {} }
|
|
|
7273
7468
|
if (!still) panel.style.transform = 'scale(0.95)';
|
|
7274
7469
|
setTimeout(function() { backdrop.remove(); }, still ? 0 : 200);
|
|
7275
7470
|
|
|
7276
|
-
//
|
|
7277
|
-
//
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
}
|
|
7471
|
+
// Out of the stack BEFORE resolving, so a caller that opens another
|
|
7472
|
+
// dialog the moment this one answers does not land under a backdrop
|
|
7473
|
+
// that is still fading. That also unlocks the page and clears inert
|
|
7474
|
+
// when this was the last overlay, hands modality back to the one
|
|
7475
|
+
// underneath when it was not, and gives focus back to the opener.
|
|
7476
|
+
overlays.close(id);
|
|
7283
7477
|
resolve(result);
|
|
7284
7478
|
}
|
|
7285
7479
|
|
|
@@ -7308,8 +7502,6 @@ catch (e) {} }
|
|
|
7308
7502
|
panel.appendChild(btnRow);
|
|
7309
7503
|
backdrop.appendChild(panel);
|
|
7310
7504
|
document.body.appendChild(backdrop);
|
|
7311
|
-
_dialogStack.push(backdrop);
|
|
7312
|
-
_dialogSyncModality();
|
|
7313
7505
|
|
|
7314
7506
|
// Animate in
|
|
7315
7507
|
if (!still) {
|
|
@@ -7318,50 +7510,6 @@ catch (e) {} }
|
|
|
7318
7510
|
panel.style.transform = 'scale(1)';
|
|
7319
7511
|
}
|
|
7320
7512
|
|
|
7321
|
-
// Escape, plus a real focus trap.
|
|
7322
|
-
//
|
|
7323
|
-
// The old handler removed itself ONLY inside the Escape branch, so every
|
|
7324
|
-
// dialog dismissed with a button left a permanent keydown listener on
|
|
7325
|
-
// document holding this whole closure \u2014 backdrop, panel and resolve \u2014 alive.
|
|
7326
|
-
// Removal now lives in cleanup(), which every exit path goes through.
|
|
7327
|
-
//
|
|
7328
|
-
// aria-modal="true" was already being claimed on the backdrop while Tab
|
|
7329
|
-
// walked straight out into the page behind it. Capture phase so the trap
|
|
7330
|
-
// wins over anything the page has bound.
|
|
7331
|
-
var keyHandler = function(e) {
|
|
7332
|
-
// Every dialog binds its own capture-phase handler on document and none
|
|
7333
|
-
// of them checked whether they were on top, so ONE Escape resolved every
|
|
7334
|
-
// open dialog at once (#1998 item 4). The backgrounded dialogs are inert
|
|
7335
|
-
// too, which is what stops their traps competing for Tab.
|
|
7336
|
-
if (_dialogStack.length && _dialogStack[_dialogStack.length - 1] !== backdrop) return;
|
|
7337
|
-
if (e.key === 'Escape') {
|
|
7338
|
-
e.preventDefault();
|
|
7339
|
-
cleanup(isConfirm ? false : undefined);
|
|
7340
|
-
return;
|
|
7341
|
-
}
|
|
7342
|
-
if (e.key !== 'Tab') return;
|
|
7343
|
-
var focusable = panel.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
7344
|
-
if (!focusable.length) return;
|
|
7345
|
-
var first = focusable[0];
|
|
7346
|
-
var last = focusable[focusable.length - 1];
|
|
7347
|
-
// Focus may sit outside the panel entirely (the page had it when the
|
|
7348
|
-
// dialog opened), in which case Tab must pull it back in rather than
|
|
7349
|
-
// continue through the document.
|
|
7350
|
-
if (!panel.contains(document.activeElement)) {
|
|
7351
|
-
e.preventDefault();
|
|
7352
|
-
(e.shiftKey ? last : first).focus();
|
|
7353
|
-
return;
|
|
7354
|
-
}
|
|
7355
|
-
if (e.shiftKey && document.activeElement === first) {
|
|
7356
|
-
e.preventDefault();
|
|
7357
|
-
last.focus();
|
|
7358
|
-
}
|
|
7359
|
-
else if (!e.shiftKey && document.activeElement === last) {
|
|
7360
|
-
e.preventDefault();
|
|
7361
|
-
first.focus();
|
|
7362
|
-
}
|
|
7363
|
-
};
|
|
7364
|
-
document.addEventListener('keydown', keyHandler, true);
|
|
7365
7513
|
|
|
7366
7514
|
/*
|
|
7367
7515
|
* Initial focus, which was an unconditional okBtn.focus() (#1998 item 3).
|
|
@@ -7380,7 +7528,18 @@ catch (e) {} }
|
|
|
7380
7528
|
if (want === 'cancel' || (!want && type === 'error')) focusTarget = cancelBtn;
|
|
7381
7529
|
else if (want === 'confirm') focusTarget = okBtn;
|
|
7382
7530
|
}
|
|
7383
|
-
|
|
7531
|
+
|
|
7532
|
+
// Onto the overlay stack, which locks the page, makes it inert behind
|
|
7533
|
+
// this backdrop, traps Tab inside the panel and answers Escape for
|
|
7534
|
+
// whichever dialog is on top - so one Escape answers one dialog
|
|
7535
|
+
// (#1998 item 4) and a component Dialog underneath stays open.
|
|
7536
|
+
overlays.open(id, {
|
|
7537
|
+
panel: panel,
|
|
7538
|
+
root: backdrop,
|
|
7539
|
+
initialFocus: focusTarget,
|
|
7540
|
+
opener: previouslyFocused,
|
|
7541
|
+
onEscape: function() { cleanup(isConfirm ? false : undefined); }
|
|
7542
|
+
});
|
|
7384
7543
|
});
|
|
7385
7544
|
}
|
|
7386
7545
|
|
|
@@ -7399,16 +7558,17 @@ catch (e) {} }
|
|
|
7399
7558
|
var el = document.querySelector('[data-stx-drawer="' + id + '"]');
|
|
7400
7559
|
if (!el) { console.warn('[stx:drawer] Drawer "' + id + '" not found'); return; }
|
|
7401
7560
|
el.style.display = 'flex';
|
|
7561
|
+
// Force reflow then animate
|
|
7402
7562
|
void el.offsetHeight;
|
|
7403
7563
|
el.setAttribute('data-stx-drawer-open', '');
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
el.
|
|
7411
|
-
}
|
|
7564
|
+
// The lock, Escape for the topmost and the Tab trap come from the
|
|
7565
|
+
// overlay stack, shared with every other overlay (stacksjs/stx#2057).
|
|
7566
|
+
// Each drawer used to bind its own Escape and set body overflow itself,
|
|
7567
|
+
// so two open closed together and the first to close unlocked the page.
|
|
7568
|
+
overlays.open('stx-drawer:' + id, {
|
|
7569
|
+
panel: el,
|
|
7570
|
+
onEscape: el.getAttribute('data-close-escape') !== 'false' ? function() { drawer.close(id); } : null
|
|
7571
|
+
});
|
|
7412
7572
|
if (el.getAttribute('data-close-backdrop') !== 'false') {
|
|
7413
7573
|
el.onclick = function(e) { if (e.target === el) drawer.close(id); };
|
|
7414
7574
|
}
|
|
@@ -7417,11 +7577,10 @@ catch (e) {} }
|
|
|
7417
7577
|
var el = document.querySelector('[data-stx-drawer="' + id + '"]');
|
|
7418
7578
|
if (!el) return;
|
|
7419
7579
|
el.removeAttribute('data-stx-drawer-open');
|
|
7420
|
-
if (el._stxEscHandler) { document.removeEventListener('keydown', el._stxEscHandler); el._stxEscHandler = null; }
|
|
7421
7580
|
el.onclick = null;
|
|
7581
|
+
overlays.close('stx-drawer:' + id);
|
|
7422
7582
|
setTimeout(function() {
|
|
7423
|
-
el.style.display = 'none';
|
|
7424
|
-
if (!document.querySelector('[data-stx-drawer-open]') && !document.querySelector('[data-stx-modal-open]')) document.body.style.overflow = '';
|
|
7583
|
+
if (!el.hasAttribute('data-stx-drawer-open')) el.style.display = 'none';
|
|
7425
7584
|
}, 300);
|
|
7426
7585
|
},
|
|
7427
7586
|
toggle: function(id) {
|
|
@@ -7619,6 +7778,7 @@ catch (e) {} }
|
|
|
7619
7778
|
toast,
|
|
7620
7779
|
modal,
|
|
7621
7780
|
drawer,
|
|
7781
|
+
overlays,
|
|
7622
7782
|
alert: stxAlert,
|
|
7623
7783
|
confirm: stxConfirm,
|
|
7624
7784
|
helpers: globalHelpers,
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-ynvce0q6.js";import"./chunk-2n5pjbw9.js";import{Qe,et,tt,nt,rt,st}from"./chunk-88px183j.js";import"./chunk-2jbyks2t.js";import"./chunk-pf0d8y9n.js";import{f,je,N,K,n,o}from"./chunk-0adxpd3e.js";import"./chunk-v83bpj84.js";import{Qn}from"./chunk-y36av1ac.js";import"./chunk-zydg3wgt.js";import"./chunk-wfqnxb38.js";import"./chunk-jz7pvh7b.js";import"./chunk-0trfbqa7.js";import"./chunk-hra6t4ch.js";import{ie,gt,mt}from"./chunk-jkf5k215.js";import{To,Ro,Ao}from"./chunk-5j5msbks.js";import{pt,Gt,Jt}from"./chunk-5pjsc9zv.js";import"./chunk-d2zw2e5m.js";import{a}from"./chunk-7tt84v1y.js";import x from"fs";import g from"path";import{createHash as $t}from"crypto";function Dt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Rt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function kt(t){return Bun.hash(t).toString(16)}function lt(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(Rt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Dt(h);let S=kt(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${$t("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Ct=new Set(["visible","idle"]);function ut(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Ct.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var Et=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function It(t){for(let i of Et){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function dt(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function Bt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=dt(e.default??e);if(l)return l}catch{}}return null}async function ht(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=dt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await Bt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=It(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ft(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
3
|
`)}class wt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class yt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function jt(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${c[1]}
|
|
@@ -41,7 +41,7 @@ ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
|
41
41
|
${s.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function zt(t={}){let i=Date.now();mt();let s=await o(process.cwd()),r=s.build||{},c=await ht({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ft());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-
|
|
44
|
+
</rss>`}async function zt(t={}){let i=Date.now();mt();let s=await o(process.cwd()),r=s.build||{},c=await ht({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ft());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-tejeej39.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-pbfwbtg4.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new wt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-tejeej39.js");await u('<div class="bg-black"></div>')}catch{}Qe();let xt=s?.routeMiddleware?.dir||"middleware";await tt(process.cwd(),xt);let H=et();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let vt=s?.routeMiddleware?.global||[];Ao(s?.layoutsDir,a(process.cwd()));let V=N(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${V.length} routes`);let _=[];for(let u of V){let m=await Ft(u);for(let v of m)_.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=_.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],X=[];for(let u=0;u<_.length;u+=e.concurrency)X.push(_.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:L,props:bt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Vt(j),Pt=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],it=[...vt,...Pt];if(it.length>0){let C=nt(d,L,F||{}),O=rt(C,null,void 0,{isServer:!0}),E=await st(it,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,U=Kt(String(R),d),T=Xt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,U),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(U),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let at=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(at)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${at[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:L})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,ot=!1;if(e.cache){if(k=B.get(d,v.filePath),k)ot=!0,l.cachedCount++}if(!k){let C=await St(v,L,bt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|