-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support async globalScripts functions
fixes #3392 STENCIL-467
- Loading branch information
1 parent
61d797b
commit 7a5e48c
Showing
16 changed files
with
172 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/** | ||
* hello world! | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf8"> | ||
<script src="./build/testglobalscript.esm.js" type="module"></script> | ||
<script src="./build/testglobalscript.js" nomodule></script> | ||
|
||
<test-cmp></test-cmp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { setupDomTests } from '../util'; | ||
|
||
describe('global script', () => { | ||
const env = setupDomTests(document); | ||
|
||
afterEach(() => { | ||
env?.tearDownDom(); | ||
}); | ||
|
||
it('supports async execution', async () => { | ||
await env?.setupDom('/global-script/index.html'); | ||
|
||
const cmp = document.querySelector('test-cmp') | ||
expect(cmp).not.toBeNull(); | ||
expect(typeof cmp?.textContent).toBe('string'); | ||
|
||
const renderedDelay = parseInt(cmp?.textContent?.slice('I am rendered after '.length)!) | ||
expect(renderedDelay).toBeGreaterThanOrEqual(1000); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "global-script", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.js", | ||
"collection": "dist/collection/collection-manifest.json", | ||
"types": "dist/types/components.d.ts", | ||
"volta": { | ||
"extends": "../package.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-disable */ | ||
/* tslint:disable */ | ||
/** | ||
* This is an autogenerated file created by the Stencil compiler. | ||
* It contains typing information for all components that exist in this project. | ||
*/ | ||
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal"; | ||
export namespace Components { | ||
interface TestCmp { | ||
} | ||
} | ||
declare global { | ||
interface HTMLTestCmpElement extends Components.TestCmp, HTMLStencilElement { | ||
} | ||
var HTMLTestCmpElement: { | ||
prototype: HTMLTestCmpElement; | ||
new (): HTMLTestCmpElement; | ||
}; | ||
interface HTMLElementTagNameMap { | ||
"test-cmp": HTMLTestCmpElement; | ||
} | ||
} | ||
declare namespace LocalJSX { | ||
interface TestCmp { | ||
} | ||
interface IntrinsicElements { | ||
"test-cmp": TestCmp; | ||
} | ||
} | ||
export { LocalJSX as JSX }; | ||
declare module "@stencil/core" { | ||
export namespace JSX { | ||
interface IntrinsicElements { | ||
"test-cmp": LocalJSX.TestCmp & JSXBase.HTMLAttributes<HTMLTestCmpElement>; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
declare global { | ||
interface Window { | ||
__testStart: number; | ||
} | ||
} | ||
|
||
export default async function () { | ||
window.__testStart = Date.now(); | ||
return new Promise((resolve) => setTimeout(() => resolve('done!'), 1000)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Component, h } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'test-cmp', | ||
scoped: true, | ||
}) | ||
export class SiblingRoot { | ||
render() { | ||
return ( | ||
<div>I am rendered after {Date.now() - window.__testStart}</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Config } from '../../../dist/declarations'; | ||
const { WWW_OUT_DIR } = require('../constants'); | ||
|
||
export const config: Config = { | ||
namespace: 'TestGlobalScript', | ||
tsconfig: 'tsconfig.json', | ||
outputTargets: [ | ||
{ | ||
type: 'www', | ||
dir: `../${WWW_OUT_DIR}`, | ||
}, | ||
], | ||
globalScript: 'src/global.ts', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"compilerOptions": { | ||
"alwaysStrict": true, | ||
"allowSyntheticDefaultImports": true, | ||
"allowUnreachableCode": true, | ||
"declaration": false, | ||
"resolveJsonModule": true, | ||
"experimentalDecorators": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"jsx": "react", | ||
"jsxFactory": "h", | ||
"lib": [ | ||
"dom", | ||
"es2017" | ||
], | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"noImplicitAny": false, | ||
"noImplicitReturns": false, | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"pretty": true, | ||
"target": "es2017", | ||
"useUnknownInCatchVariables": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"@stencil/core": ["../../../internal"], | ||
"@stencil/core/internal": ["../../../internal"], | ||
"@stencil/core/testing": ["../../../testing"] | ||
} | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
], | ||
"exclude": [ | ||
"test-prerender", | ||
"test-sibling" | ||
"test-sibling", | ||
"test-global-script" | ||
] | ||
} |