@jscad/web 2.5.2 → 2.5.5

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/data/themes.js +40 -40
  3. package/dist/jscad-web.min.js +1263 -1266
  4. package/examples/CHANGELOG.md +8 -0
  5. package/examples/core/colors/basicColors.js +0 -1
  6. package/examples/core/colors/colorCube.js +10 -12
  7. package/examples/core/curves/bezier/extrudeAlongPath.js +20 -22
  8. package/examples/core/curves/bezier/simpleExtrude.js +4 -6
  9. package/examples/core/extrusions/basicExtrusions.js +3 -3
  10. package/examples/core/hulls/hull2D.js +3 -5
  11. package/examples/core/hulls/hull3D.js +3 -5
  12. package/examples/core/measurements/measureAggregateBounds.js +5 -7
  13. package/examples/core/measurements/measureAreaAndVolume.js +6 -8
  14. package/examples/core/measurements/measureBounds.js +5 -7
  15. package/examples/core/other/orientation.js +2 -3
  16. package/examples/core/primitives/dodecahedron.js +1 -3
  17. package/examples/core/primitives/polyhedron.js +12 -14
  18. package/examples/core/primitives/primitives2D.js +1 -3
  19. package/examples/core/primitives/primitives3D.js +2 -4
  20. package/examples/core/primitives/roundedCuboid.js +7 -9
  21. package/examples/core/primitives/sphere.js +10 -12
  22. package/examples/core/primitives/torus.js +20 -22
  23. package/examples/core/text/text.js +5 -8
  24. package/examples/core/transforms/align.js +5 -7
  25. package/examples/core/transforms/center.js +6 -8
  26. package/examples/import/AMFImport/index.js +1 -3
  27. package/examples/import/STLImport/index.js +4 -6
  28. package/examples/import/SVGImport/index.js +0 -1
  29. package/examples/module-design/mountPlate.js +5 -9
  30. package/examples/module-design/subFolder/sphereShape.js +1 -3
  31. package/examples/package.json +1 -1
  32. package/examples/parameters/allParamTypes.js +19 -21
  33. package/examples/parameters/balloons.js +15 -26
  34. package/examples/parameters/gear.js +9 -11
  35. package/package.json +8 -8
  36. package/postInstall.js +3 -3
  37. package/src/index.js +0 -1
  38. package/src/most-gestures/drags.js +15 -0
  39. package/src/most-gestures/zooms.js +20 -1
  40. package/src/sideEffects/dat/index.js +0 -6
  41. package/src/sideEffects/dom/index.js +0 -2
  42. package/src/sideEffects/fileDialog/index.js +0 -2
  43. package/src/sideEffects/i18n/index.js +0 -1
  44. package/src/sideEffects/localFs/index.js +1 -4
  45. package/src/sideEffects/localFs/walkFileTree.js +1 -7
  46. package/src/sideEffects/localStorage/index.js +0 -1
  47. package/src/sideEffects/state/index.js +0 -11
  48. package/src/ui/flow/design.js +5 -26
  49. package/src/ui/flow/dom.js +0 -1
  50. package/src/ui/flow/flowOut.js +0 -24
  51. package/src/ui/flow/languages.js +0 -1
  52. package/src/ui/flow/shortcuts.js +0 -1
  53. package/src/ui/flow/themes.js +1 -1
  54. package/src/ui/flow/tools.js +0 -6
  55. package/src/ui/views/designParameters.js +9 -4
  56. package/src/ui/views/editor.js +0 -6
  57. package/src/ui/views/parameterControls.js +0 -1
  58. package/src/ui/views/status.js +4 -2
  59. package/src/ui/views/viewer.js +1 -1
  60. package/src/utils/keys.js +0 -1
  61. package/src/utils/logger.js +1 -1
  62. package/src/ui/umd.js +0 -168
