@jseeio/jsee 0.4.1 → 0.8.0

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 (60) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/LICENSE +21 -0
  3. package/README.md +583 -55
  4. package/dist/2b3e1faf89f94a483539.png +0 -0
  5. package/dist/416d91365b44e4b4f477.png +0 -0
  6. package/dist/8f2c4d11474275fbc161.png +0 -0
  7. package/dist/jsee.core.js +1 -0
  8. package/dist/jsee.full.js +1 -0
  9. package/dist/jsee.runtime.js +2 -1
  10. package/package.json +84 -18
  11. package/src/app.js +130 -33
  12. package/src/cli.js +474 -64
  13. package/src/extended-imports.js +11 -0
  14. package/src/main.js +264 -45
  15. package/src/overlay.js +26 -1
  16. package/src/utils.js +390 -12
  17. package/templates/common-inputs.js +88 -0
  18. package/templates/common-outputs.js +340 -4
  19. package/templates/minimal-app.vue +367 -0
  20. package/templates/minimal-input.vue +573 -0
  21. package/templates/minimal-output.vue +426 -0
  22. package/templates/virtual-table.vue +194 -0
  23. package/.claude/settings.local.json +0 -13
  24. package/.eslintrc.js +0 -38
  25. package/AGENTS.md +0 -65
  26. package/CLAUDE.md +0 -5
  27. package/CNAME +0 -1
  28. package/_config.yml +0 -26
  29. package/dist/jsee.js +0 -1
  30. package/jest-puppeteer.config.js +0 -14
  31. package/jest.config.js +0 -8
  32. package/jest.unit.config.js +0 -8
  33. package/load/index.html +0 -52
  34. package/templates/bulma-app.vue +0 -242
  35. package/templates/bulma-input.vue +0 -125
  36. package/templates/bulma-output.vue +0 -101
  37. package/test/class.html +0 -22
  38. package/test/code.html +0 -25
  39. package/test/codew.html +0 -25
  40. package/test/example-class.js +0 -8
  41. package/test/example-sum.js +0 -3
  42. package/test/fixtures/lodash-like.js +0 -15
  43. package/test/fixtures/upload-sample.csv +0 -3
  44. package/test/importw.html +0 -28
  45. package/test/minimal.html +0 -14
  46. package/test/minimal1.html +0 -13
  47. package/test/minimal2.html +0 -15
  48. package/test/minimal3.html +0 -10
  49. package/test/minimal4.html +0 -22
  50. package/test/pipeline.html +0 -52
  51. package/test/python.html +0 -41
  52. package/test/string.html +0 -26
  53. package/test/stringw.html +0 -29
  54. package/test/sum.schema.json +0 -17
  55. package/test/sumw.schema.json +0 -15
  56. package/test/test-basic.test.js +0 -603
  57. package/test/test-python.test.js +0 -23
  58. package/test/unit/cli-fetch.test.js +0 -229
  59. package/test/unit/utils.test.js +0 -888
  60. package/webpack.config.js +0 -101
