fragment-tools 0.1.16 → 0.1.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fragment-tools",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "A web development environment for creative coding",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -73,6 +73,7 @@ export function createConfig(
73
73
  __SEED__: Date.now(),
74
74
  __BUILD__: build,
75
75
  __DEV__: !build,
76
+ global: {},
76
77
  },
77
78
  optimizeDeps: {
78
79
  include: ['convert-length', 'webm-writer', 'changedpi'],
@@ -15,13 +15,13 @@ export default function screenshot({
15
15
  cwd = process.cwd(),
16
16
  inlineExportDir,
17
17
  } = {}) {
18
- function resolveDirectory(directoryPath) {
18
+ function resolveDirectory(directoryPath, dirname) {
19
19
  return path.isAbsolute(directoryPath)
20
20
  ? directoryPath
21
- : path.join(cwd, directoryPath);
21
+ : path.join(path.join(cwd, dirname), directoryPath);
22
22
  }
23
23
 
24
- function resolveExportDirectory(exportDir) {
24
+ function resolveExportDirectory(exportDir, dirname) {
25
25
  let directory;
26
26
 
27
27
  if (inlineExportDir) {
@@ -37,7 +37,7 @@ export default function screenshot({
37
37
  );
38
38
  }
39
39
  } else if (exportDir) {
40
- directory = resolveDirectory(exportDir);
40
+ directory = resolveDirectory(exportDir, dirname);
41
41
  } else {
42
42
  directory = cwd;
43
43
  }
@@ -62,10 +62,16 @@ export default function screenshot({
62
62
  const { filename, data, encoding, exportDir } =
63
63
  files[i];
64
64
 
65
- let directory = resolveExportDirectory(exportDir);
65
+ let directory = resolveExportDirectory(
66
+ exportDir,
67
+ path.dirname(filename),
68
+ );
66
69
  mkdirp(directory);
67
70
 
68
- let filepath = path.join(directory, filename);
71
+ let filepath = path.join(
72
+ directory,
73
+ path.basename(filename),
74
+ );
69
75
 
70
76
  let buffer = Buffer.from(
71
77
  encoding === 'base64'
@@ -58,7 +58,6 @@
58
58
  value={$exports.imageCount || 1}
59
59
  params={{ step: 1 }}
60
60
  on:change={(e) => {
61
- console.log(e.detail, $exports.imageCount);
62
61
  $exports.imageCount = e.detail;
63
62
  }}
64
63
  />
@@ -30,6 +30,7 @@ export let onBeforeUpdatePreview = ({ id }) => {
30
30
 
31
31
  if (preview) {
32
32
  preview.rendered = false;
33
+ preview.p.resetMatrix();
33
34
  }
34
35
  };
35
36
 
@@ -52,7 +53,8 @@ export let onResizePreview = ({ id, width, height, pixelRatio }) => {
52
53
  const preview = previews.find((p) => p.id === id);
53
54
 
54
55
  if (preview) {
55
- preview.p.resizeCanvas(width * pixelRatio, height * pixelRatio, false);
56
+ preview.p.pixelDensity(pixelRatio);
57
+ preview.p.resizeCanvas(width, height, false);
56
58
  }
57
59
  };
58
60
 
@@ -22,11 +22,20 @@ export let onMountPreview = ({ id, width, height }) => {
22
22
  };
23
23
  };
24
24
 
25
+ export let onBeforeUpdatePreview = ({ id }) => {
26
+ const preview = previews.find((p) => p.id === id);
27
+
28
+ if (preview) {
29
+ preview.p.resetMatrix();
30
+ }
31
+ };
32
+
25
33
  export let onResizePreview = ({ id, width, height, pixelRatio }) => {
26
34
  const preview = previews.find((p) => p.id === id);
27
35
 
28
36
  if (preview) {
29
- preview.p.resizeCanvas(width * pixelRatio, height * pixelRatio, false);
37
+ preview.p.pixelDensity(pixelRatio);
38
+ preview.p.resizeCanvas(width, height, false);
30
39
  }
31
40
  };
32
41
 
@@ -165,7 +165,8 @@ export function recordCanvas(
165
165
  files.push({
166
166
  filename,
167
167
  data,
168
- blob: exportDir,
168
+ blob,
169
+ exportDir,
169
170
  encoding: 'base64',
170
171
  });
171
172
  }
@@ -80,8 +80,8 @@ export function inferFieldType({ type, value, params, key }) {
80
80
  }
81
81
 
82
82
  export function hasChanged(initialValue, currentValue) {
83
- const initialType = typeof initialValue;
84
- const currentType = typeof currentValue;
83
+ const initialType = initialValue && typeof initialValue;
84
+ const currentType = currentValue && typeof currentValue;
85
85
 
86
86
  if (initialType !== currentType) return true;
87
87