-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
2,828 additions
and
25,633 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 was deleted.
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
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 |
---|---|---|
@@ -1,93 +1,97 @@ | ||
// import { createFilter } from '@rollup/pluginutils'; | ||
|
||
// import { collectStyles, replaceStyleTemplates } from './utils/loaders'; | ||
|
||
// function astroturf({ include, exclude, ...rest } = {}) { | ||
// const filter = createFilter(include || /\.(jsx?|tsx?)/i, exclude); | ||
// const cssLookup = new Map(); | ||
// const pathMap = new Map(); | ||
// const sourceMetadata = new Map(); | ||
|
||
// function transform(content, filename) { | ||
// const metadata = collectStyles(content, filename, undefined, rest); | ||
|
||
// const { code, map } = replaceStyleTemplates( | ||
// filename, | ||
// content, | ||
// metadata.changeset, | ||
// true, | ||
// ); | ||
|
||
// sourceMetadata.set(filename, metadata); | ||
|
||
// metadata.styles.forEach(({ absoluteFilePath, requirePath, value }) => { | ||
// cssLookup.set(absoluteFilePath, value); | ||
// pathMap.set(requirePath, absoluteFilePath); | ||
// }); | ||
|
||
// return { | ||
// code, | ||
// map, | ||
// styles: metadata.styles, | ||
// }; | ||
// } | ||
|
||
// return { | ||
// name: 'astroturf', | ||
|
||
// load(id) { | ||
// return cssLookup.get(id) || cssLookup.get(process.cwd() + id); | ||
// }, | ||
|
||
// resolveId(importee) { | ||
// importee = importee.split('?')[0]; | ||
// const id = cssLookup.get(importee) || pathMap.get(importee); | ||
// return id; | ||
// }, | ||
|
||
// async handleHotUpdate(hmr) { | ||
// if (!filter(hmr.file)) return undefined; | ||
|
||
// // console.log("ff", hmr, hmr.modules); | ||
// const prev = sourceMetadata.get(hmr.file); | ||
|
||
// if (!prev) return undefined; | ||
|
||
// const module = hmr.modules.find((m) => m.file === hmr.file); | ||
// const affectedModules = new Set(hmr.modules); | ||
|
||
// const content = await hmr.read(); | ||
// const { styles } = transform(content, hmr.file); | ||
|
||
// try { | ||
// module.importedModules?.forEach((m) => { | ||
// if ( | ||
// styles.find( | ||
// (s) => | ||
// s.absoluteFilePath === m.file || | ||
// s.absoluteFilePath === process.cwd() + m.file, | ||
// ) | ||
// ) { | ||
// affectedModules.add(m); | ||
// } | ||
// }); | ||
// } catch (err) { | ||
// console.log(err); | ||
// } | ||
|
||
// return [...affectedModules]; | ||
// }, | ||
|
||
// transform(content, id) { | ||
// if (!filter(id) || !content.includes('astroturf')) { | ||
// return undefined; | ||
// } | ||
|
||
// const { code, map } = transform(content, id); | ||
|
||
// return { code, map }; | ||
// }, | ||
// }; | ||
// } | ||
|
||
// export default astroturf; | ||
import { collectStyles, replaceStyleTemplates } from './utils/loaders'; | ||
|
||
function astroturf({ ...rest }: any = {}) { | ||
// const filter = createFilter(include || /\.(jsx?|tsx?)/i, exclude); | ||
const cssLookup = new Map(); | ||
const pathMap = new Map(); | ||
const sourceMetadata = new Map(); | ||
|
||
function filter(file) { | ||
return !!file.match(/\.(jsx?|tsx?)/i); | ||
} | ||
|
||
function transform(content, filename) { | ||
const metadata = collectStyles(content, filename, undefined as any, rest); | ||
|
||
const { code, map } = replaceStyleTemplates( | ||
filename, | ||
content, | ||
metadata.changeset, | ||
true, | ||
); | ||
|
||
sourceMetadata.set(filename, metadata); | ||
|
||
metadata.styles.forEach(({ absoluteFilePath, requirePath, value }) => { | ||
cssLookup.set(absoluteFilePath, value); | ||
pathMap.set(requirePath, absoluteFilePath); | ||
}); | ||
|
||
return { | ||
code, | ||
map, | ||
styles: metadata.styles, | ||
}; | ||
} | ||
|
||
return { | ||
name: 'astroturf', | ||
|
||
load(id) { | ||
return cssLookup.get(id) || cssLookup.get(process.cwd() + id); | ||
}, | ||
|
||
resolveId(importee) { | ||
importee = importee.split('?')[0]; | ||
const id = cssLookup.get(importee) || pathMap.get(importee); | ||
return id; | ||
}, | ||
|
||
async handleHotUpdate(hmr) { | ||
if (!filter(hmr.file)) return undefined; | ||
|
||
// console.log("ff", hmr, hmr.modules); | ||
const prev = sourceMetadata.get(hmr.file); | ||
|
||
if (!prev) return undefined; | ||
|
||
const module = hmr.modules.find((m) => m.file === hmr.file); | ||
const affectedModules = new Set(hmr.modules); | ||
|
||
const content = await hmr.read(); | ||
const { styles } = transform(content, hmr.file); | ||
|
||
try { | ||
module.importedModules?.forEach((m) => { | ||
if ( | ||
styles.find( | ||
(s) => | ||
s.absoluteFilePath === m.file || | ||
s.absoluteFilePath === process.cwd() + m.file, | ||
) | ||
) { | ||
affectedModules.add(m); | ||
} | ||
}); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
|
||
return [...affectedModules]; | ||
}, | ||
|
||
transform(content, id) { | ||
if (!filter(id) || !content.includes('astroturf')) { | ||
return undefined; | ||
} | ||
|
||
const { code, map } = transform(content, id); | ||
|
||
return { code, map }; | ||
}, | ||
}; | ||
} | ||
|
||
export default astroturf; |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
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,36 @@ | ||
#!/usr/bin/env sh | ||
|
||
# abort on errors | ||
set -e | ||
|
||
# build | ||
yarn run build | ||
|
||
# navigate into the build output directory | ||
cd dist | ||
|
||
# place .nojekyll to bypass Jekyll processing | ||
echo > .nojekyll | ||
|
||
mkdir -p introduction && cp -R index.html "$_" | ||
mkdir -p advanced && cp -R index.html "$_" | ||
mkdir -p tooling && cp -R index.html "$_" | ||
mkdir -p cross-file-dependencies && cp -R index.html "$_" | ||
mkdir -p setup && cp -R index.html "$_" | ||
|
||
|
||
# if you are deploying to a custom domain | ||
# echo 'www.example.com' > CNAME | ||
|
||
git init | ||
git checkout -B main | ||
git add -A | ||
git commit -m 'deploy' | ||
|
||
# if you are deploying to https://<USERNAME>.github.io | ||
# git push -f [email protected]:<USERNAME>/<USERNAME>.github.io.git main | ||
|
||
# if you are deploying to https://<USERNAME>.github.io/<REPO> | ||
git push -f [email protected]:4Catalyzer/astroturf.git main:gh-pages | ||
|
||
cd - |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.