nitro-web 0.0.93 → 0.0.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/app.tsx CHANGED
@@ -40,6 +40,10 @@ type RouteWithPolicies = Route & {
40
40
 
41
41
  export async function setupApp(config: Config, storeContainer: StoreContainer, layouts: React.FC<LayoutProps>[]) {
42
42
  if (!layouts) throw new Error('layouts are required')
43
+ if (!(window as unknown as { useTracked: unknown }).useTracked) {
44
+ throw new Error('useTracked is not defined globally before setupApp()')
45
+ }
46
+
43
47
  // Fetch state and init app
44
48
  const settings: Settings = {
45
49
  beforeApp: config.beforeApp || beforeApp,
package/client/globals.ts CHANGED
@@ -1,13 +1,7 @@
1
1
  import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
2
2
  import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'
3
- import { onChange } from 'nitro-web'
4
3
 
5
4
  declare global {
6
- // Common application globals
7
- const onChange: typeof import('nitro-web').onChange
8
-
9
- // Common aependency globals
10
- /** The public API for rendering a history-aware `<a>`. */
11
5
  const Link: typeof import('react-router-dom').Link
12
6
  const useCallback: typeof import('react').useCallback
13
7
  const useEffect: typeof import('react').useEffect
@@ -21,9 +15,6 @@ declare global {
21
15
  }
22
16
 
23
17
  Object.assign(window, {
24
- // application globals
25
- onChange: onChange,
26
- // dependency globals
27
18
  Link: Link,
28
19
  useCallback: useCallback,
29
20
  useEffect: useEffect,
package/client/index.ts CHANGED
@@ -1,11 +1,12 @@
1
- // Required Global Types
2
- import '../types/required-globals.d.ts'
3
-
4
- // export const pi = parseFloat(3.142)
5
- // Utility functions
6
- export * from '../util.js'
7
- export * as util from '../util.js'
8
- export * from '../types'
1
+ // const pi = parseFloat(3.142)
2
+ import '../types/globals.d.ts'
3
+
4
+ // Utility functions (use export path for js declarations to work in host projects)
5
+ export * from 'nitro-web/util'
6
+ export * as util from 'nitro-web/util'
7
+
8
+ // Main types
9
+ export * from 'types'
9
10
 
10
11
  // Main app functions
11
12
  export { setupApp, updateJwt } from './app'
@@ -1,4 +1,4 @@
1
- import { Topbar, Field, FormError, Button, request } from 'nitro-web'
1
+ import { Topbar, Field, FormError, Button, request, onChange } from 'nitro-web'
2
2
  import { Errors } from 'nitro-web/types'
3
3
 
4
4
  export function ResetInstructions() {
@@ -1,4 +1,4 @@
1
- import { Topbar, Field, Button, FormError, request, queryObject, injectedConfig, updateJwt } from 'nitro-web'
1
+ import { Topbar, Field, Button, FormError, request, queryObject, injectedConfig, updateJwt, onChange } from 'nitro-web'
2
2
  import { Errors } from 'nitro-web/types'
3
3
 
4
4
  export function Signin() {
@@ -1,4 +1,4 @@
1
- import { Button, Field, FormError, Topbar, request, injectedConfig } from 'nitro-web'
1
+ import { Button, Field, FormError, Topbar, request, injectedConfig, onChange } from 'nitro-web'
2
2
  import { Errors } from 'nitro-web/types'
3
3
 
4
4
  export function Signup() {
@@ -1,4 +1,3 @@
1
-
2
1
  import { css } from 'twin.macro'
3
2
  import { IsFirstRender } from 'nitro-web'
4
3
 
@@ -2,7 +2,7 @@ import {
2
2
  Drop, Dropdown, Field, Select, Button as ButtonNitro, Checkbox, GithubLink, Modal, Calendar, injectedConfig,
3
3
  Filters, FiltersHandleType, FilterType,
4
4
  } from 'nitro-web'
5
- import { getCountryOptions, getCurrencyOptions, ucFirst } from 'nitro-web/util'
5
+ import { getCountryOptions, getCurrencyOptions, onChange, ucFirst } from 'nitro-web/util'
6
6
  import { Check, FileEditIcon } from 'lucide-react'
7
7
 
8
8
  type StyleguideProps = {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.0.93",
3
+ "version": "0.0.95",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
7
- "main": "./client/index.ts",
8
7
  "type": "module",
8
+ "main": "./client/index.ts",
9
9
  "exports": {
10
10
  ".": "./client/index.ts",
11
11
  "./client/imgs/*": "./client/imgs/*",
package/tsconfig.json CHANGED
@@ -29,10 +29,9 @@
29
29
  "target": "es2022"
30
30
  },
31
31
  "include": [
32
- "client",
32
+ "client", // includes ./globals.ts
33
33
  "components",
34
- "server/constants.js",
35
- "types",
36
- "./types/core-only-globals.d.ts"
34
+ "server",
35
+ "types/core-only-globals.d.ts"
37
36
  ]
38
37
  }
@@ -1,8 +1,8 @@
1
1
  import { Store } from 'nitro-web/types'
2
2
  import { Dispatch, SetStateAction } from 'react'
3
3
 
4
- // Core-only global, this global will be defined globally in the project (e.g. in ./client/index.ts)
5
- declare global {
4
+ declare global {
5
+ // useTracked global (normally defined in your project's /client/index.ts)
6
6
  const useTracked: () => [Store, Dispatch<SetStateAction<Store>>]
7
7
  }
8
8
 
@@ -1,24 +1,33 @@
1
- // Required global types
2
1
  import 'twin.macro'
3
2
  import { css as cssImport } from '@emotion/react'
4
3
  import styledImport from '@emotion/styled'
5
4
  import { CSSInterpolation } from '@emotion/serialize'
5
+ import 'axios'
6
+ import type { IAxiosRetry } from 'axios-retry'
6
7
 
7
8
  declare global {
8
9
  /** Webpack injected config variables */
9
10
  const INJECTED_CONFIG: Record<string, string|boolean|object>
10
11
  /** Webpack svg loader */
11
- module '*.svg' {
12
+ declare module '*.svg' {
12
13
  const content: React.FC<React.SVGProps<SVGElement>>
13
14
  export default content
14
15
  }
16
+
15
17
  /** Webpack image loader */
16
- module '*.jpg' {
18
+ declare module '*.jpg' {
17
19
  const content: string
18
20
  export default content
19
21
  }
20
22
  }
21
23
 
24
+ // Webpack: axios-retry augment (since axios-retry is not imported in host project)
25
+ declare module 'axios' {
26
+ export interface AxiosRequestConfig {
27
+ 'axios-retry'?: IAxiosRetry.IAxiosRetryConfigExtended
28
+ }
29
+ }
30
+
22
31
  // Webpack: Twin.macro css extension
23
32
  // https://github.com/ben-rogerson/twin.examples/tree/master/react-emotion-typescript
24
33
  declare module 'twin.macro' {
@@ -37,3 +46,5 @@ declare module 'react' {
37
46
  for?: string | undefined
38
47
  }
39
48
  }
49
+
50
+ export {}