js-draw 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+
2
+ # 0.0.2
3
+ * Adjust default editor colors based on system theme.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![](doc/img/js-draw.jpg)
4
4
 
5
- For example usage, see [doc/example/example.html](doc/example/example.ts).
5
+ For example usage, see [doc/example/example.ts](doc/example/example.ts).
6
6
 
7
7
  # API
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-draw",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript. ",
5
5
  "main": "dist/src/Editor.js",
6
6
  "types": "dist/src/Editor.d.ts",
@@ -77,6 +77,9 @@
77
77
  "doc": "doc"
78
78
  },
79
79
  "keywords": [
80
- "ink"
80
+ "ink",
81
+ "drawing",
82
+ "pen",
83
+ "svg"
81
84
  ]
82
85
  }
package/src/Editor.css CHANGED
@@ -10,6 +10,17 @@
10
10
  --secondary-foreground-color: black;
11
11
  }
12
12
 
13
+ @media (prefers-color-scheme: dark) {
14
+ .imageEditorContainer {
15
+ /* Deafult colors for the editor */
16
+ --primary-background-color: #151515;
17
+ --primary-background-color-transparent: rgba(50, 50, 50, 0.5);
18
+ --secondary-background-color: #607;
19
+ --primary-foreground-color: white;
20
+ --secondary-foreground-color: white;
21
+ }
22
+ }
23
+
13
24
  .imageEditorContainer {
14
25
  color: var(--primary-foreground-color);
15
26
  font-family: system-ui, -apple-system, sans-serif;
@@ -1,12 +0,0 @@
1
- export default class BundledFile {
2
- readonly bundleName: string;
3
- private readonly sourceFilePath;
4
- private readonly bundleBaseName;
5
- private readonly rootFileDirectory;
6
- constructor(bundleName: string, sourceFilePath: string);
7
- private getWebpackOptions;
8
- private handleErrors;
9
- build(): Promise<void>;
10
- startWatching(): void;
11
- }
12
- export declare const bundledFiles: BundledFile[];
@@ -1,153 +0,0 @@
1
- // This file is taken from Joplin: https://github.com/laurent22/joplin
2
- // js-draw was originally created as a part of a pull request for joplin. This
3
- // is part of the functionality from Joplin it requires.
4
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
- return new (P || (P = Promise))(function (resolve, reject) {
7
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
- step((generator = generator.apply(thisArg, _arguments || [])).next());
11
- });
12
- };
13
- import { dirname, extname, basename } from 'path';
14
- import TerserPlugin from 'terser-webpack-plugin';
15
- import webpack from 'webpack';
16
- export default class BundledFile {
17
- constructor(bundleName, sourceFilePath) {
18
- this.bundleName = bundleName;
19
- this.sourceFilePath = sourceFilePath;
20
- this.rootFileDirectory = dirname(sourceFilePath);
21
- this.bundleBaseName = basename(sourceFilePath, extname(sourceFilePath));
22
- }
23
- getWebpackOptions(mode) {
24
- const config = {
25
- mode,
26
- entry: this.sourceFilePath,
27
- output: {
28
- path: this.rootFileDirectory,
29
- filename: `${this.bundleBaseName}.bundle.js`,
30
- library: {
31
- type: 'window',
32
- name: this.bundleName,
33
- },
34
- },
35
- // See https://webpack.js.org/guides/typescript/
36
- module: {
37
- rules: [
38
- {
39
- // Include .tsx to include react components
40
- test: /\.tsx?$/i,
41
- use: 'ts-loader',
42
- exclude: /node_modules/,
43
- },
44
- {
45
- test: /\.css$/i,
46
- use: ['style-loader', 'css-loader'],
47
- },
48
- ],
49
- },
50
- optimization: {
51
- minimizer: [
52
- // Don't create separate files for comments.
53
- // See https://stackoverflow.com/a/65650316/17055750
54
- new TerserPlugin({
55
- extractComments: false,
56
- }),
57
- ],
58
- },
59
- // Increase the minimum size required
60
- // to trigger warnings.
61
- // See https://stackoverflow.com/a/53517149/17055750
62
- performance: {
63
- maxAssetSize: 2000000,
64
- maxEntrypointSize: 2000000,
65
- },
66
- resolve: {
67
- extensions: ['.tsx', '.ts', '.js'],
68
- },
69
- };
70
- return config;
71
- }
72
- handleErrors(err, stats) {
73
- let failed = false;
74
- if (err) {
75
- console.error(`Error: ${err.name}`, err.message, err.stack);
76
- failed = true;
77
- }
78
- else if ((stats === null || stats === void 0 ? void 0 : stats.hasErrors()) || (stats === null || stats === void 0 ? void 0 : stats.hasWarnings())) {
79
- const data = stats.toJson();
80
- if (data.warnings && data.warningsCount) {
81
- console.warn('Warnings: ', data.warningsCount);
82
- for (const warning of data.warnings) {
83
- // Stack contains the message
84
- if (warning.stack) {
85
- console.warn(warning.stack);
86
- }
87
- else {
88
- console.warn(warning.message);
89
- }
90
- }
91
- }
92
- if (data.errors && data.errorsCount) {
93
- console.error('Errors: ', data.errorsCount);
94
- for (const error of data.errors) {
95
- if (error.stack) {
96
- console.error(error.stack);
97
- }
98
- else {
99
- console.error(error.message);
100
- }
101
- console.error();
102
- }
103
- failed = true;
104
- }
105
- }
106
- return failed;
107
- }
108
- // Create a minified JS file in the same directory as `this.sourceFilePath` with
109
- // the same name.
110
- build() {
111
- const compiler = webpack(this.getWebpackOptions('production'));
112
- return new Promise((resolve, reject) => {
113
- console.info(`Building bundle: ${this.bundleName}...`);
114
- compiler.run((err, stats) => {
115
- let failed = this.handleErrors(err, stats);
116
- // Clean up.
117
- compiler.close((error) => __awaiter(this, void 0, void 0, function* () {
118
- if (error) {
119
- console.error('Error cleaning up:', error);
120
- failed = true;
121
- }
122
- if (!failed) {
123
- console.log('☑ Done building! ☑');
124
- resolve();
125
- }
126
- else {
127
- reject();
128
- }
129
- }));
130
- });
131
- });
132
- }
133
- startWatching() {
134
- const compiler = webpack(this.getWebpackOptions('development'));
135
- const watchOptions = {
136
- ignored: [
137
- '**/node_modules',
138
- '**/dist',
139
- ],
140
- };
141
- console.info('Watching bundle: ', this.bundleName);
142
- compiler.watch(watchOptions, (err, stats) => __awaiter(this, void 0, void 0, function* () {
143
- const failed = this.handleErrors(err, stats);
144
- if (!failed) {
145
- console.log('☑ Built! ☑');
146
- }
147
- }));
148
- }
149
- }
150
- const rootDir = dirname(__dirname);
151
- export const bundledFiles = [
152
- new BundledFile('jsdraw', `${rootDir}/src/main.ts`),
153
- ];
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { bundledFiles } from '../build_tools/BundledFile';
11
- function build() {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- // Build all in parallel
14
- yield Promise.all(bundledFiles.map((file) => __awaiter(this, void 0, void 0, function* () {
15
- yield file.build();
16
- })));
17
- });
18
- }
19
- void build();
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import { bundledFiles } from '../build_tools/BundledFile';
2
- console.log('Watching for changes...');
3
- function watch() {
4
- // Watch for changes
5
- for (const file of bundledFiles) {
6
- file.startWatching();
7
- }
8
- }
9
- watch();
@@ -1,3 +0,0 @@
1
- import './editorStyles';
2
- import Editor from './Editor';
3
- export { Editor };
package/dist/src/main.js DELETED
@@ -1,4 +0,0 @@
1
- // Main entrypoint for bundled content
2
- import './editorStyles';
3
- import Editor from './Editor';
4
- export { Editor };