Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update package about full.js
Browse files Browse the repository at this point in the history
hqer927 committed Nov 11, 2024
1 parent 921fefa commit f4a6fb1
Showing 9 changed files with 220 additions and 64 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -41,13 +41,13 @@
"typedoc": "^0.24.8",
"typedoc-plugin-markdown": "^3.15.3",
"typescript": "5.1.6",
"vite": "^4.4.1",
"white-web-sdk": "^2.16.51"
"vite": "^4.4.1"
},
"pnpm": {
"overrides": {
"@netless/window-manager": "^0.4.75",
"@netless/appliance-plugin": "1.1.2"
"@netless/appliance-plugin": "1.1.2",
"white-web-sdk": "^2.16.51"
},
"peerDependencyRules": {
"ignoreMissing": [
52 changes: 20 additions & 32 deletions packages/buildtool/index.mjs
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ export async function build({
plugins: [
esbuildPlugin([], {
"@netless/fastboard-core": "@netless/fastboard-core/lite",
"@netless/fastboard-ui": "@netless/fastboard-ui/lite",
// "@netless/fastboard-ui": "@netless/fastboard-ui/lite",
}),
],
external: [/^[@a-z]/],
@@ -148,7 +148,7 @@ export async function build({
}

start = Date.now();
await dts.build(main, "dist/index.d.ts", { exclude: ["svelte", "svelte/internal", "./lite"] });
await dts.build(main, "dist/index.d.ts", { exclude: ["svelte", "svelte/internal", "./lite", "./full"] });
console.log("Built dist/index.d.ts in", Date.now() - start + "ms");

// Generate dist/lite.d.ts
@@ -166,8 +166,8 @@ export async function build({
console.log("Built dist/lite.d.ts in", Date.now() - start + "ms");
}

// Build dist/index.global.ts
const esbuildGlobalPlugin = (external, alias = {}) => ({
// Build dist/full.js
const esbuildFullPlugin = (external, alias = {}) => ({
name: "esbuild",
async load(id) {
const { outputFiles } = await esbuild.build({
@@ -176,7 +176,7 @@ export async function build({
format: "esm",
// The filename here does not really matter, because
// rollup will then merge sourcemaps and get the original input filename.
outfile: id.replace(/\.tsx?$/, ".global.js"),
outfile: id.replace(/\.tsx?$/, ".js"),
sourcemap: true,
write: false,
target: ["es2017"],
@@ -189,13 +189,15 @@ export async function build({
__VERSION__: JSON.stringify(version),
},
alias,
external: name.endsWith("-core") ? Object.keys({
...(external && external.reduce((acc, cur) => ((acc[cur] = true), acc), {})),
}) : Object.keys({
...dependencies,
...peerDependencies,
...(external && external.reduce((acc, cur) => ((acc[cur] = true), acc), {})),
}),
external: name.endsWith("-core")
? Object.keys({
...(external && external.reduce((acc, cur) => ((acc[cur] = true), acc), {})),
})
: Object.keys({
...dependencies,
...peerDependencies,
...(external && external.reduce((acc, cur) => ((acc[cur] = true), acc), {})),
}),
});
let code, map;
for (const { path, text } of outputFiles) {
@@ -205,25 +207,13 @@ export async function build({
return { code, map };
},
});

{
const start = Date.now();
// const bundle = await rollup.rollup({
// input: main,
// plugins: [esbuildGlobalPlugin()],
// external: [/^[@a-z]/],
// });
// const iife = bundle.write({
// file: "dist/index.global.js",
// format: "iife",
// name: `${name[0].toUpperCase()}${name.slice(1)}`,
// });
start = Date.now();
if (!name.endsWith("-ui")) {
const bundle = await rollup.rollup({
input: main,
input: name.endsWith("-core") ? "src/full.ts" : main,
plugins: [
esbuildGlobalPlugin([], {
"@netless/fastboard-core": "@netless/fastboard-core/full",
"@netless/fastboard-ui": "@netless/fastboard-ui/full",
esbuildFullPlugin([], {
"@netless/fastboard-core": "@netless/fastboard-core/full"
}),
],
external: [/^[@a-z]/],
@@ -247,10 +237,9 @@ export async function build({
await bundle.close();
console.log("Built dist/full.{js|mjs} in", Date.now() - start + "ms");
}

start = Date.now();
if (name.endsWith("-core")) {
await dts.build("src/index.ts", "dist/full.d.ts", { exclude: ["svelte", "svelte/internal"] });
await dts.build("src/full.ts", "dist/full.d.ts", { exclude: ["svelte", "svelte/internal"] });
console.log("Built dist/full.d.ts in", Date.now() - start + "ms");
} else {
let code = fs.readFileSync("dist/index.d.ts", "utf-8");
@@ -259,5 +248,4 @@ export async function build({
fs.writeFileSync("dist/full.d.ts", code);
console.log("Built dist/full.d.ts in", Date.now() - start + "ms");
}

}
5 changes: 5 additions & 0 deletions packages/fastboard-core/full.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
declare global {
interface Window {
global: any;
}
}
export * from "./dist/full";
22 changes: 15 additions & 7 deletions packages/fastboard-core/package.json
Original file line number Diff line number Diff line change
@@ -5,12 +5,14 @@
"main": "src/index.ts",
"exports": {
".": "./src/index.ts",
"./lite": "./src/lite.ts"
"./lite": "./src/lite.ts",
"./full": "./src/full.ts"
},
"files": [
"src",
"dist",
"lite.d.ts"
"lite.d.ts",
"full.d.ts"
],
"repository": "netless-io/fastboard",
"scripts": {
@@ -19,17 +21,19 @@
"build": "buildtool"
},
"dependencies": {
"@netless/app-slide": "^0.2.39",
"@netless/app-slide": "^0.2.61",
"@netless/synced-store": "^2.0.7"
},
"peerDependencies": {
"@netless/appliance-plugin": ">=1.1.1",
"@netless/window-manager": ">=0.4.0",
"white-web-sdk": ">=2.16.0"
"jspdf":">=2.5.1",
"@netless/appliance-plugin": ">=1.1.2",
"@netless/window-manager": ">=0.4.75",
"white-web-sdk": ">=2.16.51"
},
"devDependencies": {
"@netless/buildtool": "workspace:*",
"white-web-sdk": "^2.16.51"
"white-web-sdk": "^2.16.51",
"jspdf":"^2.5.1"
},
"publishConfig": {
"main": "dist/index.js",
@@ -43,6 +47,10 @@
"./lite": {
"types": "./dist/lite.d.ts",
"default": "./dist/lite.mjs"
},
"./full": {
"types": "./dist/full.d.ts",
"default": "./dist/full.mjs"
}
}
}
3 changes: 3 additions & 0 deletions packages/fastboard-core/src/full.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
if (typeof window !== "undefined") {
(window as any).global = (window as any).global || {};
}
export * from "./lite";
export * from "./behaviors";
7 changes: 6 additions & 1 deletion packages/fastboard-react/package.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,8 @@
"files": [
"src",
"dist",
"lite.d.ts"
"lite.d.ts",
"full.d.ts"
],
"repository": "netless-io/fastboard",
"scripts": {
@@ -42,6 +43,10 @@
"./lite": {
"types": "./dist/lite.d.ts",
"default": "./dist/lite.mjs"
},
"./full": {
"types": "./dist/full.d.ts",
"default": "./dist/full.mjs"
}
}
}
7 changes: 6 additions & 1 deletion packages/fastboard/package.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,8 @@
"files": [
"src",
"dist",
"lite.d.ts"
"lite.d.ts",
"full.d.ts"
],
"repository": "netless-io/fastboard",
"scripts": {
@@ -35,6 +36,10 @@
"./lite": {
"types": "./dist/lite.d.ts",
"default": "./dist/lite.mjs"
},
"./full": {
"types": "./dist/full.d.ts",
"default": "./dist/full.mjs"
}
}
}
4 changes: 2 additions & 2 deletions packages/fastboard/test/main.ts
Original file line number Diff line number Diff line change
@@ -38,12 +38,12 @@ createFastboard({
},
joinRoom: {
uid: genUID(),
uuid: import.meta.env.VITE_ROOM_UUID || "586594d09dad11efacd4a7a764beb2c4",
uuid: import.meta.env.VITE_ROOM_UUID || "b76630509f1211ef835aff90209b1830",
useNativeClipboard: true,
floatBar: true,
roomToken:
import.meta.env.VITE_ROOM_TOKEN ||
"NETLESSROOM_YWs9VWtNUk92M1JIN2I2Z284dCZleHBpcmVBdD0xNzMxMTQxNzMxMTYzJm5vbmNlPTU4ODI5MmIwLTlkYWQtMTFlZi05NmE5LWFiMzg4NjE4OThhZiZyb2xlPTEmc2lnPTc0MmMwNmY0MmM0NzVjZjI2YTNkODE1ZTA1ODlmODU4ZGQyNzI1NWEwMmVjNWFmODkyYjg0NzgzMjBjNDVkODcmdXVpZD01ODY1OTRkMDlkYWQxMWVmYWNkNGE3YTc2NGJlYjJjNA",
"NETLESSROOM_YWs9VWtNUk92M1JIN2I2Z284dCZleHBpcmVBdD0xNzMxMjk1MjIwODQ2Jm5vbmNlPWI3N2Q4OGUwLTlmMTItMTFlZi05NmE5LWFiMzg4NjE4OThhZiZyb2xlPTEmc2lnPTMyYzc0NmI0YWM4NGUwYjgyMTg5ZWRhMWUzYmE3YWNhNzc1YTE1OGQ2YTExNjUyODlmNWE0ZDljM2I1ZjllNzAmdXVpZD1iNzY2MzA1MDlmMTIxMWVmODM1YWZmOTAyMDliMTgzMA",
},
managerConfig: {
cursor: true,
178 changes: 160 additions & 18 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

0 comments on commit f4a6fb1

Please sign in to comment.