Skip to content
Merged

Next #301

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nullstack",
"version": "0.17.1",
"description": "Full-stack Javascript Components for one-dev armies",
"version": "0.17.2",
"description": "Full Stack Javascript Components for one-dev armies",
"main": "nullstack.js",
"author": "Mortaro",
"repository": "github:nullstack/nullstack",
Expand Down Expand Up @@ -32,7 +32,7 @@
"css-loader": "6.7.1",
"dotenv": "8.6.0",
"eslint-plugin-jest": "^27.1.6",
"eslint-plugin-nullstack": "^0.0.10",
"eslint-plugin-nullstack": "^0.0.11",
"express": "4.18.1",
"fs-extra": "10.1.0",
"mini-css-extract-plugin": "2.6.0",
Expand Down
Binary file added tests/public/icon-144x000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/src/ContextProject.njs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ContextProject extends Nullstack {
project.orientation = 'portrait'
project.scope = '/'
project.root = '/'
project.folderIcons = project.icons
project.icons = {
72: '/icon-72x72.png',
144: '/icon-144x144.png',
Expand All @@ -21,6 +22,7 @@ class ContextProject extends Nullstack {
}

render({ project }) {
const ignoredUnmatchedIcon = !Object.keys(project.folderIcons).find((key) => /icon-(\d+)x\1\.[a-zA-Z]+/.test(key))
return (
<div>
<div data-project={!!project} />
Expand All @@ -41,6 +43,7 @@ class ContextProject extends Nullstack {
<div data-disallow-admin={project.disallow[0]} />
<div data-sitemap={project.sitemap} />
<div data-viewport={project.viewport} />
<div data-ignored-unmatched-icon={ignoredUnmatchedIcon} />
</div>
)
}
Expand Down
5 changes: 5 additions & 0 deletions tests/src/ContextProject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ describe('ContextProject', () => {
expect(element).toBeTruthy()
})

test('icons that do not match the pattern are not loaded into icon key', async () => {
const element = await page.$('[data-ignored-unmatched-icon]')
expect(element).toBeTruthy()
})

test('icons accepts an object with sizes', async () => {
const element = await page.$('[data-icon-72="/icon-72x72.png"]')
expect(element).toBeTruthy()
Expand Down
3 changes: 1 addition & 2 deletions tests/src/TypeScript.nts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Nullstack from 'nullstack'
import { NullstackClientContext } from 'nullstack/types/index.d.ts'
import Nullstack, { NullstackClientContext } from 'nullstack'

interface TypeScriptClientContext extends NullstackClientContext {
value: number;
Expand Down
16 changes: 8 additions & 8 deletions types/ClientContext.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NullstackEnvironment } from './Environment.d.ts'
import { NullstackNode } from './JSX.d.ts'
import { NullstackPage } from './Page.d.ts'
import { NullstackParams } from './Params.d.ts'
import { NullstackProject } from './Project.d.ts'
import { NullstackRouter } from './Router.d.ts'
import { NullstackSettings } from './Settings.d.ts'
import { NullstackWorker } from './Worker.d.ts'
import { NullstackEnvironment } from './Environment'
import { NullstackNode } from './JSX'
import { NullstackPage } from './Page'
import { NullstackParams } from './Params'
import { NullstackProject } from './Project'
import { NullstackRouter } from './Router'
import { NullstackSettings } from './Settings'
import { NullstackWorker } from './Worker'

/**
* @see https://nullstack.app/context
Expand Down
2 changes: 1 addition & 1 deletion types/JSX.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// Guilherme Correia <https://github.com/GuiDevloper>
// TypeScript Version: 2.8

import { NullstackClientContext } from './ClientContext.d.ts'
import { NullstackClientContext } from './ClientContext'

type NativeDragEvent = globalThis.DragEvent
type NativeFocusEvent = globalThis.FocusEvent
Expand Down
4 changes: 2 additions & 2 deletions types/Plugin.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NullstackClientContext } from './ClientContext.d.ts'
import { AllHTMLAttributes, NullstackAttributes } from './JSX.d.ts'
import { NullstackClientContext } from './ClientContext'
import { AllHTMLAttributes, NullstackAttributes } from './JSX'

type NullstackPluginNode = {
type: string | boolean
Expand Down
12 changes: 6 additions & 6 deletions types/ServerContext.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { NullstackEnvironment } from './Environment.d.ts'
import { NullstackProject } from './Project.d.ts'
import { NullstackSecrets } from './Secrets.d.ts'
import { NullstackServer } from './Server.d.ts'
import { NullstackSettings } from './Settings.d.ts'
import { NullstackWorker } from './Worker.d.ts'
import { NullstackEnvironment } from './Environment'
import { NullstackProject } from './Project'
import { NullstackSecrets } from './Secrets'
import { NullstackServer } from './Server'
import { NullstackSettings } from './Settings'
import { NullstackWorker } from './Worker'

/**
* @see https://nullstack.app/context
Expand Down
36 changes: 18 additions & 18 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { NullstackClientContext } from './ClientContext.d.ts'
import { NullstackNode } from './JSX.d.ts'
import { NullstackPlugin } from './Plugin.d.ts'
import { NullstackServerContext } from './ServerContext.d.ts'

export * from './ClientContext.d.ts'
export * from './Environment.d.ts'
export * from './Page.d.ts'
export * from './Params.d.ts'
export * from './Plugin.d.ts'
export * from './Project.d.ts'
export * from './Router.d.ts'
export * from './Secrets.d.ts'
export * from './Server.d.ts'
export * from './ServerContext.d.ts'
export * from './Settings.d.ts'
export * from './Worker.d.ts'
export * from './JSX.d.ts'
import { NullstackClientContext } from './ClientContext'
import { NullstackNode } from './JSX'
import { NullstackPlugin } from './Plugin'
import { NullstackServerContext } from './ServerContext'

export * from './ClientContext'
export * from './Environment'
export * from './Page'
export * from './Params'
export * from './Plugin'
export * from './Project'
export * from './Router'
export * from './Secrets'
export * from './Server'
export * from './ServerContext'
export * from './Settings'
export * from './Worker'
export * from './JSX'

/**
* Functional component
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ function server(env, argv) {
const icons = {}
const publicFiles = readdirSync(path.join(dir, 'public'))
const babel = argv.loader === 'babel'
const iconFileRegex = /icon-(\d+)x\1\.[a-zA-Z]+/
for (const file of publicFiles) {
if (file.startsWith('icon-')) {
if (iconFileRegex.test(file)) {
const size = file.split('x')[1].split('.')[0]
icons[size] = `/${file}`
}
Expand Down