nextjs import multiple components from index manifest imports everything

BACKGROUND:
I have a project where I have all my UI components in a /components directory.
Right now I export each component in its own file as:

export function Component1() { ... } 

and import them individually into my page as such:

import { Component1 } from "@/components/Component1";
import { Component2 } from "@/components/Component2";

I would like to be able to import multiple components at once, like this:

import { Component1, Component2 } from "../components";

So I created this index/manifest file:
/components/index.js

import { Component1} from './Component1';
import { Component2} from './Component2';

export { Component1, Component1 }

THE ISSUE:
The issue is that when I try to import them using this syntax:

import { Component1, Component2 } from "../components";

It seems to be importing ALL the components at once because I noticed a significant slow down my compiled index.js chunk went from 169kb to 6MB.

How to hide or encrypt api calls from Network tab?

When I communicate with my server using API calls from client side. I saw my api address completly visible in the network tab. And my api data also visible in the payload. So any one can communicate with my server using this API. It’s makeing security issue in my project.

I want to completly hide my api call from the network tab. How can I do this? Or how can I encrypt my payload and response data?

Thanks a lot.

How can website schema validator show multiple of the same property

If I look at the validation of the news article below, it shows multiple “image” properties. I’m curious how this could be? How can you set your ld json data to have multiple properties with the same name of “image”?

https://validator.schema.org/#url=https%3A%2F%2Fwww.theglobeandmail.com%2Fsports%2Folympics%2Farticle-team-canada-soccer-coach-bev-priestman-out-for-game-vs-new-zealand%2F

Is it by passing an image array?

Odoo Security: Understanding security.xml vs. ir.model.access.csv

I’m trying to grasp the fundamental differences between security.xml and ir.model.access.csv files in Odoo. While I understand they both deal with security and access rights, I’m unclear about their specific roles and when to use one over the other.

Key questions:

  • What are the core purposes of each file?
  • When should I use security.xml and when ir.model.access.csv?
  • Are there performance implications or best practices for using one over the other?
  • How do these files interact with each other?
  • Can I achieve the same results using both files? If so, what are the trade-offs?

I’d appreciate concrete examples and code snippets to illustrate the concepts.

Thank you for your insights!

Thoughts by Usman Ghias

Understanding security.xml and ir.model.access.csv in Odoo

Answer by Usman Ghias

Introduction

Odoo provides two primary mechanisms for managing security and access control: security.xml and ir.model.access.csv. While they might seem similar at first glance, they serve distinct purposes and have different implications for your Odoo application.

security.xml

  • Purpose: Defines record rules, which are server-side filters determining which records a user can see or modify.
  • Location: Typically placed within the security folder of your Odoo module.
  • Structure: XML-based, using Odoo’s XML-RPC syntax.
  • Use Cases:
    • Complex access control logic based on various conditions.
    • Dynamic record visibility based on user roles or other criteria.
    • Implementing security policies that require fine-grained control.

ir.model.access.csv

  • Purpose: Defines basic access rights for models (create, read, write, delete).
  • Location: Usually placed within the data folder of your Odoo module.
  • Structure: CSV format, with columns for model name, group ID, and access rights.
  • Use Cases:
    • Assigning default access rights to groups.
    • Quick setup of basic security permissions.
    • Managing access control for simple models without complex logic.

Key Differences

Feature security.xml ir.model.access.csv
Flexibility High Low
Performance Can be slower for complex rules Generally faster
Complexity More complex to write and maintain Simpler to manage
Typical Use Cases Complex security scenarios, dynamic record visibility Basic access rights, default permissions

Best Practices

  • Use ir.model.access.csv for simple access control and default permissions.
  • Employ security.xml for intricate security logic and dynamic record filtering.
  • Consider performance implications when using complex record rules.
  • Test your security configuration thoroughly to prevent unauthorized access.

Additional Considerations

  • Both files can be used together to create a comprehensive security model.
  • Record rules in security.xml can override permissions defined in ir.model.access.csv.
  • It’s essential to balance security and usability when designing access controls.

