Skip to content

Commit

Permalink
Merge branch 'main' of github.com:openpatch/hyperbook
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebarkmin committed Feb 23, 2024
2 parents bcf4811 + 3ddfcdf commit d8e07d3
Show file tree
Hide file tree
Showing 27 changed files with 378 additions and 166 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-dingos-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperbook/element-video": patch
---

Fix not using baseUrl
7 changes: 7 additions & 0 deletions packages/element-video/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @hyperbook/element-video

## 0.2.0

### Minor Changes

- [#847](https://github.com/openpatch/hyperbook/pull/847) [`0b893a3`](https://github.com/openpatch/hyperbook/commit/0b893a39ba9f5e3fffa40fc3ce115bd379f43313) Thanks [@elielmartinsbr](https://github.com/elielmartinsbr)! - add video element
9 changes: 9 additions & 0 deletions packages/element-video/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @hyperbook/element-video

## Installation

```sh
yarn add @hyperbook/element-video
# or
npm i @hyperbook/element-video
```
54 changes: 54 additions & 0 deletions packages/element-video/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@hyperbook/element-video",
"version": "0.2.0",
"author": "Eliel Martins",
"homepage": "https://github.com/openpatch/hyperbook#readme",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"exports": {
".": "./dist/index.js",
"./index.css": "./dist/index.css"
},
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/openpatch/hyperbook.git",
"directory": "packages/element-video"
},
"bugs": {
"url": "https://github.com/openpatch/hyperbook/issues"
},
"scripts": {
"version": "pnpm build",
"lint": "tsc --noEmit",
"build": "rimraf dist && pnpm build:pkg && pnpm build:types",
"build:pkg": "node ../../scripts/build.mjs",
"build:types": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly"
},
"dependencies": {
"@hyperbook/provider": "workspace:*",
"@hyperbook/store": "workspace:*",
"@types/wavesurfer.js": "^6.0.6",
"wavesurfer.js": "^6.6.4"
},
"peerDependencies": {
"react": "18.x",
"react-dom": "18.x",
"react-redux": "8.x"
},
"devDependencies": {
"@types/react": "18.0.15",
"@types/react-dom": "18.0.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"vitest": "^0.26.3"
}
}
26 changes: 26 additions & 0 deletions packages/element-video/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.element-video {
margin-bottom: 16px;
}

.element-video .information {
margin-top: 4px;
text-align: center;
font-style: italic;
}

.element-video .description {
margin-top: 10px;
text-align: center;
}

.element-video .player {
display: flex;
overflow: hidden;
align-items: center;
justify-content: center;
background-color: var(--color-nav);
border-radius: 8px;
border-style: solid;
border-width: 1px;
border-color: var(--color-nav-border);
}
52 changes: 52 additions & 0 deletions packages/element-video/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { FC } from "react";
import { createSlice } from "@hyperbook/store";
import { useMakeUrl } from "@hyperbook/provider";
import "./index.css";

type DirectiveVideoProps = {
src: string;
title?: string;
author?: string;
poster?: string;
};

const DirectiveVideo: FC<DirectiveVideoProps> = ({
src,
title,
author,
poster,
}) => {
const makeUrl = useMakeUrl();
src = makeUrl(src, "public");
poster = makeUrl(poster, "public");

return (
<div className="element-video">
<div className="player">
<video controls src={src} poster={poster} width="100%">
Your browser does not support videos.
</video>
</div>
<div className="information">
{title && <span className="title">{title}</span>}{" "}
{title && author && <span className="spacer">-</span>}{" "}
{author && <span className="author">{author}</span>}{" "}
</div>
</div>
);
};

type ElementVideoState = {};

const initialState: ElementVideoState = {};

const sliceVideo = createSlice({
name: "element.video",
initialState,
reducers: {},
});

