Skip to content

Commit

Permalink
Merge branch 'master' into migration3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRuggster authored Jul 25, 2024
2 parents bf17d5a + 59ddb0f commit 036db2d
Show file tree
Hide file tree
Showing 12 changed files with 2,574 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
.eslintcache
.npm
/client/tmp
node_modules
node_modules
19 changes: 19 additions & 0 deletions .meteorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.github
.gitignore
.npm
.DS_Store
.eslintcache
.eslintrc
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
HISTORY.md
LICENCE
LICENSE
ORIGINAL FlowRouter LICENSE
README.md
index.test-d.ts
package-lock.json
package.json
/test/
/docs/
84 changes: 42 additions & 42 deletions .versions
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
accounts-base@2.2.3
accounts-base@2.2.10
allow-deny@1.1.1
babel-compiler@7.9.0
babel-compiler@7.10.5
babel-runtime@1.5.1
base64@1.0.12
binary-heap@1.0.11
boilerplate-generator@1.7.1
callback-hook@1.4.0
check@1.3.1
boilerplate-generator@1.7.2
callback-hook@1.5.1
check@1.3.2
communitypackages:fast-render@4.0.6
communitypackages:inject-data@2.3.2
communitypackages:picker@1.1.0
ddp@1.4.0
ddp-client@2.5.0
ddp@1.4.1
ddp-client@2.6.1
ddp-common@1.4.0
ddp-rate-limiter@1.1.0
ddp-server@2.5.0
diff-sequence@1.1.1
dynamic-import@0.7.2
ecmascript@0.16.2
ecmascript-runtime@0.8.0
ddp-rate-limiter@1.2.1
ddp-server@2.7.0
diff-sequence@1.1.2
dynamic-import@0.7.3
ecmascript@0.16.8
ecmascript-runtime@0.8.1
ecmascript-runtime-client@0.12.1
ecmascript-runtime-server@0.11.0
ejson@1.1.2
fetch@0.1.1
geojson-utils@1.0.10
ejson@1.1.3
fetch@0.1.4
geojson-utils@1.0.11
http@1.4.2
id-map@1.1.1
inter-process-messaging@0.1.1
livedata@1.0.18
local-test:ostrio:flow-router-extra@3.9.0
local-test:ostrio:flow-router-extra@3.10.1
localstorage@1.2.0
logging@1.3.1
meteor@1.10.0
minimongo@1.8.0
modern-browsers@0.1.8
modules@0.18.0
modules-runtime@0.13.0
mongo@1.15.0
logging@1.3.3
meteor@1.11.5
minimongo@1.9.3
modern-browsers@0.1.10
modules@0.20.0
modules-runtime@0.13.1
mongo@1.16.8
mongo-decimal@0.1.3
mongo-dev-server@1.1.0
mongo-id@1.0.8
montiapm:meteorx@2.2.0
npm-mongo@4.3.1
montiapm:meteorx@2.3.1
npm-mongo@4.17.2
ordered-dict@1.1.0
ostrio:flow-router-extra@3.9.0
promise@0.12.0
random@1.2.0
rate-limit@1.0.9
react-fast-refresh@0.2.3
reactive-dict@1.3.0
reactive-var@1.0.11
ostrio:flow-router-extra@3.10.1
promise@0.12.2
random@1.2.1
rate-limit@1.1.1
react-fast-refresh@0.2.8
reactive-dict@1.3.1
reactive-var@1.0.12
reload@1.3.1
retry@1.1.0
routepolicy@1.1.1
server-render@0.4.0
service-configuration@1.3.0
socket-stream-client@0.5.0
tinytest@1.2.1
tracker@1.2.0
underscore@1.0.10
server-render@0.4.1
socket-stream-client@0.5.2
tinytest@1.2.3
tracker@1.3.3
typescript@4.9.5
underscore@1.6.0
url@1.3.2
webapp@1.13.1
webapp-hashing@1.1.0
zodern:types@1.0.9
webapp@1.13.8
webapp-hashing@1.1.1
zodern:types@1.0.13
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2023, dr.dimitru (Dmitry A.; Veliov Group, LLC)
Copyright (c) 2024, dr.dimitru (Dmitry A.; Veliov Group, LLC)
All rights reserved.

