Skip to content

Commit

Permalink
Merge pull request #172 from SuperViz/feat/new-room-package
Browse files Browse the repository at this point in the history
feat: new room package
  • Loading branch information
carlossantos74 authored Dec 11, 2024
2 parents e44b9e0 + 49b3a6e commit 94c5fd2
Show file tree
Hide file tree
Showing 34 changed files with 609 additions and 68 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
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
3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
interval: "monthly"
target-branch: "lab"
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
needs: build
strategy:
matrix:
package: [realtime, sdk, yjs]
package: [realtime, sdk, yjs, 'room']
steps:
- name: Install pnpm
uses: pnpm/action-setup@v4
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/publish-packages.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Check for changes in packages/socket-client
id: check_socket_client_changes
run: |
git diff --quiet HEAD^ HEAD packages/socket-client || echo "socket_client_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/socket-client -- . ':(exclude)package.json' || echo "socket_client_changed=true" >> $GITHUB_OUTPUT
- name: Publish Socket Client package
if: steps.check_socket_client_changes.outputs.socket_client_changed == 'true'
run: npm whoami && pnpm run semantic-release --filter=@superviz/socket-client
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Check for changes in packages/realtime
id: check_realtime_changes
run: |
git diff --quiet HEAD^ HEAD packages/realtime || echo "realtime_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/realtime -- . ':(exclude)package.json' || echo "realtime_changed=true" >> $GITHUB_OUTPUT
- name: Publish realtime package
if: steps.check_realtime_changes.outputs.realtime_changed == 'true'
run: npm whoami && pnpm run semantic-release --filter=@superviz/realtime
Expand All @@ -62,7 +62,7 @@ jobs:
- name: Check for changes in packages/sdk
id: check_sdk_changes
run: |
git diff --quiet HEAD^ HEAD packages/sdk || echo "sdk_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/sdk -- . ':(exclude)package.json' || echo "sdk_changed=true" >> $GITHUB_OUTPUT
- name: Publish SDK package
if: steps.check_sdk_changes.outputs.sdk_changed == 'true'
run: npm whoami && pnpm run semantic-release --filter=@superviz/sdk
Expand All @@ -73,7 +73,7 @@ jobs:
- name: Check for changes in packages/yjs
id: check_yjs_changes
run: |
git diff --quiet HEAD^ HEAD packages/yjs || echo "yjs_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/yjs -- . ':(exclude)package.json' || echo "yjs_changed=true" >> $GITHUB_OUTPUT
- name: Publish YJS package
if: steps.check_yjs_changes.outputs.yjs_changed == 'true'
run: npm whoami && pnpm run semantic-release --filter=@superviz/yjs
Expand All @@ -84,7 +84,7 @@ jobs:
- name: Check for changes in packages/autodesk
id: check_autodesk_changes
run: |
git diff --quiet HEAD^ HEAD packages/autodesk || echo "autodesk_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/autodesk -- . ':(exclude)package.json' || echo "autodesk_changed=true" >> $GITHUB_OUTPUT
- name: Publish Autodesk package
if: steps.check_autodesk_changes.outputs.autodesk_changed == 'true'
run: npm whoami && pnpm run semantic-release --filter=@superviz/autodesk-viewer-plugin
Expand All @@ -95,7 +95,7 @@ jobs:
- name: Check for changes in packages/matterport
id: check_matterport_changes
run: |
git diff --quiet HEAD^ HEAD packages/matterport || echo "matterport_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/matterport -- . ':(exclude)package.json' || echo "matterport_changed=true" >> $GITHUB_OUTPUT
- name: Publish matterport package
if: steps.check_matterport_changes.outputs.matterport_changed == 'true'
run: npm whoami && pnpm run semantic-release --filter=@superviz/matterport-plugin
Expand All @@ -106,7 +106,7 @@ jobs:
- name: Check for changes in packages/three
id: check_three_changes
run: |
git diff --quiet HEAD^ HEAD packages/three || echo "three_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/three -- . ':(exclude)package.json' || echo "three_changed=true" >> $GITHUB_OUTPUT
- name: Publish three package
if: steps.check_three_changes.outputs.three_changed == 'true'
run: npm whoami && pnpm run semantic-release --filter=@superviz/threejs-plugin
Expand All @@ -117,12 +117,12 @@ jobs:
- name: Check for changes in React SDK and dependencies
id: check_react_and_dependencies_changes
run: |
git diff --quiet HEAD^ HEAD packages/react || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/sdk || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/autodesk || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/matterport || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/three || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/yjs || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/react -- . ':(exclude)package.json' || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/sdk -- . ':(exclude)package.json' || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/autodesk -- . ':(exclude)package.json' || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/matterport -- . ':(exclude)package.json' || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/three -- . ':(exclude)package.json' || echo "react_changed=true" >> $GITHUB_OUTPUT
git diff --quiet HEAD^ HEAD packages/yjs -- . ':(exclude)package.json' || echo "react_changed=true" >> $GITHUB_OUTPUT
- name: Publish react package
if: steps.check_react_and_dependencies_changes.outputs.react_changed == 'true'
run: npm whoami && pnpm run semantic-release --filter=@superviz/react-sdk
Expand Down
4 changes: 2 additions & 2 deletions apps/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@superviz/threejs-plugin": "workspace:*",
"@superviz/yjs": "workspace:*",
"@types/three": "^0.167.1",
"lib0": "^0.2.97",
"lib0": "^0.2.98",
"lodash": "^4.17.21",
"monaco-editor": "^0.51.0",
"quill-cursors": "^4.0.3",
Expand All @@ -31,7 +31,7 @@
"reactflow": "^11.11.4",
"three": "0.167.1",
"three-mesh-bvh": "^0.7.8",
"uuid": "^10.0.0",
"uuid": "^11.0.3",
"y-monaco": "^0.1.6",
"y-protocols": "^1.0.6",
"y-quill": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo lint",
"watch": "turbo run watch",
"watch": "turbo run watch --concurrency=11",
"semantic-release": "turbo run semantic-release",
"test:unit": "turbo run test:unit",
"test:unit:watch": "turbo run test:unit:watch",
Expand Down
4 changes: 2 additions & 2 deletions packages/autodesk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superviz/autodesk-viewer-plugin",
"version": "1.22.5-lab.1",
"version": "1.22.5",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -41,7 +41,7 @@
"@types/forge-viewer": "^7.89.1",
"@types/lodash": "^4.17.6",
"concurrently": "^8.2.2",
"dotenv": "^16.4.5",
"dotenv": "^16.4.7",
"esbuild": "^0.22.0",
"eslint": "8.56.0",
"semantic-release": "24.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/matterport/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superviz/matterport-plugin",
"version": "1.2.5-lab.1",
"version": "1.2.5",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -39,7 +39,7 @@
"@types/debug": "^4.1.12",
"@types/lodash": "^4.17.5",
"concurrently": "^8.2.2",
"dotenv": "^16.4.5",
"dotenv": "^16.4.7",
"esbuild": "^0.21.5",
"eslint": "8.56.0",
"husky": "^9.0.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@superviz/react-sdk",
"private": false,
"version": "1.14.5-lab.2",
"version": "1.14.5",
"type": "module",
"scripts": {
"watch": "./node_modules/typescript/bin/tsc && vite build --watch",
Expand Down
2 changes: 1 addition & 1 deletion packages/realtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superviz/realtime",
"version": "1.2.5-lab.1",
"version": "1.2.5",
"description": "SuperViz Real-Time",
"main": "./dist/node/index.cjs.js",
"module": "./dist/browser/index.js",
Expand Down
21 changes: 21 additions & 0 deletions packages/room/.esbuild/build.js
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);
}
})();
53 changes: 53 additions & 0 deletions packages/room/.esbuild/config.js
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,
};
60 changes: 60 additions & 0 deletions packages/room/.esbuild/plugins/style-loader.js
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' };
});
},
};
},
};
24 changes: 24 additions & 0 deletions packages/room/.esbuild/watch.js
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);
}
})();
9 changes: 9 additions & 0 deletions packages/room/.eslintrc.js
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,
},
};
8 changes: 8 additions & 0 deletions packages/room/.prettierrc.js
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,
};
Loading

0 comments on commit 94c5fd2

Please sign in to comment.