meteor3: purge dead client packages — web UI renders on 3.1

alanning:roles removed (client crashed the whole bundle; plain user.roles
checks instead), selaias:cookie-consent replaced by in-repo React banner,
publish-performant-counts vendored with countAsync, Meteor.autorun dropped
(App)/Tracker.autorun (FiresMap), and the map publications not covered by
the REST smoke (activefiresmyloc, activefiresunionmyloc, fireAlerts,
oauth.verifyConfiguration) converted to async APIs.

Verified in browser: / and /fires render with map + cookie banner, zero
uncaught exceptions. REST smoke byte-identical (12/12).
This commit is contained in:
vjrj 2026-07-14 11:32:19 +02:00
parent 0ff9848cd4
commit eb3aec82ae
16 changed files with 194 additions and 50 deletions

View file

@ -16,7 +16,6 @@ ecmascript@0.16.10 # Enable ECMAScript2015+ syntax in app code
shell-server@0.6.1 # Server-side component of the `meteor shell` command
react-meteor-data
alanning:roles
fourseven:scss@5.0.0
accounts-base@3.0.3
accounts-password@3.0.3
@ -33,14 +32,13 @@ dynamic-import@0.7.4
static-html@1.4.0
alexwine:bootstrap-4
selaias:cookie-consent # Cookie consent
gadicc:blaze-react-component # Add braze to react
255kb:meteor-status # Connect status
# mixmax:smart-disconnect # Disconnect on lost focus (disabled to get notif)
flowkey:raven # js errors
vjrj:piwik # Stats
mdg:geolocation
natestrauser:publish-performant-counts
tcef:publish-performant-counts
ostrio:mailer # mailer
# babrahams:constellation # dev utility
percolate:migrations # db migrations

View file

@ -5,7 +5,6 @@ accounts-github@1.5.1
accounts-google@1.4.1
accounts-oauth@1.4.5
accounts-password@3.0.3
alanning:roles@1.2.10
aldeed:collection2@4.2.0
aldeed:schema-deny@4.0.2
aldeed:simple-schema@1.13.1
@ -75,7 +74,6 @@ mongo-decimal@0.2.0
mongo-dev-server@1.1.1
mongo-id@1.0.9
mongo-livedata@1.0.13
natestrauser:publish-performant-counts@0.1.2
nimble:restivus@0.8.12
npm-mongo@6.10.0
nspangler:autoreconnect@0.0.1
@ -83,7 +81,6 @@ oauth@3.0.0
oauth2@1.3.3
observe-sequence@2.0.1
ordered-dict@1.2.0
ostrio:cookies@2.8.0
ostrio:mailer@2.5.0
ostrio:meteor-root@1.0.7
percolate:migrations@2.0.1
@ -99,7 +96,6 @@ reload@1.3.2
retry@1.1.1
reywood:publish-composite@1.6.0
routepolicy@1.1.2
selaias:cookie-consent@0.4.0
service-configuration@1.3.5
sha@1.0.10
shell-server@0.6.1
@ -111,6 +107,7 @@ standard-minifier-css@1.9.3
standard-minifier-js@3.0.0
static-html@1.4.0
static-html-tools@1.0.0
tcef:publish-performant-counts@0.2.0
templating@1.4.4
templating-compiler@2.0.1
templating-runtime@2.0.2

View file

@ -251,6 +251,31 @@ MONGO_CONTAINER=tcef-mongo7 MONGO_SHELL=mongosh MONGO_PORT=27019 ./smoke/smoke.s
`WebApp.connectHandlers` handler serving the same static page list (the
per-fire section of the old handler was behind `firesMapEnabled = false`,
i.e. dead code, and was dropped). Verified serving on dev.
- ✅ **Dead client packages purged — the web UI now RENDERS on Meteor 3.**
First-ever browser verification of this branch (the smoke only covers REST)
found a chain of ancient Blaze-era packages whose client code threw at
bundle load, killing the whole app (`meteorInstall is not defined`):
- **alanning:roles 1.2.10** (client crash, and its server
`Roles.userIsInRole` is sync) → package removed; the app barely used it:
`facts.js` now checks the plain `user.roles` field (admin set cached at
startup) and App.js takes `roles` from the user doc (prop was unused).
Upgrading to roles v4 was rejected: needs a prod data migration.
- **selaias:cookie-consent** (its `Cookies` global is gone) → removed;
replaced by in-repo React `imports/ui/components/CookieConsent` reusing
the same i18n keys; `CookieConsent.init` dropped from `i18n.js`.
- **natestrauser:publish-performant-counts** server `Counter._publishCursor`
uses sync `cursor.count()`**vendored** as
`packages/publish-performant-counts` (`tcef:publish-performant-counts`)
with `countAsync` and an async-aware interval; same public API.
- `Meteor.autorun` (removed in Meteor 3) → dropped (App.js debug) /
`Tracker.autorun` (FiresMap).
- Map/server publications not exercised by the REST smoke converted to
async: `activefiresmyloc`, `activefiresunionmyloc`, `fireAlerts`
(countAsync/fetchAsync/awaited firesUnion), and `oauth.verifyConfiguration`
(findOneAsync). `migrations.js` bodies stay sync **by design** (control is
pinned at v18; prod data arrives pre-migrated) — tracked as debt.
Verified in a real browser: `/` and `/fires` render (map, search, layers,
cookie banner), zero uncaught exceptions; REST smoke byte-identical.
### Still TODO before the web (not just REST) is fully deployable on 3.x
- **React 16 → 18** render root + verify ancient react-* libs.

