Skip to content

Commit

Permalink
Big Fixes + ENV Rework + Asset/CDN prefix + there's still more
Browse files Browse the repository at this point in the history
* Fixed icon & font rendering on native
* Code now ensures NEXT_PUBLIC_ and EXPO_PUBLIC_ ENV vars are duplicated across both names
* Createed util for getting public ENV vars
* Added asset/CDN prefix
* Fixed some type errors
* Added Dripsy-ified variants of used `@expo/vector-icons` components (also see: expo/vector-icons#317)
* Updated Solito fork to use a `'link'` variant by default for the `<TextLink>`'s child `<P>` component
  * Renamed `'a'` variant to `'link'`
* Updated Solito fork to fix a mistake in Solito's typing
  • Loading branch information
BellCubeDev committed Nov 17, 2024
1 parent 553d456 commit dab66be
Show file tree
Hide file tree
Showing 35 changed files with 714 additions and 220 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ IS_SAAS = false
EXPO_PUBLIC_DEFAULT_SERVER = 'https://10.0.0.128/'
NEXT_PUBLIC_BASEURL = 'https://10.0.0.128/'

# OPTIONAL: Prefix for the asset URLs. May be a path or a full URL.
#
# Assets include fonts, images, Next.js scripts, static pages,
# and other things that only change when the site/app is rebuilt.
#
# Examples:
# - "/assets/"
# - "https://cdn.example.com/"
NEXT_PUBLIC_ASSET_PREFIX = 'https://10.0.0.128/'


SITE_PORT=3000
SUPABASE_STUDIO_PORT=4080
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ src/interface/components/icons/material-symbols/.commit-sha
docker-compose-setup/supabase_volumes/db/init/*
!docker-compose-setup/supabase_volumes/db/init/data.sql

/src/platforms/next/public/robots.txt
/src/platforms/next/public/sitemap*.xml


# Test Caching! (caching resources used in tests, not caching test results)
tests/cache

Expand Down
41 changes: 33 additions & 8 deletions docker-compose-setup/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,39 @@ DOCKER_SOCKET_LOCATION=/run/user/1000/docker.sock




# OPTIONAL: Base URL of your web server, used for SEO metadata and the Web App Manifest.
#
# For an example, the default is "https://stockedhome.app/"
NEXT_PUBLIC_BASEURL=



# OPTIONAL: Prefix for the asset URLs. May be a path or a full URL.
#
# Assets include fonts, images, Next.js scripts, static pages,
# and other things that only change when the site/app is rebuilt.
#
# Examples:
# - "/assets/"
# - "https://cdn.example.com/"
NEXT_PUBLIC_ASSET_PREFIX=
















############
# Database - You can change these to any PostgreSQL database that has logical replication enabled.
############
Expand Down Expand Up @@ -140,11 +173,3 @@ SUPABASE_PUBLIC_URL=http://localhost:${SUPABASE_STUDIO_PORT}
# Google Cloud Project details. Uncomment both in here and in Docker Compose to use.
#GOOGLE_PROJECT_ID=GOOGLE_PROJECT_ID
#GOOGLE_PROJECT_NUMBER=GOOGLE_PROJECT_NUMBER




# OPTIONAL: Base URL of your web server, used for SEO metadata and the Web App Manifest.
#
# For an example, the default is "https://stockedhome.app/"
NEXT_PUBLIC_BASEURL = ''
1 change: 1 addition & 0 deletions docker-compose-setup/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ services:
USE_SAAS_UX: ${USE_SAAS_UX}
NODE_ENV: production
NEXT_PUBLIC_BASEURL: ${NEXT_PUBLIC_BASEURL:-https://stockedhome.app}
NEXT_PUBLIC_ASSET_PREFIX: ${NEXT_PUBLIC_ASSET_PREFIX:-}


studio:
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"@gorhom/bottom-sheet": "^4.6.4",
"@prisma/client": "^5.21.1",
"@react-native-cookies/cookies": "^6.2.1",
"@react-native/assets-registry": "file:./src/forks/assets-registry",
"@stockedhome/codegen": "link:codegen/results",
"@stockedhome/expo-app": "file:./src/platforms/expo",
"@stockedhome/next-app": "file:./src/platforms/next",
Expand Down Expand Up @@ -114,7 +113,9 @@
"pnpm": {
"patchedDependencies": {
"@hexagon/base64": "patches/@hexagon__base64.patch",
"react-native-safe-area-context": "patches/react-native-safe-area-context.patch"
"react-native-safe-area-context": "patches/react-native-safe-area-context.patch",
"@react-native/assets-registry": "patches/@react-native__assets-registry.patch",
"next-sitemap": "patches/next-sitemap.patch"
},
"overrides": {
"next": "^15.0.1",
Expand Down
101 changes: 101 additions & 0 deletions patches/@react-native__assets-registry.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
diff --git a/path-support.js b/path-support.js
index f0a85af33ff98d3d6d8a9c279378eb2676af160a..87f5df3ccd7e2358ac83b8c6005f8ded60d28bf8 100755
--- a/path-support.js
+++ b/path-support.js
@@ -10,7 +10,7 @@

'use strict';

-import type {PackagerAsset} from './registry.js';
+//import type {PackagerAsset} from './registry.js';

const androidScaleSuffix = {
'0.75': 'ldpi',
@@ -27,7 +27,7 @@ const ANDROID_BASE_DENSITY = 160;
* FIXME: using number to represent discrete scale numbers is fragile in essence because of
* floating point numbers imprecision.
*/
-function getAndroidAssetSuffix(scale: number): string {
+function getAndroidAssetSuffix(scale) {
if (scale.toString() in androidScaleSuffix) {
return androidScaleSuffix[scale.toString()];
}
@@ -52,9 +52,9 @@ const drawableFileTypes = new Set([
]);

function getAndroidResourceFolderName(
- asset: PackagerAsset,
- scale: number,
-): string | $TEMPORARY$string<'raw'> {
+ asset,//: PackagerAsset,
+ scale,//: number,
+) {
if (!drawableFileTypes.has(asset.type)) {
return 'raw';
}
@@ -72,7 +72,7 @@ function getAndroidResourceFolderName(
return 'drawable-' + suffix;
}

-function getAndroidResourceIdentifier(asset: PackagerAsset): string {
+function getAndroidResourceIdentifier(asset) {
return (getBasePath(asset) + '/' + asset.name)
.toLowerCase()
.replace(/\//g, '_') // Encode folder structure in file name
@@ -80,7 +80,7 @@ function getAndroidResourceIdentifier(asset: PackagerAsset): string {
.replace(/^assets_/, ''); // Remove "assets_" prefix
}

-function getBasePath(asset: PackagerAsset): string {
+function getBasePath(asset) {
const basePath = asset.httpServerLocation;
return basePath.startsWith('/') ? basePath.slice(1) : basePath;
}
diff --git a/registry.js b/registry.js
index 02470da3c4962ad1bbdc62d9ed295c19ca4905fe..584c758f2d18f3dd611bcf2614528240346c8747 100755
--- a/registry.js
+++ b/registry.js
@@ -10,28 +10,28 @@

'use strict';

-export type PackagerAsset = {
- +__packager_asset: boolean,
- +fileSystemLocation: string,
- +httpServerLocation: string,
- +width: ?number,
- +height: ?number,
- +scales: Array<number>,
- +hash: string,
- +name: string,
- +type: string,
- ...
-};
+//export type PackagerAsset = {
+// +__packager_asset: boolean,
+// +fileSystemLocation: string,
+// +httpServerLocation: string,
+// +width: ?number,
+// +height: ?number,
+// +scales: Array<number>,
+// +hash: string,
+// +name: string,
+// +type: string,
+// ...
+//};

-const assets: Array<PackagerAsset> = [];
+const assets = [];

-function registerAsset(asset: PackagerAsset): number {
+function registerAsset(asset) {
// `push` returns new array length, so the first asset will
// get id 1 (not 0) to make the value truthy
return assets.push(asset);
}

-function getAssetByID(assetId: number): PackagerAsset {
+function getAssetByID(assetId) {
return assets[assetId - 1];
}

16 changes: 16 additions & 0 deletions patches/next-sitemap.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/package.json b/package.json
index 64d04d7664700d58e7914e8a01ee2a19227fd303..c22ec3aa572b2a36bea0b678679e72414842c60d 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,11 @@
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"types": "./dist/@types/index.d.ts"
+ },
+ "./*": {
+ "import": "./dist/esm/*.js",
+ "require": "./dist/cjs/*.js",
+ "types": "./dist/@types/*.d.ts"
}
},
"files": [
Loading

0 comments on commit dab66be

Please sign in to comment.