@@ -1,229 +0,0 @@
1
- const fs = require('fs')
2
- const os = require('os')
3
- const path = require('path')
4
- const gen = require('../../src/cli')
5
- const { collectFetchBundleBlocks, resolveLocalImportFile, resolveFetchImport, resolveRuntimeMode } = gen
6
-
7
- describe('collectFetchBundleBlocks', () => {
8
- test('collects model, view and render blocks', () => {
9
- const schema = {
10
- model: { name: 'model', url: './model.js' },
11
- view: { name: 'view', url: './view.js' },
12
- render: { name: 'render', url: './render.js' }
13
- }
14
-
15
- const blocks = collectFetchBundleBlocks(schema)
16
-
17
- expect(blocks.map(b => b.name)).toEqual(['model', 'view', 'render'])
18
- })
19
-
20
- test('supports arrays and skips missing sections', () => {
21
- const schema = {
22
- model: [
23
- { name: 'm1', url: './m1.js' },
24
- { name: 'm2', url: './m2.js' }
25
- ],
26
- view: [{ name: 'v1', url: './v1.js' }]
27
- }
28
-
29
- const blocks = collectFetchBundleBlocks(schema)
30
-
31
- expect(blocks.map(b => b.name)).toEqual(['m1', 'm2', 'v1'])
32
- })
33
- })
34
-
35
- describe('resolveLocalImportFile', () => {
36
- let tmpDir
37
-
38
- beforeEach(() => {
39
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsee-resolve-'))
40
- // Create a project layout:
41
- // dist/a.js
42
- // css/x.css
43
- // src/model.js
44
- // src/helper.js
45
- fs.mkdirSync(path.join(tmpDir, 'dist'))
46
- fs.mkdirSync(path.join(tmpDir, 'css'))
47
- fs.mkdirSync(path.join(tmpDir, 'src'))
48
- fs.writeFileSync(path.join(tmpDir, 'dist', 'a.js'), '// a')
49
- fs.writeFileSync(path.join(tmpDir, 'css', 'x.css'), '/* x */')
50
- fs.writeFileSync(path.join(tmpDir, 'src', 'model.js'), '// model')
51
- fs.writeFileSync(path.join(tmpDir, 'src', 'helper.js'), '// helper')
52
- })
53
-
54
- afterEach(() => {
55
- fs.rmSync(tmpDir, { recursive: true, force: true })
56
- })
57
-
58
- test('resolves bare-relative JS path from cwd', () => {
59
- const result = resolveLocalImportFile('dist/a.js', 'src/model.js', tmpDir)
60
- expect(result).toBe(path.join(tmpDir, 'dist', 'a.js'))
61
- })
62
-
63
- test('resolves bare-relative CSS path from cwd', () => {
64
- const result = resolveLocalImportFile('css/x.css', 'src/model.js', tmpDir)
65
- expect(result).toBe(path.join(tmpDir, 'css', 'x.css'))
66
- })
67
-
68
- test('resolves explicit-relative path against model directory', () => {
69
- const result = resolveLocalImportFile('./helper.js', 'src/model.js', tmpDir)
70
- expect(result).toBe(path.join(tmpDir, 'src', 'helper.js'))
71
- })
72
-
73
- test('returns null for nonexistent file', () => {
74
- const result = resolveLocalImportFile('dist/nope.js', 'src/model.js', tmpDir)
75
- expect(result).toBeNull()
76
- })
77
-
78
- test('returns null for HTTP URLs', () => {
79
- const result = resolveLocalImportFile('https://cdn.example.com/lib.js', 'src/model.js', tmpDir)
80
- expect(result).toBeNull()
81
- })
82
-
83
- test('returns null for npm package names', () => {
84
- const result = resolveLocalImportFile('lodash', 'src/model.js', tmpDir)
85
- expect(result).toBeNull()
86
- })
87
- })
88
-
89
- describe('resolveFetchImport', () => {
90
- let tmpDir
91
-
92
- beforeEach(() => {
93
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsee-resolve-'))
94
- fs.mkdirSync(path.join(tmpDir, 'dist'))
95
- fs.mkdirSync(path.join(tmpDir, 'css'))
96
- fs.mkdirSync(path.join(tmpDir, 'src'))
97
- fs.writeFileSync(path.join(tmpDir, 'dist', 'core.js'), '// core')
98
- fs.writeFileSync(path.join(tmpDir, 'css', 'app.css'), '/* app */')
99
- fs.writeFileSync(path.join(tmpDir, 'src', 'model.js'), '// model')
100
- fs.writeFileSync(path.join(tmpDir, 'src', 'helper.js'), '// helper')
101
- })
102
-
103
- afterEach(() => {
104
- fs.rmSync(tmpDir, { recursive: true, force: true })
105
- })
106
-
107
- test('resolves bare-relative local JS with raw importUrl', () => {
108
- const result = resolveFetchImport('dist/core.js', 'src/model.js', tmpDir)
109
-
110
- expect(result.schemaImport).toBe('dist/core.js')
111
- expect(result.importUrl).toBe('dist/core.js')
112
- expect(result.localFilePath).toBe(path.join(tmpDir, 'dist', 'core.js'))
113
- expect(result.remoteUrl).toBeNull()
114
- })
115
-
116
- test('resolves bare-relative local CSS with raw importUrl', () => {
117
- const result = resolveFetchImport('css/app.css', 'src/model.js', tmpDir)
118
-
119
- expect(result.schemaImport).toBe('css/app.css')
120
- expect(result.importUrl).toBe('css/app.css')
121
- expect(result.localFilePath).toBe(path.join(tmpDir, 'css', 'app.css'))
122
- expect(result.remoteUrl).toBeNull()
123
- })
124
-
125
- test('resolves explicit-relative local import against model dir', () => {
126
- const result = resolveFetchImport('./helper.js', 'src/model.js', tmpDir)
127
-
128
- expect(result.schemaImport).toBe('./helper.js')
129
- expect(result.importUrl).toBe('./helper.js')
130
- expect(result.localFilePath).toBe(path.join(tmpDir, 'src', 'helper.js'))
131
- expect(result.remoteUrl).toBeNull()
132
- })
133
-
134
- test('keeps package imports as remote URLs', () => {
135
- const result = resolveFetchImport('chart.js', 'src/model.js', tmpDir)
136
-
137
- expect(result.schemaImport).toBe('chart.js')
138
- expect(result.importUrl).toBe('https://cdn.jsdelivr.net/npm/chart.js')
139
- expect(result.localFilePath).toBeNull()
140
- expect(result.remoteUrl).toBe('https://cdn.jsdelivr.net/npm/chart.js')
141
- })
142
-
143
- test('keeps remote HTTP URLs unchanged', () => {
144
- const result = resolveFetchImport('https://cdn.example.com/lib.css', 'model.js', tmpDir)
145
- expect(result.remoteUrl).toBe('https://cdn.example.com/lib.css')
146
- expect(result.localFilePath).toBeNull()
147
- })
148
-
149
- test('supports object imports and preserves extra fields', () => {
150
- const result = resolveFetchImport(
151
- { url: './helper.js', integrity: 'sha-123' },
152
- 'src/model.js',
153
- tmpDir
154
- )
155
-
156
- expect(result.schemaEntry).toEqual({
157
- url: './helper.js',
158
- integrity: 'sha-123'
159
- })
160
- expect(result.importUrl).toBe('./helper.js')
161
- expect(result.localFilePath).toBe(path.join(tmpDir, 'src', 'helper.js'))
162
- expect(result.remoteUrl).toBeNull()
163
- })
164
-
165
- test('nonexistent file falls through to remote/CDN', () => {
166
- const result = resolveFetchImport('dist/nope.js', 'src/model.js', tmpDir)
167
-
168
- expect(result.localFilePath).toBeNull()
169
- expect(result.remoteUrl).toBe('https://cdn.jsdelivr.net/npm/dist/nope.js')
170
- })
171
- })
172
-
173
- describe('resolveRuntimeMode', () => {
174
- test('defaults to cdn for generated output when fetch is disabled', () => {
175
- expect(resolveRuntimeMode('auto', false, true)).toBe('cdn')
176
- })
177
-
178
- test('defaults to local for served apps when fetch is disabled', () => {
179
- expect(resolveRuntimeMode('auto', false, false)).toBe('local')
180
- })
181
-
182
- test('uses inline mode when fetch is enabled', () => {
183
- expect(resolveRuntimeMode('auto', true, true)).toBe('inline')
184
- })
185
-
186
- test('honors explicit runtime mode', () => {
187
- expect(resolveRuntimeMode('local', true, true)).toBe('local')
188
- expect(resolveRuntimeMode('inline', false, false)).toBe('inline')
189
- })
190
-
191
- test('passes through custom URL/path as runtime mode', () => {
192
- expect(resolveRuntimeMode('./dist/jsee.js', false, false)).toBe('./dist/jsee.js')
193
- expect(resolveRuntimeMode('https://example.com/jsee.js', false, true)).toBe('https://example.com/jsee.js')
194
- expect(resolveRuntimeMode('./node_modules/@jseeio/jsee/dist/jsee.js', true, true)).toBe('./node_modules/@jseeio/jsee/dist/jsee.js')
195
- })
196
- })
197
-
198
- describe('output writes', () => {
199
- test('writes absolute output paths and keeps json output intact', async () => {
200
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsee-cli-output-'))
201
- const schemaPath = path.join(tmpDir, 'schema.json')
202
- const jsonOutputPath = path.join(tmpDir, 'result.json')
203
- const htmlOutputPath = path.join(tmpDir, 'result.html')
204
-
205
- fs.writeFileSync(schemaPath, JSON.stringify({
206
- model: [
207
- {
208
- name: 'demo',
209
- type: 'function',
210
- code: 'function demo () { return 1 }'
211
- }
212
- ],
213
- inputs: [],
214
- outputs: []
215
- }, null, 2))
216
-
217
- try {
218
- await gen(['--inputs', schemaPath, '--outputs', `${jsonOutputPath},${htmlOutputPath}`])
219
-
220
- const jsonContent = fs.readFileSync(jsonOutputPath, 'utf8')
221
- const htmlContent = fs.readFileSync(htmlOutputPath, 'utf8')
222
-
223
- expect(() => JSON.parse(jsonContent)).not.toThrow()
224
- expect(htmlContent).toContain('<!DOCTYPE html>')
225
- } finally {
226
- fs.rmSync(tmpDir, { recursive: true, force: true })
227
- }
228
- })
229
- })