Redistribution and use in source and binary forms,
Expand Down
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[![support](https://img.shields.io/badge/support-GitHub-white)](https://github.com/sponsors/dr-dimitru)
[![support](https://img.shields.io/badge/support-PayPal-white)](https://paypal.me/veliovgroup)
<a href="https://ostr.io/info/built-by-developers-for-developers">
<img src="https://ostr.io/apple-touch-icon-60x60.png" height="20">
</a>
<a href="https://ostr.io/info/built-by-developers-for-developers?ref=github-flowrouter-repo-top"><img src="https://ostr.io/apple-touch-icon-60x60.png" height="20"></a>
<a href="https://meteor-files.com/?ref=github-flowrouter-repo-top"><img src="https://meteor-files.com/apple-touch-icon-60x60.png" height="20"></a>

# FlowRouter Extra

Expand All @@ -14,7 +13,7 @@ It exposes a great API for changing the URL and getting data from the URL. Howev

- 📦 Not dependent on Blaze, ready for [__React.js__](https://github.com/veliovgroup/flow-router/blob/master/docs/react.md) and other templating/components engines/libs;
- 📦 No `underscore` package dependency;
- 👨‍💻 TypeScript definition [`types.d.ts`](https://github.com/veliovgroup/flow-router/blob/master/types.d.ts)
- 👨‍💻 TypeScript definition [`index.d.ts`](https://github.com/veliovgroup/flow-router/blob/master/index.d.ts)
- 👨‍🔬 Great [tests coverage](https://github.com/veliovgroup/flow-router/tree/master/test);
- 🥑 Up-to-date [dependencies](https://github.com/veliovgroup/flow-router/blob/master/package.js);
- 📦 Support of [Fast Render](https://github.com/veliovgroup/flow-router/blob/master/docs/fast-render-integration.md) and [other great packages](https://github.com/veliovgroup/flow-router#related-packages);
Expand Down Expand Up @@ -68,6 +67,8 @@ FlowRouter.route('*', {
});
```

> NOTE: If you're using TypeScript, FlowRouter supports it. For types to work you need to install and follow the instructions of [zodern:meteor-types](https://github.com/zodern/meteor-types#meteor-apps) if you haven't done it already.
## Documentation

- Continue with our [wiki](https://github.com/veliovgroup/flow-router/wiki);
Expand Down Expand Up @@ -107,8 +108,16 @@ meteor test-packages ./ --port 8888
MONGO_URL="mongodb://127.0.0.1:27017/flow-router-tests" meteor test-packages ./ --port 8888
```

### Running Typescript Test

1. Install [tsd](https://github.com/SamVerschueren/tsd) as a global package
2. Run ```tsd``` in your terminal. Tsd will find the correct *.test.d.ts file and return with any errors.

## Support this project:

- Upload and share files using [☄️ meteor-files.com](https://meteor-files.com/?ref=github-flowrouter-repo-footer) — Continue interrupted file uploads without losing any progress. There is nothing that will stop Meteor from delivering your file to the desired destination
- Use [▲ ostr.io](https://ostr.io?ref=github-flowrouter-repo-footer) for [Server Monitoring](https://snmp-monitoring.com), [Web Analytics](https://ostr.io/info/web-analytics?ref=github-flowrouter-repo-footer), [WebSec](https://domain-protection.info), [Web-CRON](https://web-cron.info) and [SEO Pre-rendering](https://prerendering.com) of a website
- Star on [GitHub](https://github.com/veliovgroup/flow-router)
- Star on [Atmosphere](https://atmospherejs.com/ostrio/flow-router-extra)
- [Sponsor via GitHub](https://github.com/sponsors/dr-dimitru)
- [Support via PayPal](https://paypal.me/veliovgroup) — support my open source contributions once or on regular basis
- Use [ostr.io](https://ostr.io)[Monitoring](https://snmp-monitoring.com), [Analytics](https://ostr.io/info/web-analytics), [WebSec](https://domain-protection.info), [Web-CRON](https://web-cron.info) and [Pre-rendering](https://prerendering.com) for a website
- [Support via PayPal](https://paypal.me/veliovgroup)
4 changes: 3 additions & 1 deletion client/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ class Router {
if (!path || (!self.env.reload.get() && self._current.path === path)) {
return;
}
original.call(self, path.replace(/\/\/+/g, '/'), state, dispatch, push);
const pathParts = path.split('?');
pathParts[0] = pathParts[0].replace(/\/\/+/g, '/');
original.call(self, pathParts.join('?'), state, dispatch, push);
};
});

Expand Down
27 changes: 18 additions & 9 deletions types.d.ts → index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Meteor } from "meteor/meteor";
import { Mongo } from "meteor/mongo";
import { Tracker } from "meteor/tracker";

type Trigger = (context: ReturnType<Router["current"]>, redirect: Router["go"], stop: () => void, data: any) => void;

type TriggerFilterParam = { only: string[] } | { except: string[] };

type DynamicImport<T extends string> = Promise<typeof import(T)>;
type DynamicImport = Promise<string>;

type Hook = (params: Param, qs: QueryParam) => void;

Expand All @@ -16,8 +20,8 @@ type waitOn = (
| Meteor.SubscriptionHandle
| Tracker.Computation
| Array<Tracker.Computation>
| DynamicImport<string>
| Array<DynamicImport<string> | Meteor.SubscriptionHandle>;
| DynamicImport
| Array<DynamicImport | Meteor.SubscriptionHandle>;

type waitOnResources = (
params: Param,
Expand All @@ -35,10 +39,14 @@ type Param = {
[key: string]: string;
};

type NewParams = {
[key: string]: string | null
};

type QueryParam = Param;

interface Router {
go: (path: string, params?: { [key: string]: string }, qs?: { [key: string]: string }) => boolean;
go: (path: string, params?: NewParams, qs?: NewParams) => boolean;
route: (
path: string,
options?: {
Expand All @@ -56,21 +64,22 @@ interface Router {
[key: string]: any;
}
) => Route;
group: (options: { name: string; prefix: string; [key: string]: any }) => any;
group: (options: { name: string; prefix?: string; [key: string]: any }) => any;
render: (layout: string, template: string, data?: { [key: string]: any }, callback?: () => void) => void;

refresh: (layout: string, template: string) => void;
reload: () => void;
redirect: (path: string) => void;
pathRegExp: RegExp;
decodeQueryParamsOnce: boolean;

getParam: (param: string) => string;
getQueryParam: (param: string) => string;
setParams: (params: Param) => boolean;
setQueryParams: (params: QueryParam) => boolean;
setParams: (params: NewParams) => boolean;
setQueryParams: (params: NewParams) => boolean;

url: (path: string, params?: Param, qs?: QueryParam) => string;
path: (path: string, params?: Param, qs?: QueryParam) => string;
url: (path: string, params?: NewParams, qs?: NewParams) => string;
path: (path: string, params?: NewParams, qs?: NewParams) => string;
current: () => {
context: Context;
oldRoute: Route;
Expand Down
21 changes: 21 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expectError, expectType } from "tsd";
import { FlowRouter } from ".";

FlowRouter.route("/", {
name: "home",
});

FlowRouter.go("/");

expectType<string>(FlowRouter.current().route.name);

FlowRouter.route("/post/:id", {
name: "singlePost",
});
FlowRouter.go("singlePost", { id: "12345" });

// Should return a string even though the paramater is a number
expectType<string>(FlowRouter.getParam("id"));

// Should return an error when a number is given instead of a string
expectError(FlowRouter.go("singlePost", { id: 12345 }));
Loading

0 comments on commit 036db2d

Please sign in to comment.