export default {
directives: { video: DirectiveVideo },
slice: sliceVideo,
};
8 changes: 8 additions & 0 deletions packages/element-video/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"include": ["src", "../../types"],
"compilerOptions": {
"rootDir": "src",
"declarationDir": "dist"
}
}
4 changes: 4 additions & 0 deletions packages/element-video/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src", "../../types", "tests"]
}
3 changes: 3 additions & 0 deletions packages/element-video/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineConfig } from "vitest/config";

export default defineConfig({});
20 changes: 4 additions & 16 deletions packages/fs/tests/__snapshots__/vfile.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ exports[`list > should get references 1`] = `
},
"name": "paradigms",
"path": {
"absolute": "/var/home/mbarkmin/Sources/openpatch/hyperbook/main/packages/fs/tests/fixtures/single-hyperbook/book/paradigms.md",
"absolute": "single-hyperbook/book/paradigms.md",
"directory": "",
"href": "/paradigms",
"relative": "paradigms.md",
},
"root": "/var/home/mbarkmin/Sources/openpatch/hyperbook/main/packages/fs/tests/fixtures/single-hyperbook",
"root": "single-hyperbook",
},
],
"root": "single-hyperbook",
Expand All @@ -142,18 +142,6 @@ exports[`list > should get references 1`] = `

