-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from SuperViz/feat/new-room-package
feat: new room package
- Loading branch information
Showing
34 changed files
with
609 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = false |
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
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
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,21 @@ | ||
const { cjsConfig, esmConfig } = require('./config'); | ||
const esbuild = require('esbuild'); | ||
|
||
(async () => { | ||
try { | ||
await Promise.all([ | ||
esbuild.build({ | ||
...cjsConfig, | ||
outfile: 'dist/index.cjs.js', | ||
}), | ||
|
||
esbuild.build({ | ||
...esmConfig, | ||
outdir: 'dist', | ||
}), | ||
]); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
})(); |
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,53 @@ | ||
require('dotenv').config(); | ||
const { style } = require('./plugins/style-loader'); | ||
|
||
const entries = Object.entries(process.env).filter((key) => key[0].startsWith('SDK_')); | ||
const env = Object.fromEntries(entries); | ||
|
||
const config = { | ||
loader: { | ||
'.png': 'file', | ||
'.svg': 'file', | ||
'.woff': 'file', | ||
'.woff2': 'file', | ||
'.eot': 'file', | ||
'.ttf': 'file', | ||
}, | ||
plugins: [style()], | ||
bundle: true, | ||
color: true, | ||
minify: true, | ||
logLevel: 'info', | ||
sourcemap: true, | ||
chunkNames: 'chunks/[name]-[hash]', | ||
define: { | ||
'process.env': JSON.stringify(env), | ||
}, | ||
}; | ||
|
||
const esmConfig = { | ||
...config, | ||
entryPoints: ['src/index.ts'], | ||
bundle: true, | ||
sourcemap: true, | ||
minify: true, | ||
splitting: true, | ||
target: 'es6', | ||
format: 'esm', | ||
define: { global: 'window', 'process.env': JSON.stringify(env) }, | ||
}; | ||
|
||
const cjsConfig = { | ||
...config, | ||
entryPoints: ['src/index.ts'], | ||
bundle: true, | ||
sourcemap: true, | ||
minify: true, | ||
platform: 'node', | ||
target: ['node16'], | ||
}; | ||
|
||
module.exports = { | ||
esmConfig, | ||
cjsConfig, | ||
}; |
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,60 @@ | ||
const esbuild = require('esbuild'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
style({ minify = true, charset = 'utf8' } = {}) { | ||
return { | ||
name: 'style', | ||
setup({ onResolve, onLoad }) { | ||
const cwd = process.cwd(); | ||
const opt = { logLevel: 'silent', bundle: true, write: false, charset, minify }; | ||
|
||
onResolve({ filter: /\.css$/, namespace: 'file' }, (args) => { | ||
const absPath = path.join(args.resolveDir, args.path); | ||
const relPath = path.relative(cwd, absPath); | ||
const resolved = fs.existsSync(absPath) ? relPath : args.path; | ||
return { path: resolved, namespace: 'style-stub' }; | ||
}); | ||
|
||
onResolve({ filter: /\.css$/, namespace: 'style-stub' }, (args) => { | ||
return { path: args.path, namespace: 'style-content' }; | ||
}); | ||
|
||
onResolve({ filter: /^__style_helper__$/, namespace: 'style-stub' }, (args) => ({ | ||
path: args.path, | ||
namespace: 'style-helper', | ||
sideEffects: false, | ||
})); | ||
|
||
onLoad({ filter: /.*/, namespace: 'style-helper' }, async () => ({ | ||
contents: ` | ||
export function injectStyle(text) { | ||
if (typeof document !== 'undefined') { | ||
const style = document.createElement('style') | ||
style.id = 'superviz-style' | ||
const node = document.createTextNode(text) | ||
style.appendChild(node) | ||
document.head.appendChild(style) | ||
} | ||
} | ||
`, | ||
})); | ||
|
||
onLoad({ filter: /.*/, namespace: 'style-stub' }, async (args) => ({ | ||
contents: ` | ||
import { injectStyle } from "__style_helper__" | ||
import css from ${JSON.stringify(args.path)} | ||
injectStyle(css) | ||
`, | ||
})); | ||
|
||
onLoad({ filter: /.*/, namespace: 'style-content' }, async (args) => { | ||
const options = { entryPoints: [args.path], ...opt }; | ||
const { errors, warnings, outputFiles } = await esbuild.build(options); | ||
return { errors, warnings, contents: outputFiles[0].text, loader: 'text' }; | ||
}); | ||
}, | ||
}; | ||
}, | ||
}; |
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,24 @@ | ||
const { cjsConfig, esmConfig } = require('./config'); | ||
const esbuild = require('esbuild'); | ||
|
||
(async () => { | ||
try { | ||
const [cjsContext, esmContext] = await Promise.all([ | ||
esbuild.context({ | ||
...cjsConfig, | ||
outfile: 'dist/index.cjs.js', | ||
}), | ||
|
||
esbuild.context({ | ||
...esmConfig, | ||
outdir: 'dist', | ||
}), | ||
]); | ||
|
||
cjsContext.watch(); | ||
esmContext.watch(); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
})(); |
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,9 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ["@superviz/eslint-config/library.js"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: "./tsconfig.lint.json", | ||
tsconfigRootDir: __dirname, | ||
}, | ||
}; |
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,8 @@ | ||
module.exports = { | ||
semi: true, | ||
trailingComma: 'all', | ||
arrowParens: 'always', | ||
printWidth: 100, | ||
singleQuote: true, | ||
tabWidth: 2, | ||
}; |
Oops, something went wrong.