@jscad/web 2.5.3 → 2.5.4
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 +11 -0
- package/data/themes.js +40 -40
- package/dist/jscad-web.min.js +46 -46
- package/examples/core/colors/basicColors.js +0 -1
- package/examples/core/colors/colorCube.js +10 -12
- package/examples/core/curves/bezier/extrudeAlongPath.js +20 -22
- package/examples/core/curves/bezier/simpleExtrude.js +4 -6
- package/examples/core/extrusions/basicExtrusions.js +3 -3
- package/examples/core/hulls/hull2D.js +3 -5
- package/examples/core/hulls/hull3D.js +3 -5
- package/examples/core/measurements/measureAggregateBounds.js +5 -7
- package/examples/core/measurements/measureAreaAndVolume.js +6 -8
- package/examples/core/measurements/measureBounds.js +5 -7
- package/examples/core/other/orientation.js +2 -3
- package/examples/core/primitives/dodecahedron.js +1 -3
- package/examples/core/primitives/polyhedron.js +12 -14
- package/examples/core/primitives/primitives2D.js +1 -3
- package/examples/core/primitives/primitives3D.js +2 -4
- package/examples/core/primitives/roundedCuboid.js +7 -9
- package/examples/core/primitives/sphere.js +10 -12
- package/examples/core/primitives/torus.js +20 -22
- package/examples/core/text/text.js +5 -8
- package/examples/core/transforms/align.js +5 -7
- package/examples/core/transforms/center.js +6 -8
- package/examples/import/AMFImport/index.js +1 -3
- package/examples/import/STLImport/index.js +4 -6
- package/examples/import/SVGImport/index.js +0 -1
- package/examples/module-design/mountPlate.js +5 -9
- package/examples/module-design/subFolder/sphereShape.js +1 -3
- package/examples/parameters/allParamTypes.js +19 -21
- package/examples/parameters/balloons.js +15 -26
- package/examples/parameters/gear.js +9 -11
- package/package.json +7 -7
- package/postInstall.js +3 -3
- package/src/index.js +0 -1
- package/src/most-gestures/drags.js +15 -0
- package/src/most-gestures/zooms.js +20 -1
- package/src/sideEffects/dat/index.js +0 -6
- package/src/sideEffects/dom/index.js +0 -2
- package/src/sideEffects/fileDialog/index.js +0 -2
- package/src/sideEffects/i18n/index.js +0 -1
- package/src/sideEffects/localFs/index.js +1 -4
- package/src/sideEffects/localFs/walkFileTree.js +1 -7
- package/src/sideEffects/localStorage/index.js +0 -1
- package/src/sideEffects/state/index.js +0 -11
- package/src/ui/flow/design.js +5 -26
- package/src/ui/flow/dom.js +0 -1
- package/src/ui/flow/flowOut.js +0 -24
- package/src/ui/flow/languages.js +0 -1
- package/src/ui/flow/shortcuts.js +0 -1
- package/src/ui/flow/themes.js +1 -1
- package/src/ui/flow/tools.js +0 -6
- package/src/ui/views/editor.js +0 -6
- package/src/ui/views/parameterControls.js +0 -1
- package/src/ui/views/status.js +4 -2
- package/src/utils/keys.js +0 -1
|
@@ -13,29 +13,27 @@ const { primitives } = require('@jscad/modeling')
|
|
|
13
13
|
const values = [3, 4, 5, 6]
|
|
14
14
|
const captions = ['three', 'four', 'five', 'six']
|
|
15
15
|
|
|
16
|
-
const getParameterDefinitions = () =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{ name: 'password', type: 'password', initial: '', caption: 'Password:' },
|
|
16
|
+
const getParameterDefinitions = () => [
|
|
17
|
+
{ name: 'group1', type: 'group', caption: 'Group 1: Text Entry' },
|
|
18
|
+
{ name: 'text', type: 'text', initial: '', size: 20, maxLength: 20, caption: 'Plain Text:', placeholder: '20 characters' },
|
|
19
|
+
{ name: 'int', type: 'int', initial: 20, min: 1, max: 100, step: 1, caption: 'Integer:' },
|
|
20
|
+
{ name: 'number', type: 'number', initial: 2.0, min: 1.0, max: 10.0, step: 0.1, caption: 'Number:' },
|
|
21
|
+
{ name: 'date', type: 'date', initial: '2020-01-01', min: '2020-01-01', max: '2030-12-31', caption: 'Date:', placeholder: 'YYYY-MM-DD' },
|
|
22
|
+
{ name: 'email', type: 'email', initial: 'me@example.com', caption: 'Email:' },
|
|
23
|
+
{ name: 'url', type: 'url', initial: 'www.example.com', size: 40, maxLength: 40, caption: 'Url:', placeholder: '40 characters' },
|
|
24
|
+
{ name: 'password', type: 'password', initial: '', caption: 'Password:' },
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
{ name: 'group2', type: 'group', caption: 'Group 2: Interactive Controls' },
|
|
27
|
+
{ name: 'checkbox', type: 'checkbox', checked: true, initial: '20', caption: 'Checkbox:' },
|
|
28
|
+
{ name: 'color', type: 'color', initial: '#FFB431', caption: 'Color:' },
|
|
29
|
+
{ name: 'slider', type: 'slider', initial: 3, min: 1, max: 10, step: 1, caption: 'Slider:' },
|
|
30
|
+
{ name: 'choice1', type: 'choice', caption: 'Dropdown Menu:', values: [0, 1, 2, 3], captions: ['No', 'Yes', 'Maybe', 'So so'], initial: 2 },
|
|
31
|
+
{ name: 'choice3', type: 'choice', caption: 'Dropdown Menu:', values: ['No', 'Yes', 'Maybe', 'So so'], initial: 'No' },
|
|
32
|
+
{ name: 'choice2', type: 'radio', caption: 'Radio Buttons:', values, captions, initial: 5 },
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
34
|
+
{ name: 'group3', type: 'group', initial: 'closed', caption: 'Group 3: Initially Closed Group' },
|
|
35
|
+
{ name: 'checkbox2', type: 'checkbox', checked: true, initial: '20', caption: 'Optional Checkbox:' }
|
|
36
|
+
]
|
|
39
37
|
|
|
40
38
|
const main = (params) => {
|
|
41
39
|
console.log(params)
|
|
@@ -12,30 +12,27 @@ const jscad = require('@jscad/modeling')
|
|
|
12
12
|
|
|
13
13
|
const { subtract, union } = jscad.booleans
|
|
14
14
|
const { colorize, hexToRgb } = jscad.colors
|
|
15
|
-
const { expand } = jscad.expansions
|
|
16
15
|
const { extrudeFromSlices, extrudeLinear, slice } = jscad.extrusions
|
|
17
16
|
const { geom2 } = jscad.geometries
|
|
18
17
|
const { hullChain } = jscad.hulls
|
|
19
18
|
const { mat4 } = jscad.maths
|
|
20
19
|
const { measureBoundingBox } = jscad.measurements
|
|
21
|
-
const { circle, ellipsoid
|
|
20
|
+
const { circle, ellipsoid } = jscad.primitives
|
|
22
21
|
const { vectorText } = jscad.text
|
|
23
22
|
const { translate, scale, rotateX, center } = jscad.transforms
|
|
24
23
|
|
|
25
24
|
const options = { segments: 32 }
|
|
26
25
|
|
|
27
|
-
const getParameterDefinitions = () =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]
|
|
38
|
-
}
|
|
26
|
+
const getParameterDefinitions = () => [
|
|
27
|
+
{ name: 'balloon', type: 'group', caption: 'Balloons' },
|
|
28
|
+
{ name: 'isBig', type: 'checkbox', checked: true, initial: '20', caption: 'Big?' },
|
|
29
|
+
{ name: 'color', type: 'color', initial: '#FFB431', caption: 'Color?' },
|
|
30
|
+
{ name: 'count', type: 'slider', initial: 4, min: 2, max: 10, step: 1, caption: 'How many?' },
|
|
31
|
+
{ name: 'friend', type: 'group', caption: 'Friend' },
|
|
32
|
+
{ name: 'name', type: 'text', initial: '', size: 20, maxLength: 20, caption: 'Name?', placeholder: '20 characters' },
|
|
33
|
+
{ name: 'birthdate', type: 'date', initial: '', min: '1915-01-01', max: '2030-12-31', caption: 'Birthday?', placeholder: 'YYYY-MM-DD' },
|
|
34
|
+
{ name: 'age', type: 'int', initial: 20, min: 1, max: 100, step: 1, caption: 'Age?' }
|
|
35
|
+
]
|
|
39
36
|
|
|
40
37
|
const initializeOptions = (params) => {
|
|
41
38
|
// use the checkbox to determine the size of the sphere
|
|
@@ -64,10 +61,10 @@ const text = (message, extrusionHeight, characterLineWidth) => {
|
|
|
64
61
|
|
|
65
62
|
const createSingleBalloon = (params) => {
|
|
66
63
|
let t = rotateX(Math.PI / 2, text(params.age.toString(), 2, 2))
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
const m = measureBoundingBox(t)
|
|
65
|
+
const x = (options.b_radius * 0.70) / Math.max(m[1][0], m[1][2])
|
|
66
|
+
const y = options.b_radius * 3
|
|
67
|
+
const z = x
|
|
71
68
|
t = translate([0, y / 2, 0], scale([x, y, z], t))
|
|
72
69
|
|
|
73
70
|
const b = ellipsoid({
|
|
@@ -118,14 +115,6 @@ const createSalutation = (name) => {
|
|
|
118
115
|
return translate([0, -10, 0], scale([0.5, 0.5, 0.5], text(salutation, 2, 2)))
|
|
119
116
|
}
|
|
120
117
|
|
|
121
|
-
const createAge = (age) => {
|
|
122
|
-
let age3D = text(age.toString(), 10, 3)
|
|
123
|
-
age3D = scale([2, 2, 2], age3D)
|
|
124
|
-
age3D = rotateX(Math.PI / 2, age3D)
|
|
125
|
-
age3D = translate([0, 30, 30], age3D)
|
|
126
|
-
return age3D
|
|
127
|
-
}
|
|
128
|
-
|
|
129
118
|
const createBirthDate = (birthDate) => {
|
|
130
119
|
const birthDateStr = birthDate.toString()
|
|
131
120
|
if (birthDateStr.length === 0) {
|
|
@@ -17,16 +17,14 @@ const { vec2 } = jscad.maths
|
|
|
17
17
|
const { degToRad } = jscad.utils
|
|
18
18
|
|
|
19
19
|
// Here we define the user editable parameters:
|
|
20
|
-
const getParameterDefinitions = () =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
]
|
|
29
|
-
}
|
|
20
|
+
const getParameterDefinitions = () => [
|
|
21
|
+
{ name: 'numTeeth', caption: 'Number of teeth:', type: 'int', initial: 10, min: 5, max: 20, step: 1 },
|
|
22
|
+
{ name: 'circularPitch', caption: 'Circular pitch:', type: 'float', initial: 5 },
|
|
23
|
+
{ name: 'pressureAngle', caption: 'Pressure angle:', type: 'float', initial: 20 },
|
|
24
|
+
{ name: 'clearance', caption: 'Clearance:', type: 'float', initial: 0.0, step: 0.1 },
|
|
25
|
+
{ name: 'thickness', caption: 'Thickness:', type: 'float', initial: 5 },
|
|
26
|
+
{ name: 'centerholeradius', caption: 'Radius of center hole (0 for no hole):', type: 'float', initial: 2 }
|
|
27
|
+
]
|
|
30
28
|
|
|
31
29
|
// Main entry point; here we construct our solid:
|
|
32
30
|
const main = (params) => {
|
|
@@ -74,7 +72,7 @@ const createBaseCirclePolygon = (numTeeth, angularToothWidthAtBase, rootRadius)
|
|
|
74
72
|
const toothCenterAngle = 0.5 * angularToothWidthAtBase
|
|
75
73
|
for (let k = 0; k < numTeeth; k++) {
|
|
76
74
|
const currentAngle = toothCenterAngle + k * toothAngle
|
|
77
|
-
|
|
75
|
+
const p1 = vec2.scale(vec2.create(), vec2.fromAngleRadians(vec2.create(), currentAngle), rootRadius)
|
|
78
76
|
points.push([p1[0], p1[1]])
|
|
79
77
|
}
|
|
80
78
|
return polygon({ points, closed: true })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jscad/web",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.4",
|
|
4
4
|
"description": "Web Application for JSCAD",
|
|
5
5
|
"repository": "https://github.com/jscad/OpenJSCAD.org",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@jscad/array-utils": "2.1.1",
|
|
38
|
-
"@jscad/core": "2.5.
|
|
39
|
-
"@jscad/examples": "2.3.
|
|
40
|
-
"@jscad/io": "2.2.
|
|
41
|
-
"@jscad/modeling": "2.7.
|
|
42
|
-
"@jscad/regl-renderer": "2.5.
|
|
38
|
+
"@jscad/core": "2.5.4",
|
|
39
|
+
"@jscad/examples": "2.3.2",
|
|
40
|
+
"@jscad/io": "2.2.4",
|
|
41
|
+
"@jscad/modeling": "2.7.2",
|
|
42
|
+
"@jscad/regl-renderer": "2.5.4",
|
|
43
43
|
"@most/create": "2.0.1",
|
|
44
44
|
"brace": "0.11.1",
|
|
45
45
|
"codemirror": "5.57.0",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"url": "https://opencollective.com/openjscad",
|
|
67
67
|
"logo": "https://opencollective.com/openjscad/logo.txt"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "b6c5675d2d9a292e0ba24896bf22d0e9dc5d4270"
|
|
70
70
|
}
|
package/postInstall.js
CHANGED
|
@@ -6,7 +6,7 @@ const fs = require('fs')
|
|
|
6
6
|
const DocBlock = require('docblock')
|
|
7
7
|
const docBlock = new DocBlock()
|
|
8
8
|
|
|
9
|
-
const ignoreExamples = {Imports:1, Projects:1}
|
|
9
|
+
const ignoreExamples = { Imports: 1, Projects: 1 }
|
|
10
10
|
|
|
11
11
|
const copyAndProcessExamples = (examplesSrc) => {
|
|
12
12
|
const examples = { 'Creating Shapes': [], 'Manipulating Shapes': [], Colors: [], Parameters: [], Other: [] }
|
|
@@ -42,8 +42,8 @@ const processExamplesFile = (filePath, examples) => {
|
|
|
42
42
|
if (result.length) {
|
|
43
43
|
const category = result[0].tags.category
|
|
44
44
|
|
|
45
|
-
if(category in ignoreExamples){
|
|
46
|
-
console.log(`Ignoring example ${filePath}`)
|
|
45
|
+
if (category in ignoreExamples) {
|
|
46
|
+
console.log(`Ignoring example ${filePath}`)
|
|
47
47
|
return
|
|
48
48
|
}
|
|
49
49
|
|
package/src/index.js
CHANGED
|
@@ -114,7 +114,6 @@ const makeJscad = async (targetElement, options) => {
|
|
|
114
114
|
|
|
115
115
|
// we return a function to allow setting/modifying params
|
|
116
116
|
const mainParams = callbackToObservable()
|
|
117
|
-
// mainParams.stream.forEach(x => console.log('setting params', x))
|
|
118
117
|
return (params) => {
|
|
119
118
|
mainParams.callback(params)
|
|
120
119
|
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
const { merge } = require('most')
|
|
2
2
|
|
|
3
|
+
let isPinching = false
|
|
4
|
+
|
|
5
|
+
if (typeof window !== 'undefined') {
|
|
6
|
+
window.addEventListener('pinchStarted', (e) => {
|
|
7
|
+
// console.log("received pinch started");
|
|
8
|
+
isPinching = true
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
window.addEventListener('pinchEnded', (e) => {
|
|
12
|
+
// console.log("received pinch ended");
|
|
13
|
+
isPinching = false
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
// based on http://jsfiddle.net/mattpodwysocki/pfCqq/
|
|
4
18
|
const mouseDrags = (mouseDowns$, mouseUps, mouseMoves, settings) => {
|
|
5
19
|
const { pixelRatio } = settings
|
|
@@ -47,6 +61,7 @@ const touchDrags = (touchStarts$, touchEnds$, touchMoves$, settings) => {
|
|
|
47
61
|
let prevY = startY
|
|
48
62
|
|
|
49
63
|
return touchMoves$
|
|
64
|
+
.takeWhile((e) => isPinching === false)
|
|
50
65
|
.map((e) => {
|
|
51
66
|
const curX = e.touches[0].pageX * pixelRatio
|
|
52
67
|
const curY = e.touches[0].pageY * pixelRatio
|
|
@@ -18,6 +18,16 @@ const pinchZooms = ({ touchStarts$, touchMoves$, touchEnds$ }, settings) => {
|
|
|
18
18
|
return touchMoves$
|
|
19
19
|
.tap((e) => e.preventDefault())
|
|
20
20
|
.filter((t) => t.touches.length === 2)
|
|
21
|
+
.tap((e) => {
|
|
22
|
+
// console.log("pinch started");
|
|
23
|
+
if (typeof CustomEvent !== 'undefined') {
|
|
24
|
+
const pinchStarted = new CustomEvent('pinchStarted', {
|
|
25
|
+
detail: true
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
window.dispatchEvent(pinchStarted)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
21
31
|
.map((e) => {
|
|
22
32
|
const curX1 = e.touches[0].pageX * pixelRatio
|
|
23
33
|
const curY1 = e.touches[0].pageY * pixelRatio
|
|
@@ -43,7 +53,16 @@ const pinchZooms = ({ touchStarts$, touchMoves$, touchEnds$ }, settings) => {
|
|
|
43
53
|
const scale = e > 0 ? Math.sqrt(e) : -Math.sqrt(Math.abs(e))
|
|
44
54
|
return scale
|
|
45
55
|
}) */
|
|
46
|
-
.takeUntil(touchEnds
|
|
56
|
+
.takeUntil(touchEnds$.tap((e) => {
|
|
57
|
+
// console.log("pinch ended");
|
|
58
|
+
if (typeof CustomEvent !== 'undefined') {
|
|
59
|
+
const pinchEnded = new CustomEvent('pinchEnded', {
|
|
60
|
+
detail: true
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
window.dispatchEvent(pinchEnded)
|
|
64
|
+
}
|
|
65
|
+
}))
|
|
47
66
|
})
|
|
48
67
|
}
|
|
49
68
|
|
|
@@ -26,7 +26,6 @@ const makeDatSideEffect = async (params) => {
|
|
|
26
26
|
// every time a new command is recieved (observable)
|
|
27
27
|
commands$.forEach((command) => {
|
|
28
28
|
const { type, id, urls, path } = command
|
|
29
|
-
// console.log('command', command)
|
|
30
29
|
if (!enabled) {
|
|
31
30
|
commandResponses.callback({ type, id, error: new Error('Dat archives not supported in this environment!') })
|
|
32
31
|
return
|
|
@@ -44,7 +43,6 @@ const makeDatSideEffect = async (params) => {
|
|
|
44
43
|
|
|
45
44
|
archive = new DatArchive(url, {})
|
|
46
45
|
const filesAndFolders = await archive.readdir(path, { recursive: true, stat: true })
|
|
47
|
-
// console.log('filesAndFolders', filesAndFolders)
|
|
48
46
|
const fileContents = await Promise.all(filesAndFolders.map(async (f) => {
|
|
49
47
|
const fullPath = `${path}/${f.name}`
|
|
50
48
|
if (f.stat.isFile() && f.name.includes('js')) {
|
|
@@ -67,7 +65,6 @@ const makeDatSideEffect = async (params) => {
|
|
|
67
65
|
}]
|
|
68
66
|
commandResponses.callback({ type, id, url, data: hiearchyRoot })
|
|
69
67
|
const history = await archive.history()
|
|
70
|
-
console.log('history', history)
|
|
71
68
|
})
|
|
72
69
|
}
|
|
73
70
|
|
|
@@ -77,7 +74,6 @@ const makeDatSideEffect = async (params) => {
|
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
const watch = () => {
|
|
80
|
-
console.log('starting watch')
|
|
81
77
|
const evts = archive.watch()
|
|
82
78
|
// TODO: deal with additions & deletions
|
|
83
79
|
// ex /holder.stl has been updated!
|
|
@@ -86,11 +82,9 @@ const makeDatSideEffect = async (params) => {
|
|
|
86
82
|
evts.addEventListener('changed', async ({ path }) => {
|
|
87
83
|
// const fullPath = `${path}/${f.name}`
|
|
88
84
|
// TODO: how about folders ?
|
|
89
|
-
console.log(path, 'has been updated!')
|
|
90
85
|
const content = await archive.readFile(path)
|
|
91
86
|
const name = require('path').basename(path)
|
|
92
87
|
const entry = { name, ext: 'js', source: content, fullPath: `/${rootFolder}` + path }
|
|
93
|
-
// console.log('content', content)
|
|
94
88
|
// FIXME: cannot work
|
|
95
89
|
// hiearchyRoot.children = [...hiearchyRoot.children]
|
|
96
90
|
const index = hiearchyRoot[0].children.findIndex((el) => el.fullPath === entry.fullPath)
|
|
@@ -41,7 +41,6 @@ const makeDomSideEffect = ({ targetEl }) => {
|
|
|
41
41
|
} */
|
|
42
42
|
|
|
43
43
|
const select = (query) => {
|
|
44
|
-
// console.log('selecting', query)
|
|
45
44
|
const items = getElements(query)
|
|
46
45
|
|
|
47
46
|
let outputStream
|
|
@@ -61,7 +60,6 @@ const makeDomSideEffect = ({ targetEl }) => {
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
out$.forEach(() => {
|
|
64
|
-
// console.log('dom source watching dom change')
|
|
65
63
|
Object.keys(storedListeners).forEach((queryAndEventName) => {
|
|
66
64
|
const [query] = queryAndEventName.split('@@')
|
|
67
65
|
const items = getElements(query)
|
|
@@ -21,7 +21,6 @@ const makeFileDialog = (params) => {
|
|
|
21
21
|
const blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
|
22
22
|
saveAs(blob, filePath) */
|
|
23
23
|
|
|
24
|
-
console.log('here')
|
|
25
24
|
const input = document.createElement('input')
|
|
26
25
|
input.id = 'foo'
|
|
27
26
|
input.name = 'gna'
|
|
@@ -31,7 +30,6 @@ const makeFileDialog = (params) => {
|
|
|
31
30
|
// input.trigger('click')// opening dialog
|
|
32
31
|
// return false; // avoiding navigation
|
|
33
32
|
input.addEventListener('change', () => {
|
|
34
|
-
console.log('foo')
|
|
35
33
|
})
|
|
36
34
|
})
|
|
37
35
|
}
|
|
@@ -17,7 +17,6 @@ const makeLocalFsSideEffect = async (params) => {
|
|
|
17
17
|
webSocket = new WebSocket(localFsOptions.livereloadUrl)
|
|
18
18
|
|
|
19
19
|
webSocket.onopen = function (event) {
|
|
20
|
-
console.log('websocket open', event)
|
|
21
20
|
sendWs({ command: 'hello', protocols: ['http://livereload.com/protocols/official-6', 'http://livereload.com/protocols/official-7'], ver: '2.0.8', ext: 'Chrome', extver: '2.1.0' })
|
|
22
21
|
}
|
|
23
22
|
|
|
@@ -28,11 +27,10 @@ const makeLocalFsSideEffect = async (params) => {
|
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
webSocket.onerror = function (event) {
|
|
31
|
-
console.
|
|
30
|
+
console.warn('websocket error', event)
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
webSocket.onclose = function (event) {
|
|
35
|
-
console.log('websocket closed', event)
|
|
36
34
|
webSocket = null
|
|
37
35
|
}
|
|
38
36
|
}
|
|
@@ -111,7 +109,6 @@ const makeLocalFsSideEffect = async (params) => {
|
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
const write = () => {
|
|
114
|
-
// console.error('writing to local file system is not implemented yet')
|
|
115
112
|
}
|
|
116
113
|
|
|
117
114
|
const commandHandlers = {
|
|
@@ -30,8 +30,6 @@ const binaryMimetypes = {
|
|
|
30
30
|
* @returns {Promise} new promise to read and convert the file
|
|
31
31
|
*/
|
|
32
32
|
const readFileAsync = (file, fileMeta) => {
|
|
33
|
-
//console.log('readFileAsync',file,fileMeta)
|
|
34
|
-
|
|
35
33
|
const fullPath = fileMeta && fileMeta.fullPath ? fileMeta.fullPath : ''
|
|
36
34
|
const ext = getFileExtensionFromString(file.name)
|
|
37
35
|
const mimetype = file.mimetype
|
|
@@ -43,7 +41,7 @@ const readFileAsync = (file, fileMeta) => {
|
|
|
43
41
|
const result = event.target.result
|
|
44
42
|
if (result.byteLength) {
|
|
45
43
|
resolve({ name: file.name, ext, fullPath, mimetype, source: result })
|
|
46
|
-
} else if (typeof
|
|
44
|
+
} else if (typeof result === 'string') {
|
|
47
45
|
resolve({ name: file.name, ext, fullPath, mimetype, source: result })
|
|
48
46
|
}
|
|
49
47
|
}
|
|
@@ -87,7 +85,6 @@ const isEmpty = (x) => x !== null && x !== undefined // skip empty items
|
|
|
87
85
|
* @returns {Promise} one promise to resolve them all
|
|
88
86
|
*/
|
|
89
87
|
const processEntries = (items) => {
|
|
90
|
-
// console.log('processEntries',items)
|
|
91
88
|
const results = pseudoArraytoArray(items.filter(isEmpty))
|
|
92
89
|
.filter(isEmpty) // skip empty items
|
|
93
90
|
.reduce((result, item) => {
|
|
@@ -109,7 +106,6 @@ const processEntries = (items) => {
|
|
|
109
106
|
|
|
110
107
|
return Promise.all(results)
|
|
111
108
|
.then((x) => x.filter((x) => x !== null && x !== undefined))
|
|
112
|
-
// BAD .catch((error) => console.error(error.message))
|
|
113
109
|
}
|
|
114
110
|
|
|
115
111
|
/*
|
|
@@ -118,7 +114,6 @@ const processEntries = (items) => {
|
|
|
118
114
|
* @returns {Promise} new promise to read and process the file
|
|
119
115
|
*/
|
|
120
116
|
const processFile = (fileItem) => {
|
|
121
|
-
// console.log('processFile',fileItem)
|
|
122
117
|
const promiseFile = new Promise((resolve, reject) => {
|
|
123
118
|
fileItem.file(
|
|
124
119
|
(fileData) => {
|
|
@@ -139,7 +134,6 @@ const processFile = (fileItem) => {
|
|
|
139
134
|
* @returns {Promise} new promise to read and process the directory
|
|
140
135
|
*/
|
|
141
136
|
const processDirectory = (directory) => {
|
|
142
|
-
// console.log('processDirectory',directory)
|
|
143
137
|
const promiseDirectory = new Promise((resolve, reject) => {
|
|
144
138
|
if (directory.entries) {
|
|
145
139
|
directory.entries.length ? processEntries(directory.entries).then(resolve) : resolve([])
|
|
@@ -20,7 +20,6 @@ const makeStorageSideEffect = ({ name }) => {
|
|
|
20
20
|
const { type, key, data } = command
|
|
21
21
|
// const storage = target === `local` ? localStorage : sessionStorage
|
|
22
22
|
if (type === 'write') {
|
|
23
|
-
// console.log('writing settings', data)
|
|
24
23
|
localStorage.setItem(`jscad:${name}-${key}`, JSON.stringify(data))
|
|
25
24
|
} else if (type === 'read') {
|
|
26
25
|
const settings = localStorage.getItem(`jscad:${name}-${key}`)
|
|
@@ -33,11 +33,8 @@ const makeState = (params) => {
|
|
|
33
33
|
const source = () => {
|
|
34
34
|
const commandResponses$ = commandResponses.stream.multicast()
|
|
35
35
|
// return commandResponses$
|
|
36
|
-
// commandResponses$.forEach(x=>console.log('commandResponses', x))
|
|
37
36
|
return most.scan((state, input) => {
|
|
38
|
-
// console.log('updating state', state.design, input.type, input.state.design)
|
|
39
37
|
const foo = Object.assign({}, state, input.state)
|
|
40
|
-
// console.log('output state', foo.design)
|
|
41
38
|
return foo
|
|
42
39
|
}, initialState, commandResponses$)
|
|
43
40
|
.startWith(initialState)
|
|
@@ -47,14 +44,6 @@ const makeState = (params) => {
|
|
|
47
44
|
|
|
48
45
|
const sink = (out$) => {
|
|
49
46
|
out$.forEach((command) => {
|
|
50
|
-
// const { state } = command
|
|
51
|
-
/* try {
|
|
52
|
-
const newState = state
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.error('caught error', error)
|
|
55
|
-
const status = Object.assign({}, state.status, {error})
|
|
56
|
-
state = Object.assign({}, state, {status})
|
|
57
|
-
} */
|
|
58
47
|
commandResponses.callback(command)
|
|
59
48
|
})
|
|
60
49
|
}
|
package/src/ui/flow/design.js
CHANGED
|
@@ -79,7 +79,6 @@ const reducers = {
|
|
|
79
79
|
* @returns {Object} the updated state
|
|
80
80
|
*/
|
|
81
81
|
resetDesign: (state, origin) => {
|
|
82
|
-
// console.log('design: reset', origin)
|
|
83
82
|
// we reset only the given fields: mostly all except design specific things
|
|
84
83
|
const fieldsToReset = [
|
|
85
84
|
'name', 'path', 'mainPath', 'origin', 'filesAndFolders',
|
|
@@ -101,7 +100,6 @@ const reducers = {
|
|
|
101
100
|
* @returns {Object} the updated state
|
|
102
101
|
*/
|
|
103
102
|
setDesignContent: (state, payload) => {
|
|
104
|
-
// console.log('design: set content', state, state.design, payload)
|
|
105
103
|
// all our available data (specific to web)
|
|
106
104
|
const { filesAndFolders } = payload
|
|
107
105
|
const fakeFs = makeFakeFs(filesAndFolders)
|
|
@@ -109,7 +107,6 @@ const reducers = {
|
|
|
109
107
|
const mainPath = getDesignEntryPoint(fakeFs, rootPath)
|
|
110
108
|
const designName = getDesignName(fakeFs, rootPath)
|
|
111
109
|
const designPath = path.dirname(rootPath)
|
|
112
|
-
// console.log('BLAA', rootPath, designName, designPath)
|
|
113
110
|
|
|
114
111
|
let design = state.design
|
|
115
112
|
// to track computation time
|
|
@@ -142,7 +139,6 @@ const reducers = {
|
|
|
142
139
|
* @returns {Object} the updated state
|
|
143
140
|
*/
|
|
144
141
|
setDesignSolids: (state, { solids, lookup, lookupCounts }) => {
|
|
145
|
-
// console.log('design: set solids', lookup, lookupCounts)
|
|
146
142
|
solids = solids || []
|
|
147
143
|
lookup = lookup || {}
|
|
148
144
|
lookupCounts = lookupCounts || {}
|
|
@@ -182,7 +178,6 @@ const reducers = {
|
|
|
182
178
|
},
|
|
183
179
|
|
|
184
180
|
setDesignParameterDefinitions: (state, data) => {
|
|
185
|
-
// console.log('design: set parameter definitions & defaults', data)
|
|
186
181
|
const parameterDefaults = data.parameterDefaults || state.design.parameterDefaults
|
|
187
182
|
const parameterDefinitions = data.parameterDefinitions || state.design.parameterDefinitions
|
|
188
183
|
const design = Object.assign({}, state.design, {
|
|
@@ -201,7 +196,6 @@ const reducers = {
|
|
|
201
196
|
* @returns {Object} the updated state
|
|
202
197
|
*/
|
|
203
198
|
setDesignParameterValues: (state, data) => {
|
|
204
|
-
// console.log('setDesignParameterValues',state,data)
|
|
205
199
|
let parameterValues = data.parameterValues
|
|
206
200
|
// one of many ways of filtering out data from instantUpdates
|
|
207
201
|
if (data.origin === 'instantUpdate' && !state.design.instantUpdate) {
|
|
@@ -227,7 +221,6 @@ const reducers = {
|
|
|
227
221
|
},
|
|
228
222
|
|
|
229
223
|
setSettings: (state, { data }) => {
|
|
230
|
-
// console.log('design: set settings', state.design, data)
|
|
231
224
|
const {
|
|
232
225
|
vtreeMode,
|
|
233
226
|
autoReload,
|
|
@@ -258,7 +251,6 @@ const reducers = {
|
|
|
258
251
|
},
|
|
259
252
|
|
|
260
253
|
requestWriteCachedGeometry: ({ design }, cache) => {
|
|
261
|
-
// console.log('requestWriteCachedGeometry', cache)
|
|
262
254
|
const data = {}
|
|
263
255
|
Object.keys(cache).forEach((key) => {
|
|
264
256
|
data[key] = cache[key]
|
|
@@ -278,7 +270,6 @@ const reducers = {
|
|
|
278
270
|
if (!previousState.design) {
|
|
279
271
|
return false
|
|
280
272
|
}
|
|
281
|
-
// console.log('isDesignTheSame', previousState.design, state.design)
|
|
282
273
|
const current = JSON.stringify(keep(designEqualityFields, state.design))
|
|
283
274
|
const previous = JSON.stringify(keep(designEqualityFields, previousState.design))
|
|
284
275
|
return previous === current
|
|
@@ -344,16 +335,10 @@ const actions = ({ sources }) => {
|
|
|
344
335
|
.multicast()
|
|
345
336
|
|
|
346
337
|
const requestLoadDesignContent$ = most.mergeArray([
|
|
347
|
-
// load previously loaded remote file (or example)
|
|
348
|
-
/* sources.store
|
|
349
|
-
.filter(reply => reply.key === 'design' && reply.type === 'read' && reply.data !== undefined && reply.data.origin === 'http')
|
|
350
|
-
.map(({ data }) => data.mainPath), */
|
|
351
|
-
|
|
352
338
|
// load files from drag & drop (file or folder)
|
|
353
339
|
sources.drops
|
|
354
340
|
.filter((d) => d.type === 'fileOrFolder')
|
|
355
341
|
.tap((x) => console.log('dropped file', x))
|
|
356
|
-
// url, text, "fileOrFolder"
|
|
357
342
|
.map(({ data }) => ({ sink: 'fs', data, path: 'realFs', urls: [] })),
|
|
358
343
|
|
|
359
344
|
// load remote file from drag & drop (url)
|
|
@@ -367,8 +352,7 @@ const actions = ({ sources }) => {
|
|
|
367
352
|
const urls = url ? [url] : []
|
|
368
353
|
const { protocol, pathname } = urlData
|
|
369
354
|
return { sink: protocol.replace(':', ''), urls, origin, path: pathname, proxy: true }
|
|
370
|
-
})
|
|
371
|
-
.tap((x) => console.log('load url', x)),
|
|
355
|
+
}),
|
|
372
356
|
|
|
373
357
|
// load example from click
|
|
374
358
|
sources.dom.select('.example').events('click')
|
|
@@ -416,9 +400,8 @@ const actions = ({ sources }) => {
|
|
|
416
400
|
})
|
|
417
401
|
])
|
|
418
402
|
.filter((x) => x !== undefined)
|
|
419
|
-
.thru(holdUntil(setDesignSettings$))// only after FIXME : this does not seem to work
|
|
403
|
+
.thru(holdUntil(setDesignSettings$)) // only after FIXME : this does not seem to work
|
|
420
404
|
.map((data) => ({ type: 'read', id: 'loadRemote', urls: data.urls, sink: data.sink, origin: data.origin, path: data.path, data: data.data, proxy: data.proxy }))
|
|
421
|
-
.tap((x) => console.log('load remote', x))
|
|
422
405
|
.multicast()
|
|
423
406
|
.skipRepeats()
|
|
424
407
|
|
|
@@ -431,7 +414,6 @@ const actions = ({ sources }) => {
|
|
|
431
414
|
.map(({ data }) => ({ filesAndFolders: data }))
|
|
432
415
|
.thru(withLatestFrom(reducers.setDesignContent, sources.state))
|
|
433
416
|
.map((data) => ({ type: 'setDesignContent', state: data, sink: 'state' }))
|
|
434
|
-
// .tap((x) => console.log(x))
|
|
435
417
|
.multicast()
|
|
436
418
|
|
|
437
419
|
const requestWatchDesign$ = most.mergeArray([
|
|
@@ -450,7 +432,6 @@ const actions = ({ sources }) => {
|
|
|
450
432
|
.skipRepeatsWith(jsonCompare)
|
|
451
433
|
])
|
|
452
434
|
.map((payload) => Object.assign({}, { type: 'watch', sink: payload.origin }, payload))
|
|
453
|
-
.tap((x) => console.log('watch', x))
|
|
454
435
|
.multicast()
|
|
455
436
|
|
|
456
437
|
const requestWriteCachedGeometry$ = most.mergeArray([
|
|
@@ -471,21 +452,19 @@ const actions = ({ sources }) => {
|
|
|
471
452
|
// .thru(holdUntil(setDesignSettings$))// only after FIXME : this does not seem to work
|
|
472
453
|
.thru(withLatestFrom(reducers.resetDesign, sources.state))
|
|
473
454
|
.map((data) => ({ type: 'resetDesign', state: data, sink: 'state' }))
|
|
474
|
-
// .tap((x) => console.log('design reset', x))
|
|
475
455
|
.multicast()
|
|
476
456
|
|
|
477
457
|
const setDesignSolids$ = most.mergeArray([
|
|
478
458
|
sources.solidWorker
|
|
479
459
|
.filter((event) => !('error' in event) && event.data instanceof Object && event.data.type === 'solids')
|
|
480
460
|
.map((event) => {
|
|
481
|
-
|
|
482
|
-
|
|
461
|
+
const { lookupCounts, lookup, solids } = event.data
|
|
462
|
+
return { solids, lookup, lookupCounts }
|
|
483
463
|
})
|
|
484
|
-
|
|
464
|
+
.multicast(),
|
|
485
465
|
sources.fs
|
|
486
466
|
.filter((res) => res.type === 'read' && res.id === 'loadCachedGeometry' && res.data)
|
|
487
467
|
.map((raw) => {
|
|
488
|
-
console.log('loading cached ')
|
|
489
468
|
const deserialize = () => {}
|
|
490
469
|
const lookup = deserialize(raw.data)
|
|
491
470
|
return { solids: undefined, lookupCounts: undefined, lookup }
|
package/src/ui/flow/dom.js
CHANGED
|
@@ -2,7 +2,6 @@ const makeOutput = ({ sources, extras }) => sources.state
|
|
|
2
2
|
.filter((state) => state.design && state.languages && state.viewer)
|
|
3
3
|
// TODO: add omiting of a few complex fields like the cache , the filetree, the solids
|
|
4
4
|
.skipRepeatsWith((state, previousState) => JSON.stringify(state) === JSON.stringify(previousState))
|
|
5
|
-
// .tap(state => console.log('state', state))
|
|
6
5
|
.combine((state, i18n) => require('../views/main')(state, i18n, extras.paramsCallbacktoStream, extras.editorCallbackToStream),
|
|
7
6
|
sources.i18n.filter((x) => x.type === 'changeSettings').map((x) => x.data))
|
|
8
7
|
|