View file

@ -16,7 +16,7 @@ Meteor.publish('activefirestotal', function total() {
return counter;
});
const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, withMarks) => {
const activefires = async (northEastLng, northEastLat, southWestLng, southWestLat, withMarks) => {
const fires = ActiveFires.find({
ourid: {
$geoWithin: {
@ -36,10 +36,10 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit
}
});
if (Meteor.isDevelopment) console.log(`Active fires total: ${fires.count()}`);
if (Meteor.isDevelopment) console.log(`Active fires total: ${await fires.countAsync()}`);
if (withMarks && fires.fetch().length > 0) {
const union = firesUnion(fires);
if (withMarks && (await fires.fetchAsync()).length > 0) {
const union = await firesUnion(fires);
const falsePos = whichAreFalsePositives(FalsePositives, union);
const industries = whichAreFalsePositives(Industries, union);
return [fires, falsePos, industries];
@ -48,7 +48,7 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit
return fires;
};
Meteor.publish('activefiresmyloc', function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
Meteor.publish('activefiresmyloc', async function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
// latitude -90 and 90 and the longitude between -180 and 180
check(northEastLng, NumberBetween(-180, 180));
check(southWestLat, NumberBetween(-90, 90));

View file

@ -16,7 +16,7 @@ Meteor.publish('activefiresuniontotal', function total() {
return counter;
});
const activeFiresUnion = (b1, b2, c1, c2, withMarks) => {
const activeFiresUnion = async (b1, b2, c1, c2, withMarks) => {
// a --- b
// c --- d
const geometry = {
@ -46,7 +46,7 @@ const activeFiresUnion = (b1, b2, c1, c2, withMarks) => {
}
});
if (Meteor.isDevelopment) console.log(`Active fires union total: ${fires.count()}`);
if (Meteor.isDevelopment) console.log(`Active fires union total: ${await fires.countAsync()}`);
/*
if (withMarks && fires.fetch().length > 0) {
@ -59,7 +59,7 @@ const activeFiresUnion = (b1, b2, c1, c2, withMarks) => {
return fires;
};
Meteor.publish('activefiresunionmyloc', function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
Meteor.publish('activefiresunionmyloc', async function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
// latitude -90 and 90 and the longitude between -180 and 180
check(northEastLng, NumberBetween(-180, 180));
check(southWestLat, NumberBetween(-90, 90));

View file

@ -6,7 +6,7 @@ import { check } from 'meteor/check';
import { NumberBetween } from '/imports/modules/server/other-checks';
import FireAlerts from '../FireAlerts';
Meteor.publish('fireAlerts', function fireAlerts(northEastLng, northEastLat, southWestLng, southWestLat) {
Meteor.publish('fireAlerts', async function fireAlerts(northEastLng, northEastLat, southWestLng, southWestLat) {
// latitude -90 and 90 and the longitude between -180 and 180
check(northEastLng, NumberBetween(-180, 180));
check(southWestLat, NumberBetween(-90, 90));
@ -37,6 +37,6 @@ Meteor.publish('fireAlerts', function fireAlerts(northEastLng, northEastLat, sou
track: 1
}
});
if (Meteor.isDevelopment) console.log(`Neighbour alerts total: ${fires.count()}`);
if (Meteor.isDevelopment) console.log(`Neighbour alerts total: ${await fires.countAsync()}`);
return fires;
});

View file

@ -4,16 +4,16 @@ import { ServiceConfiguration } from 'meteor/service-configuration';
import rateLimit from '../../../modules/rate-limit';
Meteor.methods({
'oauth.verifyConfiguration': function oauthVerifyConfiguration(services) {
'oauth.verifyConfiguration': async function oauthVerifyConfiguration(services) {
check(services, Array);
try {
const verifiedServices = [];
services.forEach((service) => {
if (ServiceConfiguration.configurations.findOne({ service })) {
for (const service of services) {
if (await ServiceConfiguration.configurations.findOneAsync({ service })) {
verifiedServices.push(service);
}
});
}
return verifiedServices.sort();
} catch (exception) {
throw new Meteor.Error('500', exception);

View file

@ -1,4 +1,4 @@
/* global CookieConsent Intl */
/* global Intl */
import i18n from 'i18next';
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
@ -89,23 +89,9 @@ i18n.use(backend)
i18nReady.set(true);
// cookies eu consent
const cookiesOpt = {
cookieTitle: t('Uso de Cookies'),
cookieMessage: t('Utilizamos cookies para asegurar un mejor uso de nuestra web. Si continúas navegando, consideramos que aceptas su uso'),
/* cookieMessage: t('Uso de Cookies'),
cookieMessageImply: t('Utilizamos cookies para asegurar un mejor uso de nuestra web. Si continúas navegando, consideramos que aceptas su uso'), */
showLink: false,
position: 'bottom',
linkText: 'Lee más',
linkRouteName: '/privacy',
acceptButtonText: t('Aceptar'),
html: false,
expirationInDays: 70,
forceShow: false
};
CookieConsent.init(cookiesOpt);
// Cookie consent banner: selaias:cookie-consent (Blaze, dead on Meteor 3)
// replaced by the React component imports/ui/components/CookieConsent,
// which reuses the same i18n keys.
});
Meteor.subscribe('userData'); // lang is there

View file

@ -1,5 +1,18 @@
/* global Facts */
import { Roles } from 'meteor/alanning:roles';
import { Meteor } from 'meteor/meteor';
import { Facts } from 'meteor/facts-base';
Facts.setUserIdFilter(userId => Roles.userIsInRole(userId, ['admin']));
/*
* alanning:roles removed (1.x is dead on Meteor 3 crashes the whole client
* bundle at load and 4.x needs a data migration we don't want). Admin check
* against the plain `user.roles` field, cached at startup: facts are
* dev/admin instrumentation and the admin set essentially never changes.
*/
const adminIds = new Set();
Meteor.startup(async () => {
await Meteor.users
.find({ roles: 'admin' }, { fields: { _id: 1 } })
.forEachAsync(u => adminIds.add(u._id));
});
Facts.setUserIdFilter(userId => adminIds.has(userId));

View file

@ -0,0 +1,45 @@
import React, { Component } from 'react';
import i18n from 'i18next';
import './CookieConsent.scss';
/*
* Minimal cookie-consent banner replacing selaias:cookie-consent (Blaze,
* dead on Meteor 3: its `Cookies` global is gone and it crashed the whole
* client bundle at load). Same behavior: informative banner, dismissed once.
*/
const STORAGE_KEY = 'tcef-cookie-consent';
class CookieConsent extends Component {
constructor(props) {
super(props);
let accepted = false;
try {
accepted = window.localStorage.getItem(STORAGE_KEY) === 'yes';
} catch (e) { /* storage disabled: show banner every time */ }
this.state = { accepted };
this.accept = this.accept.bind(this);
}
accept() {
try {
window.localStorage.setItem(STORAGE_KEY, 'yes');
} catch (e) { /* ignore */ }
this.setState({ accepted: true });
}
render() {
if (this.state.accepted) return null;
return (
<div className="CookieConsent">
<span>
{i18n.t('Utilizamos cookies para asegurar un mejor uso de nuestra web. Si continúas navegando, consideramos que aceptas su uso')}
</span>
<button type="button" className="btn btn-primary btn-sm" onClick={this.accept}>
{i18n.t('Aceptar')}
</button>
</div>
);
}
}
export default CookieConsent;

View file

@ -0,0 +1,20 @@
.CookieConsent {
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 2000;
display: flex;
align-items: center;
justify-content: center;
gap: 1em;
padding: 0.75em 1em;
background: rgba(0, 0, 0, 0.85);
color: #fff;
font-size: 0.9em;
button {
margin-left: 1em;
white-space: nowrap;
}
}

View file

@ -9,7 +9,6 @@ import { I18nextProvider } from 'react-i18next';
import { Helmet } from 'react-helmet';
import { Meteor } from 'meteor/meteor';
import { withTracker } from 'meteor/react-meteor-data';
import { Roles } from 'meteor/alanning:roles';
// https://github.com/gadicc/meteor-blaze-react-component/
import Blaze from 'meteor/gadicc:blaze-react-component';
// i18n
@ -48,6 +47,7 @@ import About from '../../pages/About/About';
import Privacy from '../../pages/Privacy/Privacy';
import License from '../../pages/License/License';
import Credits from '../../pages/Credits/Credits';
import CookieConsent from '../../components/CookieConsent/CookieConsent';
import Footer from '../../components/Footer/Footer';
import Feedback from '../../components/Feedback/Feedback';
import ReSendEmail from '../../components/ReSendEmail/ReSendEmail';
@ -151,7 +151,7 @@ const App = props => (
<Footer />
<Reconnect {...props} />
<Feedback {...props} />
{props.i18nReady.get() && <Blaze template="cookieConsent" /> }
{props.i18nReady.get() && <CookieConsent /> }
</div>}
</LocationListener>
</Router>
@ -183,19 +183,16 @@ export default withTracker(() => {
const loggingIn = Meteor.loggingIn();
const user = Meteor.user();
const userId = Meteor.userId();
const loading = !Roles.subscription.ready() || !i18nReady.get();
const loading = !i18nReady.get();
const name = user && user.profile && user.profile.name && getUserName(user.profile.name);
const emailAddress = user && user.emails && user.emails[0].address;
Meteor.autorun(() => {
console.log(`i18n ready?: ${i18nReady.get()}`);
});
return {
loading,
loggingIn,
i18nReady,
authenticated: !loggingIn && !!userId,
name: name || emailAddress,
roles: !loading && Roles.getRolesForUser(userId),
roles: (user && user.roles) || [],
userId,
emailAddress,
emailVerified: user && user.emails ? user && user.emails && user.emails[0].verified : true

View file

@ -8,6 +8,7 @@ import { ButtonGroup, Row, Col, Checkbox } from 'react-bootstrap';
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { withTracker } from 'meteor/react-meteor-data';
import { Tracker } from 'meteor/tracker';
import { Helmet } from 'react-helmet';
import { Trans, translate } from 'react-i18next';
import { Map } from 'react-leaflet';
@ -408,7 +409,7 @@ export default translate([], { wait: true })(withTracker(() => {
}
// Disable, because this increase the number of fires by one
// Meteor.subscribe('lastFireDetected');
Meteor.autorun(() => {
Tracker.autorun(() => {
if ((centerStored !== [0, 0] || geolocation.get()) && geoInit) {
center.set(centerStored || geolocation.get());
// console.log(`Geolocation ${geolocation.get()}`);

View file

@ -0,0 +1,9 @@
/* global Counter:true */
Counter = {};
Counter.collection = new Mongo.Collection('counters-collection');
Counter.get = function (name) {
const doc = Counter.collection.findOne(name);
return doc ? doc.count : 0;
};

View file

@ -0,0 +1,16 @@
// Vendored natestrauser:publish-performant-counts 0.1.2, patched for Meteor 3
// (server cursor.count() is gone -> countAsync). Same public API: server
// `new Counter(name, cursor)`, client `Counter.get(name)`.
Package.describe({
name: 'tcef:publish-performant-counts',
version: '0.2.0',
summary: 'Vendored publish-performant-counts patched for Meteor 3 (countAsync)'
});
Package.onUse(function (api) {
api.versionsFrom('3.0');
api.use(['meteor', 'mongo', 'ecmascript']);
api.addFiles('server.js', 'server');
api.addFiles('client.js', 'client');
api.export('Counter');
});

View file

@ -0,0 +1,37 @@
/* global Counter:true */
Counter = function (name, cursor, interval) {
this.name = name;
this.cursor = cursor;
this.interval = interval || 1000 * 10;
this._collectionName = 'counters-collection';
};
// every cursor must provide a collection name via this method
Counter.prototype._getCollectionName = function () {
return `counter-${this.name}`;
};
// the api to publish (async: Meteor 3 awaits _publishCursor)
Counter.prototype._publishCursor = async function (sub) {
const self = this;
sub.added(self._collectionName, self.name, { count: await self.cursor.countAsync() });
const handler = Meteor.setInterval(async () => {
try {
const count = await self.cursor.countAsync();
sub.changed(self._collectionName, self.name, { count });
} catch (e) {
// transient db error: retry on the next tick
}
}, this.interval);
sub.onStop(() => {
Meteor.clearInterval(handler);
});
return {
stop: sub.onStop.bind(sub)
};
};