- App.tsx: full navigation (Auth stack + Main tabs with 5 screens) - Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen - HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors - MapScreen: interactive map with layer toggles (6 layers) - MarketplaceScreen: categories (6), products (5), search - ChatScreen: AI chat with quick prompts (4), bot responses - ProfileScreen: user info, stats, menu (9 items), logout - AlertsScreen: alert list with severity, acknowledge - SensorsScreen: sensor list with type filters (6 types), search - ZonesScreen: zone cards with stats - SettingsScreen: language picker (FR/EN/ES/DE), privacy, about - Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n - Hooks: useSensors, useAlerts, useNotifications, useLocation - Components: Card, Button, LoadingSpinner, ErrorBoundary, Header - Services: iotService, notificationService (with axios API client) - Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN) - Theme: colors.ts with full design system (Blue Ocean palette) - Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
99 lines
3.3 KiB
JavaScript
99 lines
3.3 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', {
|
|
value: true
|
|
});
|
|
exports.default = globsToMatcher;
|
|
function _picomatch() {
|
|
const data = _interopRequireDefault(require('picomatch'));
|
|
_picomatch = function () {
|
|
return data;
|
|
};
|
|
return data;
|
|
}
|
|
var _replacePathSepForGlob = _interopRequireDefault(
|
|
require('./replacePathSepForGlob')
|
|
);
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : {default: obj};
|
|
}
|
|
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
const globsToMatchersMap = new Map();
|
|
const picomatchOptions = {
|
|
dot: true
|
|
};
|
|
|
|
/**
|
|
* Converts a list of globs into a function that matches a path against the
|
|
* globs.
|
|
*
|
|
* Every time picomatch is called, it will parse the glob strings and turn
|
|
* them into regexp instances. Instead of calling picomatch repeatedly with
|
|
* the same globs, we can use this function which will build the picomatch
|
|
* matchers ahead of time and then have an optimized path for determining
|
|
* whether an individual path matches.
|
|
*
|
|
* This function is intended to match the behavior of `micromatch()`.
|
|
*
|
|
* @example
|
|
* const isMatch = globsToMatcher(['*.js', '!*.test.js']);
|
|
* isMatch('pizza.js'); // true
|
|
* isMatch('pizza.test.js'); // false
|
|
*/
|
|
function globsToMatcher(globs) {
|
|
if (globs.length === 0) {
|
|
// Since there were no globs given, we can simply have a fast path here and
|
|
// return with a very simple function.
|
|
return () => false;
|
|
}
|
|
const matchers = globs.map(glob => {
|
|
if (!globsToMatchersMap.has(glob)) {
|
|
const isMatch = (0, _picomatch().default)(glob, picomatchOptions, true);
|
|
const matcher = {
|
|
isMatch,
|
|
// Matchers that are negated have different behavior than matchers that
|
|
// are not negated, so we need to store this information ahead of time.
|
|
negated: isMatch.state.negated || !!isMatch.state.negatedExtglob
|
|
};
|
|
globsToMatchersMap.set(glob, matcher);
|
|
}
|
|
return globsToMatchersMap.get(glob);
|
|
});
|
|
return path => {
|
|
const replacedPath = (0, _replacePathSepForGlob.default)(path);
|
|
let kept = undefined;
|
|
let negatives = 0;
|
|
for (let i = 0; i < matchers.length; i++) {
|
|
const {isMatch, negated} = matchers[i];
|
|
if (negated) {
|
|
negatives++;
|
|
}
|
|
const matched = isMatch(replacedPath);
|
|
if (!matched && negated) {
|
|
// The path was not matched, and the matcher is a negated matcher, so we
|
|
// want to omit the path. This means that the negative matcher is
|
|
// filtering the path out.
|
|
kept = false;
|
|
} else if (matched && !negated) {
|
|
// The path was matched, and the matcher is not a negated matcher, so we
|
|
// want to keep the path.
|
|
kept = true;
|
|
}
|
|
}
|
|
|
|
// If all of the globs were negative globs, then we want to include the path
|
|
// as long as it was not explicitly not kept. Otherwise only include
|
|
// the path if it was kept. This allows sets of globs that are all negated
|
|
// to allow some paths to be matched, while sets of globs that are mixed
|
|
// negated and non-negated to cause the negated matchers to only omit paths
|
|
// and not keep them.
|
|
return negatives === matchers.length ? kept !== false : !!kept;
|
|
};
|
|
}
|