Clear Understanding

By understanding these distinctions and following best practices, you can effectively implement robust security in your Odoo applications.

Would you like to delve deeper into a specific use case or explore advanced security techniques?

How to expand the telegram web application to the top using window.Telegram.WebApp.expand(); in html

How to expand the telegram web application to the top using window.Telegram.WebApp.expand(); in html
, here is an example of my code, but nothing works

<html>
<head>
    
    <script>
    window.Telegram.WebApp.ready();
    window.Telegram.WebApp.expand();
    </script>
    
    
</head>

I don’t know if I’m using window.Telegram incorrectly.WebApp.expand();
I’m just a beginner

Tomtom api search by street

This is something I shouldn’t ask here, doubting that I will get too many answers, but I have no idea where else to look for an answer. The documentation is very light and there is not support offered.
So what I’m trying to achieve(or figure out if it’s achievable), is to search by street name in a given country using tomtom’s search api.
You can set the country, which is great, but that’s it.
If I want to search for all oxford streets in the UK and set the query value to ‘oxford str’ , it returns everything what has oxford in it, which is not what I want.
I would probably should use the autocomplete endpoint, but that’s even confusing and restricted. If I set the same parameters, it returns nothing.

Is it doable what I want, or this api is simply just built to search for shops and restaurants?

Thanks.

Does Datadog RUM track events before the onReady callback fires?

Looking at the docs, it’s a bit unclear whether I need to wait for the onReady callback to fire to track events.

My question is, do I have to write my code this way?

datadogRum.init(...)
dataDogRum.onReady(() => {
   // Might throw an error, we should log them
   renderApp()
})

Or does datadog buffer it, and let me dog something like:

datadogRum.init(...)

// Might throw an error, we should log them
renderApp()

In the latter case, will I lose any events that the renderApp method sends, because I didn’t wait for the onReady()? Or will RUM still track them and send them once its ready?

remove white spaces till /n in js, and put it inside a array

I’m looking for a way of put all three lines of my html inside an array, but those three lines will be breaked in 3 index. My array has to be a 3 length array, with a line in each index.
I see that i can accomplish that by rearrange my paragraph removing white spaces and making them more close, right in the html file. So i would like to know if there are others ways using only JS for that. This is what i have done so far, when i click on convert button, and look at console log, there a confuse array, with more than 3 index and full of white spaces:
enter image description here
i would like to remove those white spaces and have just 3 index with those 3 text lines.
I’ve tried trim(), but it only remove from the first index, the second and third not.
enter image description here

//let stringg = document.querySelector('input');

let btn = document.querySelector('button');
let p = document.querySelector('.example-text');

let x = p.innerText.toString();
let y = x.split('n');

btn.onclick = function(){
    console.log(y);
};
<p class="question">4. Write a JavaScript program to convert a 
                       comma-separated value (CSV) string to a 
                       2D array of objects. 
</p>
<p class="example-text" style="display: none ;">
        this,is,text,example
        lets,go,try,if,i
        can,solve,this issue</p>
<div class="butt-out">
  <button id="btn-press">convert</button>
</div>

Can i clone/copy card game script

I’m interested in creating my own 3-card poker website to play with friends and potentially others. However, I’m pretty new to the technical aspects involved, like backend, frontend, and game logic. Here are a few questions I have:

Is it possible to copy the game script from another website? Can I use the script from an existing 3-card poker site, or are those scripts typically stored on a server that I wouldn’t have access to?

Decompiling game files: I tried decompiling an .apk file for a specific 3-card poker game to get the source code, but I couldn’t complete the process. Is this a viable approach? If so, any tips on how to successfully do it?

Any help or guidance would be greatly appreciated. Thanks in advance!

function calling in $(document).ready() vs $(document).ready(function() {})

