Skip to content

Commit

Permalink
Merge branch 'main' into observer_excludedchild
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanpodila authored Nov 24, 2023
2 parents 4e67b13 + d7dbbf5 commit 9741494
Show file tree
Hide file tree
Showing 15 changed files with 9,502 additions and 7,944 deletions.
2 changes: 2 additions & 0 deletions docs/docs/api/observers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Observers
---

import { PubBadge } from '../../src/components/PubBadge';

## Observer Widget

#### `Observer({required Widget Function(BuildContext context) builder})`
Expand Down
1 change: 1 addition & 0 deletions docs/docs/examples/dice/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ slug: /examples/dice

import { Profile } from '../../../src/components/Testimonial';
import diceJpg from './dice.gif';
import { PubBadge } from '../../../src/components/PubBadge';

<Profile
author="Giri Jeedigunta"
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/getting-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ Add the following **dependencies** to your `pubspec.yaml` file.

```yaml
dependencies:
mobx: ^{{ plugins.mobx }}
flutter_mobx: ^{{ plugins.flutter_mobx }}
mobx: ^{{ mobx }}
flutter_mobx: ^{{ flutter_mobx }}
```
Next add the following **dev_dependencies**:
```yaml
dev_dependencies:
build_runner: ^{{ plugins.build_runner }}
mobx_codegen: ^{{ plugins.mobx_codegen }}
build_runner: ^{{ build_runner }}
mobx_codegen: ^{{ mobx_codegen }}
```
In your project folder, run this command to fetch all the packages:
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/guides/cheat-sheet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ These packages should appear in your `pubspec.yaml` like below.

```yaml
dependencies:
mobx: ^{{ plugins.mobx }}
flutter_mobx: ^{{ plugins.flutter_mobx }}
mobx: ^{{ mobx }}
flutter_mobx: ^{{ flutter_mobx }}

dev_dependencies:
build_runner: ^{{ plugins.build_runner }}
mobx_codegen: ^{{ plugins.mobx_codegen }}
build_runner: ^{{ build_runner }}
mobx_codegen: ^{{ mobx_codegen }}
```
## Declaring a Store class
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/guides/json-serialization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ it.

```yaml
dependencies:
json_serializable: ^{{ plugins.json_serializable }}
json_annotation: ^{{ plugins.json_annotation }}
json_serializable: ^{{ json_serializable }}
json_annotation: ^{{ json_annotation }}
```
## Adding annotations
Expand Down
11 changes: 0 additions & 11 deletions docs/docs/versions.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {
copyright: `Copyright © ${new Date().getFullYear()} MobX.dart team. Built with Docusaurus.`,
},
prism: {
theme: require('prism-react-renderer/themes/vsDark'),
theme: require('prism-react-renderer').themes.vsDark,
additionalLanguages: ['dart'],
defaultLanguage: 'dart',
},
Expand Down
28 changes: 15 additions & 13 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"serve": "docusaurus serve"
},
"dependencies": {
"@docusaurus/core": "^2.2.0",
"@docusaurus/preset-classic": "^2.2.0",
"@emotion/styled": "^11.10.5",
"@emotion/react": "^11.10.5",
"@mdx-js/mdx": "^1.6.22",
"axios": "^0.27.2",
"dotenv": "^16.0.2",
"@docusaurus/core": "^3.0.0",
"@docusaurus/preset-classic": "^3.0.0",
"@emotion/styled": "^11.11.0",
"@emotion/react": "^11.11.1",
"@mdx-js/react": "^3.0.0",
"axios": "^1.6.2",
"dotenv": "^16.3.1",
"lodash.get": "^4.4.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand All @@ -35,12 +35,14 @@
]
},
"devDependencies": {
"prettier": "^2.8.1",
"prism-react-renderer": "^1.3.5",
"@docusaurus/module-type-aliases": "2.2.0",
"@tsconfig/docusaurus": "^1.0.5",
"typescript": "^4.9.4",
"webpack": "^5.76.0"
"prettier": "^3.1.0",
"prism-react-renderer": "^2.3.0",
"@docusaurus/module-type-aliases": "3.0.0",
"@docusaurus/types": "^3.0.0",
"typescript": "^5.3.2",
"@types/react": "^18.2.38",
"webpack": "^5.89.0",
"@types/lodash.get": "^4.4.7"
},
"peerDependencies": {
"react-loadable": "^5.5.0",
Expand Down
73 changes: 19 additions & 54 deletions docs/plugins/fetch-versions/index.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,52 @@
const webpack = require('webpack');
const axios = require('axios');
const plugins = [
{
pub: 'mobx',
},
{
pub: 'flutter_mobx',
},
{
pub: 'mobx_codegen',
},
{
pub: 'build_runner',
},
{
pub: 'json_serializable',
},
{
pub: 'json_annotation',
},
'mobx',
'flutter_mobx',
'mobx_codegen',
'build_runner',
'json_serializable',
'json_annotation',
];

// Fetch the plugins latest version from the pub API
async function fetchPluginVersion(plugin) {
const defaultVersion = 'any';

try {
const response = await axios.get(`https://pub.dev/packages/${plugin}.json`);
const versions = response.data.versions;

if (!Array.isArray(versions)) {
return '';
return defaultVersion;
}

return versions[0];
} catch (e) {
console.log(`Failed to load version for plugin "${plugin}".`);
return '';
return defaultVersion;
}
}

module.exports = function sourceVersions() {
return {
name: '@mobx/fetch-versions',
// Create a content string which will contain pub.dev versions for each plugin in the format of a .env file
// See https://www.npmjs.com/package/dotenv#usage for more information.
// Create a content map which will contain pub.dev versions for each plugin
async loadContent() {
let versions = '';

for (let i = 0; i < plugins.length; i++) {
const { pub } = plugins[i];
let versions = {};

const version = await fetchPluginVersion(pub);
versions += `PUB_${pub.toUpperCase()}=${version}`;
if (i < plugins.length - 1) versions += '\n';
for (let plugin of plugins) {
versions[plugin] = await fetchPluginVersion(plugin);
}

return versions;
},
// Using the content string, create a cached file on the local filesystem
// Read the contents of the file with dotenv.
// See https://www.npmjs.com/package/dotenv#path for more information.
// Using the content map and set as global data
async contentLoaded({ content, actions }) {
require('dotenv').config({
path: await actions.createData('versions.env', content),
debug: process.env.NODE_ENV !== 'production',
const { setGlobalData } = actions;

setGlobalData({
versions: content,
});
},
// Using webpack, create a global variable for each plugin, using the created environment variable.
// This ensures we can access the data on both the server and client.
// See https://webpack.js.org/plugins/define-plugin/ for more information.
configureWebpack() {
return {
plugins: [
new webpack.DefinePlugin(
plugins.reduce((current, plugin) => {
const envVar = `PUB_${plugin.pub.toUpperCase()}`;
return {
...current,
[envVar]: JSON.stringify(process.env[envVar] || ''),
};
}, {})
),
],
};
},
};
};
Loading

0 comments on commit 9741494

Please sign in to comment.