Skip to content

Commit 45fad76

Browse files
committed
refactor: firebase ssr
1 parent e7dbf2a commit 45fad76

142 files changed

Lines changed: 313250 additions & 28 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/docs/src/server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { dirname, join, resolve } from 'node:path';
55
import { fileURLToPath } from 'node:url';
66
import bootstrap from './main.server';
77

8-
function app(): express.Express {
8+
// eslint-disable-next-line @typescript-eslint/naming-convention
9+
export function app(): express.Express {
910
const server = express();
1011
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
1112
const browserDistFolder = resolve(serverDistFolder, '../browser');
@@ -44,7 +45,8 @@ function app(): express.Express {
4445
return server;
4546
}
4647

47-
function run(): void {
48+
// eslint-disable-next-line @typescript-eslint/naming-convention
49+
export function run(): void {
4850
const port = process.env['PORT'] || 4000;
4951
const server = app();
5052

firebase.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/firebase/firebase-tools/v13.35.1/schema/firebase-config.json",
3+
"functions": {
4+
"source": "functions",
5+
"runtime": "nodejs18"
6+
},
37
"hosting": [
48
{
59
"target": "stable",
@@ -92,8 +96,8 @@
9296
"cleanUrls": true,
9397
"rewrites": [
9498
{
95-
"source": "/**/!(*.@(js|ts|html|css|json|svg|png|jpg|jpeg))",
96-
"destination": "/index.csr.html"
99+
"source": "**",
100+
"function": "ssr"
97101
}
98102
],
99103
"headers": [

functions/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const server = require('./server/server.mjs');
2+
const functions = require('firebase-functions');
3+
4+
exports.ssr = functions.https.onRequest(server.app());

functions/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "functions",
3+
"main": "index.js"
4+
}
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
import {
2+
s as _,
3+
h as A,
4+
u as b,
5+
o as f,
6+
r as g,
7+
w as k,
8+
n as p,
9+
z as S,
10+
v as w,
11+
p as x,
12+
q as y
13+
} from './chunk-CW5VMV6A.mjs';
14+
import { Sa as c, u as d, g as h, a as I, G as l, da as u, M as v } from './chunk-CYLTISQO.mjs';
15+
import './polyfills.server.mjs';
16+
var n = class {
17+
get activeItemIndex() {
18+
return this._activeItemIndex;
19+
}
20+
get activeItem() {
21+
return this._activeItem;
22+
}
23+
constructor(t) {
24+
((this._items = t),
25+
(this.tabOut = new h()),
26+
(this.change = new h()),
27+
(this.previousActiveItemIndex = -1),
28+
(this._activeItemIndex = -1),
29+
(this.wrap = !1),
30+
(this.letterKeyStream = new h()),
31+
(this.typeaheadSubscription = I.EMPTY),
32+
(this.vertical = !0),
33+
(this.scrollSize = 0),
34+
(this.pressedLetters = []),
35+
(this.homeAndEnd = !1),
36+
(this.allowedModifierKeys = []),
37+
(this.skipPredicateFn = (e) => e.disabled),
38+
t instanceof c &&
39+
t.changes.subscribe((e) => {
40+
if (this._activeItem) {
41+
let s = e.toArray().indexOf(this._activeItem);
42+
s > -1 && s !== this._activeItemIndex && (this._activeItemIndex = s);
43+
}
44+
}));
45+
}
46+
isTyping() {
47+
return this.pressedLetters.length > 0;
48+
}
49+
withScrollSize(t) {
50+
return ((this.scrollSize = t), this);
51+
}
52+
withAllowedModifierKeys(t) {
53+
return ((this.allowedModifierKeys = t), this);
54+
}
55+
withWrap(t = !0) {
56+
return ((this.wrap = t), this);
57+
}
58+
skipPredicate(t) {
59+
return ((this.skipPredicateFn = t), this);
60+
}
61+
withVerticalOrientation(t = !0) {
62+
return ((this.vertical = t), this);
63+
}
64+
withHorizontalOrientation(t) {
65+
return ((this.horizontal = t), this);
66+
}
67+
withTypeAhead(t = 200, e = 0) {
68+
if (this._items.length && this._items.some((i) => typeof i.getLabel != 'function'))
69+
throw Error('ListKeyManager items in typeahead mode must implement the `getLabel` method.');
70+
return (
71+
this.typeaheadSubscription.unsubscribe(),
72+
(this.typeaheadSubscription = this.letterKeyStream
73+
.pipe(
74+
u((i) => this.pressedLetters.push(i)),
75+
v(t),
76+
l(() => this.pressedLetters.length > 0),
77+
d(() => this.pressedLetters.join(''))
78+
)
79+
.subscribe((i) => {
80+
if (e === -1) {
81+
this.pressedLetters = [];
82+
return;
83+
}
84+
let s = this._items.toArray();
85+
for (let r = 1; r < s.length + 1; r++) {
86+
let m = (this._activeItemIndex + r) % s.length,
87+
o = s[m];
88+
if (!o.disabled && o.getLabel().toUpperCase().trim().indexOf(i) === e) {
89+
this.setActiveItem(m);
90+
break;
91+
}
92+
}
93+
this.pressedLetters = [];
94+
})),
95+
this
96+
);
97+
}
98+
withHomeAndEnd(t = !0) {
99+
return ((this.homeAndEnd = t), this);
100+
}
101+
setActiveItem(t) {
102+
((this.previousActiveItemIndex = this._activeItemIndex),
103+
this.updateActiveItem(t),
104+
this._activeItemIndex !== this.previousActiveItemIndex && this.change.next(this._activeItemIndex));
105+
}
106+
onKeydown(t) {
107+
let e = t.keyCode,
108+
s = ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].every(
109+
(r) => !t[r] || this.allowedModifierKeys.indexOf(r) > -1
110+
);
111+
switch (e) {
112+
case A:
113+
this.tabOut.next();
114+
return;
115+
case _:
116+
if (this.vertical) {
117+
this.setNextItemActive();
118+
break;
119+
} else return;
120+
case y:
121+
if (this.vertical) {
122+
this.setPreviousItemActive();
123+
break;
124+
} else return;
125+
case g:
126+
if (this.horizontal === 'ltr') {
127+
this.setNextItemActive();
128+
break;
129+
} else if (this.horizontal === 'rtl') {
130+
this.setPreviousItemActive();
131+
break;
132+
} else return;
133+
case x:
134+
if (this.horizontal === 'ltr') {
135+
this.setPreviousItemActive();
136+
break;
137+
} else if (this.horizontal === 'rtl') {
138+
this.setNextItemActive();
139+
break;
140+
} else return;
141+
case f:
142+
if (this.homeAndEnd && s) {
143+
this.setFirstItemActive();
144+
break;
145+
} else return;
146+
case p:
147+
if (this.homeAndEnd && s) {
148+
this.setLastItemActive();
149+
break;
150+
} else return;
151+
default:
152+
t.key && t.key.length === 1
153+
? this.letterKeyStream.next(t.key.toLocaleUpperCase())
154+
: ((e >= k && e <= S) || (e >= b && e <= w)) &&
155+
this.letterKeyStream.next(String.fromCharCode(e));
156+
return;
157+
}
158+
((this.pressedLetters = []), t.preventDefault());
159+
}
160+
setFirstItemActive() {
161+
this.setActiveItemByIndex(0, 1);
162+
}
163+
setLastItemActive() {
164+
this.setActiveItemByIndex(this._items.length - 1, -1);
165+
}
166+
setNextItemActive() {
167+
this._activeItemIndex < 0 ? this.setFirstItemActive() : this.setActiveItemByDelta(1);
168+
}
169+
setPreviousItemActive() {
170+
this._activeItemIndex < 0 && this.wrap ? this.setLastItemActive() : this.setActiveItemByDelta(-1);
171+
}
172+
setNextPageItemActive(t = this.scrollSize) {
173+
this._activeItemIndex + t >= this._items.length ? this.setLastItemActive() : this.setActiveItemByDelta(t);
174+
}
175+
setPreviousPageItemActive(t = this.scrollSize) {
176+
this._activeItemIndex - t <= 0 ? this.setFirstItemActive() : this.setActiveItemByDelta(-t);
177+
}
178+
updateActiveItem(t) {
179+
let e = this._items.toArray(),
180+
i = typeof t == 'number' ? t : e.indexOf(t);
181+
((this._activeItemIndex = i), (this._activeItem = e[i]));
182+
}
183+
setActiveItemByDelta(t) {
184+
this.wrap ? this.setActiveInWrapMode(t) : this.setActiveInDefaultMode(t);
185+
}
186+
setActiveInWrapMode(t) {
187+
let e = this.getItemsArray();
188+
for (let i = 1; i <= e.length; i++) {
189+
let s = (this._activeItemIndex + t * i + e.length) % e.length,
190+
r = e[s];
191+
if (!this.skipPredicateFn(r)) {
192+
this.setActiveItem(s);
193+
return;
194+
}
195+
}
196+
}
197+
setActiveInDefaultMode(t) {
198+
this.setActiveItemByIndex(this._activeItemIndex + t, t);
199+
}
200+
setActiveItemByIndex(t, e) {
201+
let i = this.getItemsArray();
202+
if (!i[t]) return;
203+
let s = t;
204+
for (; this.skipPredicateFn(i[s]); ) if (((s += e), !i[s])) return;
205+
this.setActiveItem(s);
206+
}
207+
getItemsArray() {
208+
return this._items instanceof c ? this._items.toArray() : this._items;
209+
}
210+
},
211+
L = class extends n {
212+
setActiveItem(t) {
213+
(this.activeItem && this.activeItem.setInactiveStyles(),
214+
super.setActiveItem(t),
215+
this.activeItem && this.activeItem.setActiveStyles());
216+
}
217+
},
218+
O = class extends n {
219+
constructor() {
220+
(super(...arguments), (this.origin = 'program'));
221+
}
222+
setActiveItem(t) {
223+
(super.setActiveItem(t), this.activeItem && this.activeItem.focus(this.origin));
224+
}
225+
setFocusOrigin(t) {
226+
return ((this.origin = t), this);
227+
}
228+
getFocusOrigin() {
229+
return this.origin;
230+
}
231+
};
232+
export { L as a, O as b };

0 commit comments

Comments
 (0)