exports[`list > should list all 1`] = `
[
{
"extension": ".zip",
"folder": "archives",
"name": "archive-1",
"path": {
"absolute": "single-hyperbook/archives/archive-1",
"directory": "",
"href": "/archives/archive-1.zip",
"relative": "archive-1",
},
"root": "single-hyperbook",
},
{
"extension": ".md",
"folder": "glossary",
Expand Down Expand Up @@ -184,12 +172,12 @@ exports[`list > should list all 1`] = `
},
"name": "paradigms",
"path": {
"absolute": "/var/home/mbarkmin/Sources/openpatch/hyperbook/main/packages/fs/tests/fixtures/single-hyperbook/book/paradigms.md",
"absolute": "single-hyperbook/book/paradigms.md",
"directory": "",
"href": "/paradigms",
"relative": "paradigms.md",
},
"root": "/var/home/mbarkmin/Sources/openpatch/hyperbook/main/packages/fs/tests/fixtures/single-hyperbook",
"root": "single-hyperbook",
},
],
"root": "single-hyperbook",
Expand Down
43 changes: 23 additions & 20 deletions packages/fs/tests/vfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,35 @@ describe("list", () => {
let hyperbookPath = path.join(__dirname, "fixtures", "single-hyperbook");
vfile.clean(hyperbookPath);

it("should list all", async () => {
const files = await vfile.list(hyperbookPath);
expect(
files.map((f) => ({
const makeFileRelative = (f: vfile.VFile) => {
if ("references" in f) {
return {
...f,
root: relative(f.root),
path: { ...f.path, absolute: relative(f.path.absolute) },
}))
).toMatchSnapshot();
references: f.references.map((f) => ({
...f,
root: relative(f.root),
path: { ...f.path, absolute: relative(f.path.absolute) },
})),
} as vfile.VFileGlossary;
}
return {
...f,
root: relative(f.root),
path: { ...f.path, absolute: relative(f.path.absolute) },
};
};

it("should list all", async () => {
const files = await vfile.list(hyperbookPath);
const relativeFiles = files.map(makeFileRelative);
expect(relativeFiles).toMatchSnapshot();
});

it("should list for folder book", async () => {
const files = await vfile.listForFolder(hyperbookPath, "book");
expect(
files.map((f) => ({
...f,
root: relative(f.root),
path: { ...f.path, absolute: relative(f.path.absolute) },
}))
).toMatchSnapshot();
expect(files.map(makeFileRelative)).toMatchSnapshot();
});

it("should include main index", async () => {
Expand All @@ -38,13 +47,7 @@ describe("list", () => {

it("should get references", async () => {
const files = await vfile.listForFolder(hyperbookPath, "glossary");
expect(
files.map((f) => ({
...f,
root: relative(f.root),
path: { ...f.path, absolute: relative(f.path.absolute) },
}))
).toMatchSnapshot();
expect(files.map(makeFileRelative)).toMatchSnapshot();
});
});

Expand Down
6 changes: 6 additions & 0 deletions packages/hyperbook/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# hyperbook

## 0.28.0

### Minor Changes

- [#847](https://github.com/openpatch/hyperbook/pull/847) [`0b893a3`](https://github.com/openpatch/hyperbook/commit/0b893a39ba9f5e3fffa40fc3ce115bd379f43313) Thanks [@elielmartinsbr](https://github.com/elielmartinsbr)! - add video element

## 0.27.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/hyperbook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hyperbook",
"version": "0.27.1",
"version": "0.28.0",
"author": "Mike Barkmin",
"homepage": "https://github.com/openpatch/hyperbook#readme",
"license": "MIT",
Expand Down
11 changes: 11 additions & 0 deletions platforms/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @hyperbook/vscode-extension

## 0.21.0

### Minor Changes

- [#847](https://github.com/openpatch/hyperbook/pull/847) [`0b893a3`](https://github.com/openpatch/hyperbook/commit/0b893a39ba9f5e3fffa40fc3ce115bd379f43313) Thanks [@elielmartinsbr](https://github.com/elielmartinsbr)! - add video element

### Patch Changes

- Updated dependencies [[`0b893a3`](https://github.com/openpatch/hyperbook/commit/0b893a39ba9f5e3fffa40fc3ce115bd379f43313)]:
- @hyperbook/element-video@0.2.0

## 0.20.1

### Patch Changes
Expand Down
2 changes: 2 additions & 0 deletions platforms/vscode/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Provider, ProviderProps } from "@hyperbook/provider";
import elementTab from "@hyperbook/element-tabs";
import elementTiles from "@hyperbook/element-tiles";
import elementAudio from "@hyperbook/element-audio";
import elementVideo from "@hyperbook/element-video";
import elementAlert from "@hyperbook/element-alert";
import elementBitflow from "@hyperbook/element-bitflow";
import elementTerm from "@hyperbook/element-term";
Expand Down Expand Up @@ -136,6 +137,7 @@ export const App = () => {
elements={[
elementTab,
elementAudio,
elementVideo,
elementAlert,
elementBitflow,
elementTerm,
Expand Down
1 change: 1 addition & 0 deletions platforms/vscode/app/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@import "@hyperbook/element-tabs/index.css";
@import "@hyperbook/element-tiles/index.css";
@import "@hyperbook/element-audio/index.css";
@import "@hyperbook/element-video/index.css";
@import "@hyperbook/element-alert/index.css";
@import "@hyperbook/element-term/index.css";
@import "@hyperbook/element-youtube/index.css";
Expand Down
3 changes: 2 additions & 1 deletion platforms/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"homepage": "https://hyperbook.openpatch.org",
"main": "./out/extension.js",
"version": "0.20.1",
"version": "0.21.0",
"engines": {
"vscode": "^1.71.0"
},
Expand Down Expand Up @@ -182,6 +182,7 @@
},
"dependencies": {
"@hyperbook/element-audio": "workspace:*",
"@hyperbook/element-video": "workspace:*",
"@hyperbook/element-alert": "workspace:*",
"@hyperbook/element-bitflow": "workspace:*",
"@hyperbook/element-bookmarks": "workspace:*",
Expand Down
11 changes: 11 additions & 0 deletions platforms/web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# hyperbook-simple-template

## 0.28.0

### Minor Changes

- [#847](https://github.com/openpatch/hyperbook/pull/847) [`0b893a3`](https://github.com/openpatch/hyperbook/commit/0b893a39ba9f5e3fffa40fc3ce115bd379f43313) Thanks [@elielmartinsbr](https://github.com/elielmartinsbr)! - add video element

### Patch Changes

- Updated dependencies [[`0b893a3`](https://github.com/openpatch/hyperbook/commit/0b893a39ba9f5e3fffa40fc3ce115bd379f43313)]:
- @hyperbook/element-video@0.2.0

## 0.27.1

### Patch Changes
Expand Down
Loading

0 comments on commit d8e07d3

Please sign in to comment.