@codespark/react 1.0.3 → 1.0.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.
package/dist/index.d.ts CHANGED
@@ -261,7 +261,7 @@ declare function useWorkspace(init?: WorkspaceInit | Workspace): UseWorkspaceRet
261
261
  /**
262
262
  * Configuration options for createWorkspace function
263
263
  */
264
- interface CreateWorkspaceConfig extends Pick<WorkspaceInit, 'id' | 'framework'> {
264
+ interface CreateWorkspaceConfig extends Omit<WorkspaceInit, 'entry' | 'files'> {
265
265
  /**
266
266
  * Entry file name/path
267
267
  *
package/dist/index.js CHANGED
@@ -397,25 +397,31 @@ function useWorkspace(init) {
397
397
  const compiled = framework.compile();
398
398
  workspace[INTERNAL_EMIT]("compiled", compiled);
399
399
  const modules = framework.getOutput(LoaderType.ESModule);
400
+ const styles = framework.getOutput(LoaderType.Style);
401
+ const scripts = framework.getOutput(LoaderType.Script);
402
+ const externals = modules.flatMap(({ externals: externals$1 }) => externals$1).reduce((acc, { name, imported }) => {
403
+ if (!acc[name]) acc[name] = /* @__PURE__ */ new Set();
404
+ imported.forEach((i) => acc[name].add(i));
405
+ return acc;
406
+ }, {});
400
407
  return {
401
408
  fileTree,
402
409
  compiled,
403
410
  compileError: null,
404
411
  vendor: {
405
412
  modules,
406
- styles: framework.getOutput(LoaderType.Style),
407
- scripts: framework.getOutput(LoaderType.Script),
413
+ styles,
414
+ scripts,
408
415
  imports: {
409
- ...modules.map(({ externals }) => externals).flat().reduce((pre, { name, imported }) => {
410
- return {
411
- ...pre,
412
- [name]: constructESMUrl({
413
- pkg: name,
414
- version: "",
415
- external: Object.keys(framework.imports),
416
- exports: imported.length ? imported : void 0
417
- })
418
- };
416
+ ...Object.entries(externals).reduce((pre, [name, importedSet]) => {
417
+ const imported = Array.from(importedSet);
418
+ pre[name] = constructESMUrl({
419
+ pkg: name,
420
+ version: "",
421
+ external: Object.keys(framework.imports),
422
+ exports: imported.length ? imported : void 0
423
+ });
424
+ return pre;
419
425
  }, {}),
420
426
  ...framework.imports
421
427
  }
@@ -462,9 +468,8 @@ function useWorkspace(init) {
462
468
  * ```
463
469
  */
464
470
  function createWorkspace(source, config) {
465
- const { id, framework, name = "./App.tsx", mode = "packed" } = config || {};
471
+ const { name = "./App.tsx", mode = "packed", ...workspaceInit } = config || {};
466
472
  if (!this?.__scanned) return new Workspace({
467
- id,
468
473
  entry: name,
469
474
  files: { [name]: source.toString() }
470
475
  });
@@ -474,10 +479,9 @@ function createWorkspace(source, config) {
474
479
  else if (mode === "source") {
475
480
  packedCode = Object.values(files)[0] || "";
476
481
  return new Workspace({
477
- id,
478
- framework,
479
482
  entry: Object.keys(files)[0] || "",
480
- files
483
+ files,
484
+ ...workspaceInit
481
485
  });
482
486
  } else {
483
487
  const { code, locals, imports } = entry;
@@ -488,13 +492,12 @@ function createWorkspace(source, config) {
488
492
  ].filter(Boolean).join("\n\n");
489
493
  }
490
494
  return new Workspace({
491
- id,
492
- framework,
493
495
  entry: name,
494
496
  files: {
495
497
  [name]: packedCode,
496
498
  ...files
497
- }
499
+ },
500
+ ...workspaceInit
498
501
  });
499
502
  }
500
503
 
@@ -1577,7 +1580,7 @@ function useTailwindCSS() {
1577
1580
  const PREFLIGHT_STYLE = `
1578
1581
  :root {
1579
1582
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
1580
- font-size: 14px;
1583
+ font-size: 16px;
1581
1584
  line-height: 1.5;
1582
1585
  font-synthesis: none;
1583
1586
  text-rendering: optimizeLegibility;
@@ -1600,6 +1603,7 @@ html {
1600
1603
  body {
1601
1604
  height: 100%;
1602
1605
  padding: 12px;
1606
+ font-size: 14px;
1603
1607
  overflow: auto;
1604
1608
  box-sizing: border-box;
1605
1609
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codespark/react",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "description": "React components for codespark ecosystem",
6
6
  "keywords": [
@@ -27,7 +27,8 @@
27
27
  "dist"
28
28
  ],
29
29
  "scripts": {
30
- "build": "tsdown"
30
+ "build": "tsdown",
31
+ "release": "pnpm build && npm publish --access public"
31
32
  },
32
33
  "author": "TonyL1u",
33
34
  "license": "MIT",