I am using displayRows() function to add table body using document.ready. It was working fine for syntax : $(document).ready(function() as below

'$(document).ready(function() {
 function displayRows(){
var catRow = $('<tr class="category-row">'
+ '<th>'
+...........
+ '</th>'                                                         + '</tr>');
$('#cat tbody').append(catRow);
}
});`

But when I removed the function() as below, the table is not getting appended.

`$(document).ready(
function displayRows(){
var catRow = $('<tr class="category-row">'
+ '<th>'
+...........
+ '</th>'                                                         + '</tr>');
$('#cat tbody').append(catRow);
}
});`

Can anyone explain why it’s not working in below case.

I expect it should work in same in both cases. As document.ready() require a function to be passed in it. And displayRows() function is still passed as a function to document.ready in second case.

Selenium Nodejs – Trying To Select Button

The HTML

<button class="RCK Hsu USg adn gn8 L4E kVc iyn S9z Vxj aZc Zr3 hA- Il7 hNT BG7" tabindex="0" type="submit">
     <div class="KS5 hs0 mQ8 un8 tkf TB_">
          <div class="xuA">
               <div class="tBJ dyH iFc sAJ B1n tg7 H2s">Log in</div>
          </div>
     </div>
</button>

The Code

...

await driver
      .findElement(
        By.css(
          "button.RCK.Hsu.USg.adn.gn8.L4E.kVc.CCY.S9z.Vxj.aZc.Zr3.hA-.Il7.hNT.BG7"
        )
      )
      .click(); 

...

The Error

NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"button.RCK.Hsu.USg.adn.gn8.L4E.kVc.CCY.S9z.Vxj.aZc.Zr3.hA-.Il7.hNT.BG7"}

The Problem

I’m trying to select the button above using Selenium. I’ve been able to select other elements using xpath and id. But I’ve been unable to select the button shown above. Ideally I would want the button selected. I tried xpath and css but nothing is working. Can someone help me out?

Problem with CSS :valid pseudo-class and required input

I am learning front-end and PHP. I was able to come up with this little form behaving almost perfectly the way I want it.

The problem is, some inputs are not required, that being the case, they are valid even when empty. Because of that, when the page is loaded they already have the classes that should only take form when something is typed. Is there a way around this somehow?

<!DOCTYPE html>
<html lang="pt-br">
<head>
  <meta charset="UTF-8">
  <title>Cadastro de Funcionários</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
  <link rel="stylesheet" href="style2.css">
</head>
<body>
  <div class="container">
    <div class="text">
      Cadastro de Funcionários
    </div>
    <form method="post" action="post.php">
      <div class="form-row">
         <div class="input-data">
            <input type="text" id="ctps" maxlength="8" name="ctps" required>
            <div class="underline"></div>
            <label for="pis">Carteira de Trabalho</label>
         </div>

         <div class="input-data input-data narrow">
            <input type="text" id="phone" maxlength="14" name="phone">
            <div class="underline"></div>
            <label for="phone">Telefone</label>
         </div>

         <div class="input-data select-container input-data tiny">
          <select name="ativo" required>
           <option value="" selected></option>
            <?php
            $query = $pdo->query("SELECT id, ativo FROM ativos");
            $registros = $query->fetchAll(PDO::FETCH_ASSOC);
            foreach ($registros as $option) {
              echo '<option value="' . $option['id'] . '|' . $option['ativo'] . '">' . $option['ativo'] . '</option>';
            }
            ?>
          </select>
          <div class="underline"></div>
          <label for="ativo">Ativo?</label>
        </div>
 

        <div class="input-data">
          <input type="date" name="demissao">
          <div class="underline"></div>
          <label for="demissao">Demissão</label>
        </div>
      </div>

      <div class="form-row submit-btn">
         <div class="input-data">
            <div class="inner"></div>
            <input type="submit" value="Salvar">
         </div>

         <div class="input-data">
            <div class="inner"></div>
            <input type="reset" value="Limpar">
         </div>
      </div>
    </form>
  </div>

<script src="script.js"></script>
</body>
</html>
@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');
*{
  margin: 0;
  padding: 0;
  outline: none;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}
body{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 10px;
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(115deg, #01a89e 10%, #006571 90%);
}
.container{
  max-width: 1300px;
  background: #fff;
  width: 1300px;
  padding: 25px 40px 10px 40px;
  box-shadow: 0px 0px 10px rgba(0,0,0,0.1);
}
.container .text{
  text-align: center;
  font-size: 41px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  background: -webkit-linear-gradient(right, #01a89e, #006571, #01a89e, #006571);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.container form{
  padding: 0 0 0 0;
}
.container form .form-row{
  display: flex;
  margin: 30px 0;
}
form .form-row .input-data{
  width: 100%;
  height: 40px;
  margin: 0 20px;
  position: relative;
}
form .form-row .textarea{
  height: 70px;
}
.input-data input,
.textarea textarea{
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  font-size: 17px;
  border-bottom: 2px solid rgba(0,0,0, 0.12);
}

.textarea textarea{
  resize: none;
  padding-top: 10px;
}
.input-data label{
  position: absolute;
  pointer-events: none;
  bottom: 10px;
  font-size: 16px;
  transition: all 0.3s ease;
}
.textarea label{
  width: 100%;
  bottom: 40px;
  background: #fff;
}
.input-data .underline{
  position: absolute;
  bottom: 0;
  height: 2px;
  width: 100%;
}
.input-data .underline:before{
  position: absolute;
  content: "";
  height: 2px;
  width: 100%;
  background: #3498db;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}

.submit-btn .input-data{
  overflow: hidden;
  height: 45px!important;
  width: 25%!important;
}
.submit-btn .input-data .inner{
  height: 100%;
  width: 300%;
  position: absolute;
  left: -100%;
  background: -webkit-linear-gradient(right, #01a89e, #006571, #01a89e, #006571);
  transition: all 0.4s;
}
.submit-btn .input-data:hover .inner{
  left: 0;
}
.submit-btn .input-data input{
  background: none;
  border: none;
  color: #fff;
  font-size: 17px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
@media (max-width: 700px) {
  .container .text{
    font-size: 30px;
  }
  .container form{
    padding: 10px 0 0 0;
  }
  .container form .form-row{
    display: block;
  }
  form .form-row .input-data{
    margin: 35px 0!important;
  }
  .submit-btn .input-data{
    width: 40%!important;
  }
}


input, select {
  display: block;
  width: 100%;
  height: 40px; 
  border: none;
  font-size: 17px;
  border-bottom: 2px solid rgba(0,0,0, 0.12);
  background: #fff; 
}






.select-container .underline:before {
  position: absolute;
  content: "";
  height: 2px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}


.select-container {
  position: relative;
  width: 100%;
}

.select-container label {
  position: absolute;
  pointer-events: none;
  bottom: 10px;
  font-size: 16px;
  transition: all 0.3s ease;
}

.input-data {
  flex: 1;
  margin: 0 10px;
}

.input-data.mid {
  flex: 0.4;
}

.input-data.narrow {
  flex: 0.3; 
}

.input-data.tiny {
  flex: 0.2; 
}

.uppercase {
  text-transform: uppercase;
}

.select-container select:focus ~ .underline:before,
.select-container select:valid ~ .underline:before {
  transform: scale(1);
}

.input-data select:focus ~ label, .textarea textarea:focus ~ label,
.input-data select:valid ~ label, .textarea textarea:valid ~ label
.input-data input:focus ~ label, .textarea textarea:focus ~ label,
.input-data input:valid ~ label, .textarea textarea:valid ~ label{
  transform: translateY(-20px);
  font-size: 14px;
  color: #3498db;
}

.input-data input:focus ~ .underline:before,
.input-data input:valid ~ .underline:before,
.textarea textarea:focus ~ .underline:before,
.textarea textarea:valid ~ .underline:before{
  transform: scale(1);
}

select:focus ~ label, select:valid ~ label {
  transform: translateY(-20px);
  font-size: 14px;
}

input[type=date]::-webkit-datetime-edit{ color: transparent; }
input[type=date]:valid::-webkit-datetime-edit{ color: #000; }
input[type=date]:focus::-webkit-datetime-edit{ color: #000; }

input[type=date]{ color: transparent; }
input[type=date]:valid{ color: #000; }
input[type=date]:focus{ color: #000; }

Ideally even the inputs that are not required would only get the :valid css styles if something is typed.

RNGestureHandlerModule could not be found

I am creating a basic React-Native Expo App, and I have been consistently running into one problem.
I have seen other Stack Overflow questions on the same topic, linked below. I have tried the solutions (if there are any solutions), but none of them worked.

Invariant Violation:TurboModuleRegistry.getEnforcing(…):’RNGestureHandlerModule’ could not be found

When I make a development build for my app, and run the development build, I get the two error below:

Error 1:

Invariant Violation: TurboModuleRegistry.getEnforcing(…): ‘RNGestureHandlerModule’ could not be found.
Verify that a module by this name is registered in the native binary.Bridgeless mode: false.
TurboModule interop: false. Modules loaded: {“NativeModules”:[“PlatformConstants”,”LogBox”,”SourceCode”,”Timing”,”AppState”,”BlobModule”,”WebSocketModule”,”DevSettings”,”DevToolsSettingsManager”,”Networking”,”Appearance”,”DevLoadingView”,”HeadlessJsTaskSupport”,”DeviceInfo”,”UIManager”,”ImageLoader”,”SoundManager”,”IntentAndroid”,”DeviceEventManager”,”NativeAnimatedModule”,”I18nManager”],”TurboModules”:[],”NotFound”:[“NativePerformanceCxx”,”NativePerformanceObserverCxx”,”RedBox”,”BugReporting”,”LinkingManager”,”NativeReactNativeFeatureFlagsCxx”,”RNCSafeAreaContext”,”RNGestureHandlerModule”]}, js engine: hermes

Error 2:

ERROR Invariant Violation: “main” has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn’t called., js engine: hermes

I must specify that this project does work locally. It only fails when I run it as a development build.

As for my code, I have a simple navigation setup, with an App.js file, HomeScreen.js, and ContactScreen.js. The app is brand new, and simply for testing.

App.js:

import 'react-native-gesture-handler';
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import HomeScreen from './screens/HomeScreen';
import ContactScreen from './screens/ContactScreen';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Home">
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Contact" component={ContactScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

HomeScreen.js:

import React from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';

const HomeScreen = ({ navigation }) => {
  return (
    <View style={styles.container}>
      <Text style={styles.title}>Home Page</Text>
      <Button
        title="Go to Contact Page"
        onPress={() => navigation.navigate('Contact')}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  title: {
    fontSize: 24,
    marginBottom: 20,
  },
});

export default HomeScreen;

ContactScreen.js:

import React from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';

const ContactScreen = ({ navigation }) => {
  return (
    <View style={styles.container}>
      <Text style={styles.title}>Contact Page</Text>
      <Button
        title="Go to Home Page"
        onPress={() => navigation.navigate('Home')}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  title: {
    fontSize: 24,
    marginBottom: 20,
  },
});

export default ContactScreen;

And here’s my Package.json file:

{
  "name": "yoyo",
  "version": "1.0.0",
  "main": "expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@react-navigation/native": "^6.1.18",
    "@react-navigation/stack": "^6.4.1",
    "expo": "^51.0.22",
    "expo-dev-client": "~4.0.20",
    "expo-status-bar": "~1.12.1",
    "react": "18.2.0",
    "react-native": "0.74.3",
    "react-native-document-picker": "^9.3.0",
    "react-native-gesture-handler": "~2.16.1",
    "react-native-safe-area-context": "4.10.5",
    "react-native-screens": "3.31.1",
    "react-navigation": "^5.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

Steps to reproduce:

npx create-expo-app yoyo --template blank
cd yoyo
yarn add expo
npx expo install expo-dev-client
npm install -g eas-cli
eas login
npx eas build:configure
npx eas build --profile development --platform android