@@ -2,24 +2,6 @@ const makeReactions = (inputs) => {
2
2
  const { sinks, outputs$ } = inputs
3
3
  const { store, fs, http, https, i18n, dom, solidWorker, state, dat } = sinks
4
4
 
5
- /* outputs$
6
- .filter(x => 'sink' in x && x.sink === 'dom')
7
- .forEach(x => console.log(' out to dom', x))
8
- outputs$
9
- .filter(x => 'sink' in x && x.sink === 'state')
10
- .forEach(x => console.log(' out to state', x))
11
-
12
- outputs$
13
- .filter(x => 'sink' in x && x.sink === 'i18n')
14
- .forEach(x => console.log(' out to i18n', x))
15
-
16
- outputs$
17
- .filter(x => 'sink' in x && x.sink === 'store')
18
- .forEach(x => console.log(' out to store', x))
19
- outputs$
20
- .filter(x => 'sink' in x && x.sink === 'fs')
21
- .forEach(x => console.log(' out to fs', x)) */
22
-
23
5
  // output to dom
24
6
  dom(require('./dom')(inputs))
25
7
  // output to i18n
@@ -40,12 +22,6 @@ const makeReactions = (inputs) => {
40
22
  state(outputs$.filter((x) => 'sink' in x && x.sink === 'state'))
41
23
 
42
24
  dat(outputs$.filter((x) => 'sink' in x && x.sink === 'dat'))
43
-
44
- // titlebar & store side effects
45
- // FIXME/ not compatible with multiple instances !!
46
- /* titleBar.sink(
47
- state.map(state => state.appTitle).skipRepeats()
48
- ) */
49
25
  }
50
26
 
51
27
  module.exports = makeReactions
@@ -15,7 +15,6 @@ const reducers = {
15
15
  return { languages }
16
16
  },
17
17
  setAvailableLanguages: (state, available) => {
18
- // console.log('setAvailableLanguages', available)
19
18
  const languages = Object.assign({}, state.languages, { available })
20
19
  return { languages }
21
20
  },
@@ -155,7 +155,6 @@ const actions = ({ sources }) => {
155
155
  const triggerFromShortcut$ = keyCombos$
156
156
  .thru(withLatestFrom(reducers.triggerShortcut, sources.state))
157
157
  .filter((x) => x !== undefined)
158
- // .tap(x => console.log('triggerFromShortcut', x))
159
158
 
160
159
  // this means we wait until the data here has been initialized before saving
161
160
  const requestLoadSettings$ = initialize$
@@ -14,7 +14,7 @@ const reducers = {
14
14
  },
15
15
  setTheme: (state, active) => {
16
16
  const available = require('../../../data/themes')
17
- const themeData = available[active] ? available[active] : available['light']
17
+ const themeData = available[active] ? available[active] : available.light
18
18
  const viewer = state.viewer ? merge({}, state.viewer, themeData.viewer) : themeData.viewer
19
19
  const themes = Object.assign({}, state.themes, { available, active, themeSettings: themeData })
20
20
  return { viewer, themes }
@@ -8,12 +8,6 @@ const actions = ({ sources }) => {
8
8
  sources.dom.select('#toggleEditor').events('click').map((event) => 'editor'),
9
9
  sources.dom.select('#toggleHelp').events('click').map((event) => 'help'),
10
10
  sources.dom.select('.example').events('mouseup').map((event) => undefined)
11
- /* sources.state // we changed designs
12
- .filter(state => state.design)
13
- .map(state => state.design.mainPath)
14
- .skipRepeatsWith((mainPath, previousMainPath) => mainPath !== previousMainPath)
15
- // .map(_ => undefined)
16
- .tap(x => console.log('changed design')) */
17
11
  ])
18
12
  .thru(withLatestFrom((state, tool) => {
19
13
  const activeTool = state.activeTool === tool ? undefined : tool
@@ -4,10 +4,11 @@ const { createParamControls } = require('./parameterControls')
4
4
 
5
5
  const designParameters = (state, paramsCallbacktoStream, i18n) => {
6
6
  const { parameterValues, parameterDefinitions, parameterDefaults } = state.design
7
- const { controls } = createParamControls(
8
- Object.assign({}, parameterDefaults, parameterValues), parameterDefinitions, paramsCallbacktoStream.callback
9
- )
10
- return html`
7
+ try {
8
+ const { controls } = createParamControls(
9
+ Object.assign({}, parameterDefaults, parameterValues), parameterDefinitions, paramsCallbacktoStream.callback
10
+ )
11
+ return html`
11
12
  <section id='params' style='visibility:${state.design.parameterDefinitions.length === 0 ? 'hidden' : 'visible'};color:${state.themes.themeSettings.secondaryTextColor}'>
12
13
  <span id='paramsTable'>
13
14
  <table>
@@ -22,6 +23,10 @@ const designParameters = (state, paramsCallbacktoStream, i18n) => {
22
23
  </span>
23
24
  </section>
24
25
  `
26
+ } catch (e) {
27
+ e.stack = undefined // remove unhelpful stacktrace
28
+ state.status.error = e
29
+ }
25
30
  }
26
31
 
27
32
  module.exports = designParameters
@@ -26,10 +26,8 @@ const openscadOpenJscadParser = require('@jscad/openscad-openjscad-translator')
26
26
  const setUpEditor = (element, gProcessor) => {
27
27
  const langTools = ace.acequire('ace/ext/language_tools')
28
28
 
29
- console.log('langTools', langTools)
30
29
  const flowCompleter = {
31
30
  getCompletions: (editor, session, pos, prefix, callback) => {
32
- console.log('getCompletions')
33
31
  // your code
34
32
  }
35
33
  }
@@ -93,7 +91,6 @@ const setUpEditor = (element, gProcessor) => {
93
91
  document.body.addEventListener('keydown', (evt) => {
94
92
  if (evt.key === 'F5') {
95
93
  evt.preventDefault()
96
- // console.log('no accidental reloading!')
97
94
  runExec(gEditor)
98
95
  }
99
96
  })
@@ -184,12 +181,9 @@ const editorWrapper = (state, editorCallbackToStream) => {
184
181
  // editor.resize(true)
185
182
  // editor.renderer.updateFull()
186
183
  /* ace.config.loadModule('ace/snippets/javascript', function (ba) {
187
- console.log('boo', ba)
188
184
  })
189
185
  ace.config.loadModule('ace/ext/language_tools', function () {
190
- console.log('gna')
191
186
  const bla = require('brace/snippets/javascript')
192
- console.log('foo', bla)
193
187
  editor.insertSnippet(bli);
194
188
  }) */
195
189
  editor.setOptions({
@@ -245,7 +245,6 @@ const createRadioControl = (definition, prevValue) => {
245
245
  * @returns {[*]}
246
246
  */
247
247
  const createInputControl = (definition, prevValue) => {
248
- // console.log('parameterControls.createInputControl')
249
248
  const controlList = [
250
249
  { type: 'text', control: 'text', required: ['type', 'name'], initial: '' },
251
250
  { type: 'int', control: 'number', required: ['type', 'name'], initial: 0 },
@@ -7,7 +7,8 @@ const status = (state, paramsCallbacktoStream) => {
7
7
  const errorLine = status.error !== undefined && status.error.lineno ? `Line: ${status.error.lineno}` : ''
8
8
  const errorStack = status.error !== undefined && status.error.stack ? `Stack: ${status.error.stack}` : ''
9
9
 
10
- const statusMessage = status.error !== undefined ? html`<span>
10
+ const statusMessage = status.error !== undefined
11
+ ? html`<span>
11
12
  <div>
12
13
  ERROR:
13
14
  </div>
@@ -20,7 +21,8 @@ const status = (state, paramsCallbacktoStream) => {
20
21
  <div>
21
22
  ${errorStack}
22
23
  </div>
23
- </span>` : ''
24
+ </span>`
25
+ : ''
24
26
 
25
27
  // ? `Error: ${status.error.message} line: ${status.error.lineno}, filename:${status.error.filename} stack: ${status.error.stack}` : ''
26
28
  // ${statusMessage}
@@ -143,7 +143,7 @@ const viewer = (state, i18n) => {
143
143
  } else {
144
144
  // only generate entities when the solids change
145
145
  // themes, options, etc also change the viewer state
146
- const solids = state.design.solids
146
+ const solids = state.design.solids.filter((solid) => solid && (solid instanceof Object))
147
147
  if (prevSolids) {
148
148
  const theme = state.themes.themeSettings.viewer
149
149
  const color = theme.rendering.meshColor
package/src/utils/keys.js CHANGED
@@ -50,7 +50,6 @@ const getKeyCombos = (options, keyUps$, keyDown$) => {
50
50
  }, [])
51
51
  .filter((x) => x !== undefined)
52
52
  .filter((x) => x.event !== undefined)
53
- // .tap(x => console.log('key stuff', x))
54
53
  .multicast()
55
54
 
56
55
  return keyCombos$
@@ -18,7 +18,7 @@ const makeLogger = (params) => {
18
18
 
19
19
  const warning = (...params) => {
20
20
  if (enabled) {
21
- console.warning(...params)
21
+ console.warn(...params)
22
22
  }
23
23
  }
24
24
  const error = (...params) => {
package/src/ui/umd.js DELETED
@@ -1,168 +0,0 @@
1
- /**
2
- * @prettier
3
- */
4
- // == OpenJSCAD.org, Copyright (c) 2017, Licensed under MIT License
5
- const AlertUserOfUncaughtExceptions = require('./errorDispatcher')
6
-
7
- const version = require('../../package.json').version
8
- const Processor = require('../jscad/processor-bare')
9
-
10
- let gProcessor = null
11
-
12
- /**
13
- * Initialize a jscad viewer. You can prevent the processor from creating
14
- * a new `canvas` element by passing a canvas element on `glOptions`.
15
- *
16
- * If the viewer element has a `design-url` attribute, that url will be loaded
17
- * with a `XMLHttpRequest`. Otherwise load the design using `setJsCad`.
18
- *
19
- * @param {Object} viewer - A DOM element to use as the base element.
20
- * @param {JscadViewerOptions} options - options passed to the viewer processor
21
- */
22
- const init = (viewer, options) => {
23
- const versionText = 'UMD OpenJSCAD.org Version ' + version
24
- console.log('umd init', versionText, options)
25
-
26
- // Show all exceptions to the user: // WARNING !! this is not practical at dev time
27
- AlertUserOfUncaughtExceptions()
28
-
29
- const design = viewer.getAttribute('design-url')
30
-
31
- gProcessor = new Processor(viewer, options)
32
-
33
- // load the given design
34
- if (design) {
35
- const xhr = new XMLHttpRequest()
36
- xhr.open('GET', design, true)
37
- gProcessor.setStatus('Loading ' + design)
38
-
39
- xhr.onload = function () {
40
- const source = this.responseText
41
-
42
- if (design.match(/\.jscad$/i) || design.match(/\.js$/i)) {
43
- gProcessor.setStatus('Processing ' + design)
44
- gProcessor.setJsCad(source, design)
45
- }
46
- }
47
- xhr.send()
48
- }
49
-
50
- return {
51
- /**
52
- * Start the processor on generating an output file. Once
53
- * the file has been created, the `
54
- * @param {FormatInfo} format
55
- */
56
- generateOutputFile: function (format) {
57
- return gProcessor.generateOutputFile(format)
58
- },
59
-
60
- clearOutputFile: function () {
61
- return gProcessor.clearOutputFile()
62
- },
63
-
64
- resetCamera () {
65
- return gProcessor.viewer.resetCamera()
66
- },
67
-
68
- abort () {
69
- return gProcessor.abort()
70
- },
71
-
72
- setJsCad (source, design) {
73
- gProcessor.setJsCad(source, design)
74
- },
75
-
76
- rebuildSolids () {
77
- gProcessor.rebuildSolids()
78
- }
79
- }
80
- }
81
-
82
- module.exports = init
83
-
84
- /**
85
- * @typedef {Object} XYZCoord
86
- * @property {number} x
87
- * @property {number} y
88
- * @property {number} z
89
- */
90
-
91
- /**
92
- * @typedef {Object} MinMax
93
- * @property {number} min
94
- * @property {number} max
95
- */
96
-
97
- /**
98
- * Camera settings
99
- * @typedef {Object} CameraSettings
100
- * @property {number} fov - field of view.
101
- * @property {XYZCoord} angle - view angle about XYZ axis.
102
- * @property {XYZCoord} position - initial position at XYZ.
103
- * @property {MinMax} clip - rendering outside this range is clipped.
104
- */
105
-
106
- /**
107
- * @typedef {Object} RgbaColor
108
- * @property {number} r - red (values 0.0 - 1.0).
109
- * @property {number} g - green (values 0.0 - 1.0).
110
- * @property {number} b - blue (values 0.0 - 1.0).
111
- * @property {number} a - alpha (values 0.0 - 1.0).
112
- */
113
-
114
- /**
115
- * Grid settings
116
- * @typedef {Object} GridSettings
117
- * @property {number} i - number of units between grid lines.
118
- * @property {RgbaColor} color - color.
119
- */
120
-
121
- /**
122
- * @typedef {Object} PlateSettings
123
- * @property {boolean} draw draw or not (default: true).
124
- * @property {number} size plate size (X and Y) (default: 200).
125
- * @property {GridSettings} m minor grid settings.
126
- * @property {GridSettings} M major grid settings.
127
- */
128
-
129
- /**
130
- *
131
- * @typedef {Object} PosNegColor
132
- * @property {RgbaColor} neg color in negative direction.
133
- * @property {RgbaColor} pos color in positive direction.
134
- */
135
-
136
- /**
137
- * @typedef {Object} AxisSettings
138
- * @property {boolean} draw - draw or not (default: false).
139
- * @property {PosNegColor} x
140
- * @property {PosNegColor} y
141
- * @property {PosNegColor} z
142
- */
143
-
144
- /**
145
- * @typedef {Object} LightGLOptions
146
- * @property {Object} canvas - Uses the HTML canvas given in 'options' or creates a new one if necessary.
147
- * @property {number} width - width applied to the canvas created when `options.canvas` is not set. (default: 800).
148
- * @property {number} height - height applied to the canvas created when `options.canvas` is not set. (default: 600).
149
- * @property {number} alpha - The alpha channel is disabled by default because it usually causes unintended transparencies in the canvas.
150
- *
151
- */
152
-
153
- /**
154
- * @typedef {Object} JscadViewerOptions
155
- * @property {PlateSettings} plate - The grid show in the viewer.
156
- * @property {CameraSettings} camera
157
- * @property {AxisSettings} axis
158
- * @property {LightGLOptions} glOptions - Options sent to `GL.create()`.
159
- * @property {Object} processor - options used by the viewer processor.
160
- */
161
-
162
- /**
163
- * @typedef {Object} ProcessorOptions
164
- * @property {Element} viewerContext - The main element that jscad uses. If no canvas element is set, jscad creates one.
165
- * @property {Element} viewerdiv - Jscad moves the canvas tag here, or creates one and places it here.
166
- * @property {Element} parameterstable - A Table element reference. The design parameters will be added here.
167
- * @property {Element} viewerCanvas - A Canvas element reference that will be used to draw the GL canvas.
168
- */