create-oc 1.1.29 → 1.1.31
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/index.js +49 -0
- package/package.json +1 -1
- package/templates/elm/package.json +2 -2
- package/templates/elm/tsconfig.json +1 -1
- package/templates/es6/package.json +2 -2
- package/templates/es6/src/view.ts +1 -2
- package/templates/es6/tsconfig.json +1 -1
- package/templates/esm.react/package.json +2 -2
- package/templates/esm.react/src/App.tsx +5 -1
- package/templates/esm.react/src/entry.client.tsx +14 -12
- package/templates/esm.react/vite.config.ts +5 -12
- package/templates/esm.remix/package.json +2 -2
- package/templates/esm.remix/src/App.tsx +5 -1
- package/templates/esm.remix/src/entry.client.tsx +11 -9
- package/templates/esm.remix/vite.config.ts +0 -11
- package/templates/preact/package.json +2 -2
- package/templates/preact/src/App.tsx +5 -1
- package/templates/preact/tsconfig.json +1 -1
- package/templates/react/package.json +2 -2
- package/templates/react/src/App.tsx +5 -1
- package/templates/react/tsconfig.json +1 -1
- package/templates/solid/package.json +2 -2
- package/templates/solid/src/App.tsx +6 -2
- package/templates/solid/tsconfig.json +1 -1
- package/templates/svelte/package.json +2 -2
- package/templates/svelte/src/App.svelte +1 -1
- package/templates/vue/package.json +2 -2
- package/templates/vue/tsconfig.json +1 -1
package/index.js
CHANGED
|
@@ -16,6 +16,31 @@ function checkNodeVersion() {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
function createOcJson(cwd, importmap) {
|
|
20
|
+
let oc = {};
|
|
21
|
+
try {
|
|
22
|
+
oc = fs.readFileSync(path.join(cwd, 'oc.json'), 'utf-8');
|
|
23
|
+
} catch {}
|
|
24
|
+
|
|
25
|
+
if (!oc.$schema) {
|
|
26
|
+
oc.$schema = 'https://opencomponents.github.io/schema.json';
|
|
27
|
+
}
|
|
28
|
+
oc.importmap = oc.importmap?.imports
|
|
29
|
+
? {
|
|
30
|
+
imports: {
|
|
31
|
+
...oc.importmap.imports,
|
|
32
|
+
...importmap,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
: importmap;
|
|
36
|
+
|
|
37
|
+
fs.writeFileSync(
|
|
38
|
+
path.join(cwd, 'oc.json'),
|
|
39
|
+
JSON.stringify(oc, null, 2),
|
|
40
|
+
'utf-8'
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
19
44
|
checkNodeVersion();
|
|
20
45
|
|
|
21
46
|
const templateChoices = [
|
|
@@ -132,6 +157,30 @@ replaceJson(`./${componentName}/package.json`, (pkg) => ({
|
|
|
132
157
|
},
|
|
133
158
|
}));
|
|
134
159
|
|
|
160
|
+
const imports = (() => {
|
|
161
|
+
switch (template) {
|
|
162
|
+
case 'esm.react':
|
|
163
|
+
return {
|
|
164
|
+
react: 'https://esm.sh/react@19.1.0',
|
|
165
|
+
'react-dom': 'https://esm.sh/react-dom@19.1.0',
|
|
166
|
+
'react-dom/': 'https://esm.sh/react-dom@19.1.0/',
|
|
167
|
+
};
|
|
168
|
+
case 'esm.remix':
|
|
169
|
+
return {
|
|
170
|
+
'@remix-run/dom':
|
|
171
|
+
'https://esm.sh/@remix-run/dom@0.0.0-experimental-remix-jam.6',
|
|
172
|
+
'@remix-run/events':
|
|
173
|
+
'https://esm.sh/@remix-run/events@0.0.0-experimental-remix-jam.5',
|
|
174
|
+
'@remix-run/events/':
|
|
175
|
+
'https://esm.sh/@remix-run/events@0.0.0-experimental-remix-jam.5/',
|
|
176
|
+
};
|
|
177
|
+
default:
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
})();
|
|
181
|
+
|
|
182
|
+
createOcJson(process.cwd(), imports ? { imports } : undefined);
|
|
183
|
+
|
|
135
184
|
console.log('Finished. To start your oc for the first time:');
|
|
136
185
|
console.log();
|
|
137
186
|
console.log(` cd ${componentName}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { InitialData, serverClient } from 'oc-server';
|
|
1
|
+
import { InitialData, serverClient, getSettings } from 'oc-server/client';
|
|
2
2
|
import styles from './styles.css';
|
|
3
3
|
import logo from '../public/logo.png';
|
|
4
|
-
import { getSettings } from 'oc-server';
|
|
5
4
|
|
|
6
5
|
const onRender = (cb: (element: HTMLElement) => void) => {
|
|
7
6
|
const isBrowser = typeof window !== 'undefined';
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@types/react-dom": "^19.1.6",
|
|
29
29
|
"@vitejs/plugin-react": "^4.6.0",
|
|
30
30
|
"happy-dom": "^18.0.1",
|
|
31
|
-
"oc-server": "^
|
|
32
|
-
"oc-template-esm-compiler": "^
|
|
31
|
+
"oc-server": "^4.0.0",
|
|
32
|
+
"oc-template-esm-compiler": "^3.0.2",
|
|
33
33
|
"react": "19.1.0",
|
|
34
34
|
"react-dom": "19.1.0",
|
|
35
35
|
"typescript": "5.8.3",
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
serverClient,
|
|
4
|
+
type InitialData,
|
|
5
|
+
type ActionOutput,
|
|
6
|
+
} from 'oc-server/client';
|
|
3
7
|
import styles from './styles.module.css';
|
|
4
8
|
import logo from '../public/logo.png';
|
|
5
9
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { createComponent } from
|
|
2
|
-
import { createRoot, Root } from
|
|
3
|
-
import App from
|
|
1
|
+
import { createComponent } from 'oc-template-esm-compiler/renderer';
|
|
2
|
+
import { createRoot, Root } from 'react-dom/client';
|
|
3
|
+
import App from './App';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export default createComponent(() => {
|
|
6
|
+
let root: Root | undefined = undefined;
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
return {
|
|
9
|
+
mount(element, props) {
|
|
10
|
+
root = createRoot(element);
|
|
11
|
+
root.render(<App {...props} />);
|
|
12
|
+
},
|
|
13
|
+
unmount() {
|
|
14
|
+
root?.unmount();
|
|
15
|
+
},
|
|
16
|
+
};
|
|
15
17
|
});
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
import { defineConfig } from
|
|
2
|
-
import react from
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
3
|
|
|
4
4
|
// https://vitejs.dev/config/
|
|
5
5
|
export default defineConfig({
|
|
6
6
|
// Add your own plugins here for thinkgs like eslint or typecheckers
|
|
7
7
|
plugins: [react()],
|
|
8
|
-
resolve: {
|
|
9
|
-
alias: {
|
|
10
|
-
react: "https://esm.sh/react@19.1.0",
|
|
11
|
-
"react-dom": "https://esm.sh/react-dom@19.1.0",
|
|
12
|
-
"react-dom/": "https://esm.sh/react-dom@19.1.0/",
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
8
|
build: {
|
|
16
9
|
rollupOptions: {
|
|
17
|
-
external: [
|
|
10
|
+
external: ['react', 'react-dom'],
|
|
18
11
|
},
|
|
19
12
|
},
|
|
20
13
|
// @ts-ignore Missing test property
|
|
21
14
|
test: {
|
|
22
|
-
environment: 'jsdom'
|
|
23
|
-
}
|
|
15
|
+
environment: 'jsdom',
|
|
16
|
+
},
|
|
24
17
|
});
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@remix-run/dom": "^0.0.0-experimental-remix-jam.6",
|
|
26
26
|
"@remix-run/events": "^0.0.0-experimental-remix-jam.5",
|
|
27
27
|
"happy-dom": "^18.0.1",
|
|
28
|
-
"oc-server": "^
|
|
29
|
-
"oc-template-esm-compiler": "^
|
|
28
|
+
"oc-server": "^4.0.0",
|
|
29
|
+
"oc-template-esm-compiler": "^3.0.2",
|
|
30
30
|
"typescript": "5.8.3",
|
|
31
31
|
"vitest": "^3.2.4"
|
|
32
32
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
serverClient,
|
|
3
|
+
type ActionOutput,
|
|
4
|
+
getInitialData,
|
|
5
|
+
} from 'oc-server/client';
|
|
2
6
|
import type { Remix } from '@remix-run/dom';
|
|
3
7
|
import { press } from '@remix-run/events/press';
|
|
4
8
|
import styles from './styles.module.css';
|
|
@@ -2,14 +2,16 @@ import { createComponent } from 'oc-template-esm-compiler/renderer';
|
|
|
2
2
|
import { createRoot } from '@remix-run/dom';
|
|
3
3
|
import App from './App';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export default createComponent(() => {
|
|
6
|
+
let root: ReturnType<typeof createRoot> | undefined = undefined;
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
return {
|
|
9
|
+
mount(element) {
|
|
10
|
+
root = createRoot(element as HTMLElement);
|
|
11
|
+
root.render(<App />);
|
|
12
|
+
},
|
|
13
|
+
unmount() {
|
|
14
|
+
root?.remove();
|
|
15
|
+
},
|
|
16
|
+
};
|
|
15
17
|
});
|
|
@@ -2,17 +2,6 @@ import { defineConfig } from 'vite';
|
|
|
2
2
|
|
|
3
3
|
// https://vitejs.dev/config/
|
|
4
4
|
export default defineConfig({
|
|
5
|
-
// Add your own plugins here for thinkgs like eslint or typecheckers
|
|
6
|
-
resolve: {
|
|
7
|
-
alias: {
|
|
8
|
-
'@remix-run/dom':
|
|
9
|
-
'https://esm.sh/@remix-run/dom@0.0.0-experimental-remix-jam.6',
|
|
10
|
-
'@remix-run/events':
|
|
11
|
-
'https://esm.sh/@remix-run/events@0.0.0-experimental-remix-jam.5',
|
|
12
|
-
'@remix-run/events/':
|
|
13
|
-
'https://esm.sh/@remix-run/events@0.0.0-experimental-remix-jam.5/',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
5
|
build: {
|
|
17
6
|
rollupOptions: {
|
|
18
7
|
external: ['@remix-run/dom', '@remix-run/events'],
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@testing-library/react": "^14.0.0",
|
|
27
27
|
"@testing-library/user-event": "^14.4.3",
|
|
28
28
|
"jsdom": "^21.1.1",
|
|
29
|
-
"oc-server": "^
|
|
30
|
-
"oc-template-preact-compiler": "^3.1.
|
|
29
|
+
"oc-server": "^4.0.0",
|
|
30
|
+
"oc-template-preact-compiler": "^3.1.4",
|
|
31
31
|
"preact": "^10.13.2",
|
|
32
32
|
"typescript": "5.0.2",
|
|
33
33
|
"vitest": "^0.29.7"
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { useState } from 'preact/hooks';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type ActionOutput,
|
|
4
|
+
type InitialData,
|
|
5
|
+
serverClient,
|
|
6
|
+
} from 'oc-server/client';
|
|
3
7
|
import styles from './styles.css';
|
|
4
8
|
import logo from '../public/logo.png';
|
|
5
9
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// These values are required and cannot be changed by the user
|
|
17
17
|
// Keep this in sync with the rollup config
|
|
18
18
|
"module": "esnext",
|
|
19
|
-
"moduleResolution": "
|
|
19
|
+
"moduleResolution": "bundler",
|
|
20
20
|
"resolveJsonModule": true,
|
|
21
21
|
"isolatedModules": true,
|
|
22
22
|
"jsx": "react-jsx",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@testing-library/user-event": "^14.4.3",
|
|
27
27
|
"@types/react": "^18.0.28",
|
|
28
28
|
"jsdom": "^21.1.1",
|
|
29
|
-
"oc-server": "^
|
|
30
|
-
"oc-template-react-compiler": "^10.1.
|
|
29
|
+
"oc-server": "^4.0.0",
|
|
30
|
+
"oc-template-react-compiler": "^10.1.4",
|
|
31
31
|
"react": "18.3.1",
|
|
32
32
|
"react-dom": "18.3.1",
|
|
33
33
|
"typescript": "5.1.3",
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
serverClient,
|
|
4
|
+
type InitialData,
|
|
5
|
+
type ActionOutput,
|
|
6
|
+
} from 'oc-server/client';
|
|
3
7
|
import styles from './styles.css';
|
|
4
8
|
import logo from '../public/logo.png';
|
|
5
9
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// These values are required and cannot be changed by the user
|
|
17
17
|
// Keep this in sync with the rollup config
|
|
18
18
|
"module": "ESNext",
|
|
19
|
-
"moduleResolution": "
|
|
19
|
+
"moduleResolution": "bundler",
|
|
20
20
|
"resolveJsonModule": true,
|
|
21
21
|
"isolatedModules": true,
|
|
22
22
|
"jsx": "react-jsx"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@testing-library/jest-dom": "^6.5.0",
|
|
26
26
|
"@types/testing-library__jest-dom": "^5.14.5",
|
|
27
27
|
"jsdom": "^21.1.1",
|
|
28
|
-
"oc-server": "^
|
|
29
|
-
"oc-template-solid-compiler": "^3.1.
|
|
28
|
+
"oc-server": "^4.0.0",
|
|
29
|
+
"oc-template-solid-compiler": "^3.1.4",
|
|
30
30
|
"solid-js": "^1.9.5",
|
|
31
31
|
"typescript": "5.5.4",
|
|
32
32
|
"vitest": "^2.0.5"
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { createSignal, Show
|
|
2
|
-
import {
|
|
1
|
+
import { createSignal, Show } from 'solid-js';
|
|
2
|
+
import {
|
|
3
|
+
serverClient,
|
|
4
|
+
type InitialData,
|
|
5
|
+
type ActionOutput,
|
|
6
|
+
} from 'oc-server/client';
|
|
3
7
|
import styles from './styles.css';
|
|
4
8
|
import logo from '../public/logo.png';
|
|
5
9
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// These values are required and cannot be changed by the user
|
|
17
17
|
// Keep this in sync with the rollup config
|
|
18
18
|
"module": "esnext",
|
|
19
|
-
"moduleResolution": "
|
|
19
|
+
"moduleResolution": "bundler",
|
|
20
20
|
"resolveJsonModule": true,
|
|
21
21
|
"isolatedModules": true,
|
|
22
22
|
"jsx": "preserve",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@tsconfig/svelte": "^5.0.4",
|
|
28
28
|
"@types/testing-library__jest-dom": "^5.14.5",
|
|
29
29
|
"jsdom": "^21.1.1",
|
|
30
|
-
"oc-server": "^
|
|
31
|
-
"oc-template-svelte-compiler": "^2.1.
|
|
30
|
+
"oc-server": "^4.0.0",
|
|
31
|
+
"oc-template-svelte-compiler": "^2.1.4",
|
|
32
32
|
"svelte": "^5.23.0",
|
|
33
33
|
"svelte-check": "^4.0.0",
|
|
34
34
|
"typescript": "5.0.2",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import logo from '../public/logo.png';
|
|
3
|
-
import { type InitialData, serverClient } from 'oc-server';
|
|
3
|
+
import { type InitialData, serverClient } from 'oc-server/client';
|
|
4
4
|
|
|
5
5
|
let funFact: string | null = $state(null);
|
|
6
6
|
let { born, firstName, hobbies, lastName }: InitialData = $props();
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
28
28
|
"@vue/tsconfig": "^0.7.0",
|
|
29
29
|
"jsdom": "^21.1.1",
|
|
30
|
-
"oc-server": "^
|
|
31
|
-
"oc-template-vue-compiler": "^3.1.
|
|
30
|
+
"oc-server": "^4.0.0",
|
|
31
|
+
"oc-template-vue-compiler": "^3.1.4",
|
|
32
32
|
"typescript": "5.8.2",
|
|
33
33
|
"vitest": "^0.29.7",
|
|
34
34
|
"vue": "^3.5.13",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// These values are required and cannot be changed by the user
|
|
17
17
|
// Keep this in sync with the rollup config
|
|
18
18
|
"module": "esnext",
|
|
19
|
-
"moduleResolution": "
|
|
19
|
+
"moduleResolution": "bundler",
|
|
20
20
|
"resolveJsonModule": true,
|
|
21
21
|
"isolatedModules": true,
|
|
22
22
|
"jsx": "preserve"
|