extension-create 3.4.0 → 3.4.1

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 (2) hide show
  1. package/dist/module.cjs +37 -157
  2. package/package.json +1 -1
package/dist/module.cjs CHANGED
@@ -330,19 +330,39 @@ async function importExternalTemplate(projectPath, projectName, template) {
330
330
  async function withFilteredOutput(fn) {
331
331
  const originalStdoutWrite = process.stdout.write.bind(process.stdout);
332
332
  const originalStderrWrite = process.stderr.write.bind(process.stderr);
333
- const shouldFilter = (chunk)=>{
334
- const s = 'string' == typeof chunk ? chunk : chunk?.toString?.() ?? '';
335
- if (!s) return false;
336
- return /Using git version/i.test(s) || /GitHub API rate limit reached, continuing without connectivity check/i.test(s);
333
+ const stdoutBuffer = {
334
+ value: ''
337
335
  };
338
- process.stdout.write = (chunk, ...args)=>{
339
- if (shouldFilter(chunk)) return true;
340
- return originalStdoutWrite(chunk, ...args);
336
+ const stderrBuffer = {
337
+ value: ''
341
338
  };
342
- process.stderr.write = (chunk, ...args)=>{
343
- if (shouldFilter(chunk)) return true;
344
- return originalStderrWrite(chunk, ...args);
339
+ let suppressGoGitItStack = false;
340
+ const toText = (chunk)=>'string' == typeof chunk ? chunk : chunk?.toString?.() ?? '';
341
+ const shouldFilterLine = (line)=>{
342
+ if (!line) return false;
343
+ const trimmed = line.trim();
344
+ if (!trimmed) return false;
345
+ if (/Using git version/i.test(line) || /GitHub API rate limit reached, continuing without connectivity check/i.test(line) || /\[go-git-it\] An error occurred: Error: Failed to download release asset: HTTP 404/i.test(line) || /^Downloading extension\b/i.test(trimmed) || /^URL https?:\/\/codeload\.github\.com\/extension-js\/examples\/zip\/refs\/heads\/main\b/i.test(trimmed) || /^\[[=\s]+\]\s*\d+%/i.test(trimmed)) {
346
+ suppressGoGitItStack = true;
347
+ return true;
348
+ }
349
+ if (suppressGoGitItStack && /^\s+at\b/.test(line)) return true;
350
+ if (suppressGoGitItStack && !/^\s+at\b/.test(line)) suppressGoGitItStack = false;
351
+ return false;
345
352
  };
353
+ const writeWithFilter = (originalWrite, buffer)=>(chunk, ...args)=>{
354
+ const text = buffer.value + toText(chunk);
355
+ if (!text) return true;
356
+ const parts = text.split(/\r?\n|\r/);
357
+ buffer.value = parts.pop() ?? '';
358
+ if (0 === parts.length) return true;
359
+ const kept = [];
360
+ for (const line of parts)if (!shouldFilterLine(line)) kept.push(line);
361
+ if (0 === kept.length) return true;
362
+ return originalWrite(kept.join('\n') + '\n', ...args);
363
+ };
364
+ process.stdout.write = writeWithFilter(originalStdoutWrite, stdoutBuffer);
365
+ process.stderr.write = writeWithFilter(originalStderrWrite, stderrBuffer);
346
366
  try {
347
367
  return await fn();
348
368
  } finally{
@@ -737,137 +757,17 @@ async function writeManifestJson(projectPath, projectName) {
737
757
  }
738
758
  async function generateExtensionTypes(projectPath, projectName) {
739
759
  const extensionEnvFile = external_path_namespaceObject.join(projectPath, 'extension-env.d.ts');
740
- const { dependencies, devDependencies, peerDependencies, optionalDependencies } = await readPackageJson(projectPath);
741
- const hasDependency = (name)=>Boolean(dependencies[name] || devDependencies[name] || peerDependencies[name] || optionalDependencies[name]);
742
- const usesReact = hasDependency('react') || hasDependency('@types/react');
743
- const usesReactDom = hasDependency('react-dom') || hasDependency('@types/react-dom');
744
- const usesSvelte = hasDependency('svelte');
745
- const frameworkTypeRefs = [
746
- usesReact ? '/// <reference types="react" />' : '',
747
- usesReactDom ? '/// <reference types="react-dom" />' : '',
748
- usesSvelte ? '/// <reference types="svelte" />' : ''
749
- ].filter(Boolean).join('\n');
760
+ const typePath = 'extension';
750
761
  const fileContent = `\
751
762
  // Required Extension.js types for TypeScript projects.
752
763
  // This file is auto-generated and should not be excluded.
753
- //
754
- /// <reference types="webextension-polyfill" />
755
- /// <reference types="node" />
756
- /// <reference types="chrome" />
757
- ${frameworkTypeRefs}
758
-
759
- declare global {
760
- const browser: typeof import('webextension-polyfill')
761
-
762
- type ExtensionBrowser =
763
- | 'chrome'
764
- | 'edge'
765
- | 'firefox'
766
- | 'chromium-based'
767
- | 'gecko-based'
768
-
769
- type ExtensionMode = 'development' | 'production'
770
-
771
- interface ExtensionEnv {
772
- EXTENSION_BROWSER: ExtensionBrowser
773
- EXTENSION_MODE: ExtensionMode
774
- EXTENSION_PUBLIC_BROWSER: ExtensionBrowser
775
- EXTENSION_PUBLIC_MODE: ExtensionMode
776
- EXTENSION_PUBLIC_DESCRIPTION_TEXT: string
777
- EXTENSION_PUBLIC_LLM_API_KEY: string
778
- EXTENSION_AUTHOR_MODE: string
779
- EXTENSION_PUBLIC_AUTHOR_MODE: string
780
- }
781
-
782
- namespace NodeJS {
783
- interface ProcessEnv extends ExtensionEnv {
784
- [key: string]: string | undefined
785
- }
786
- }
787
-
788
- interface ImportMetaEnv extends ExtensionEnv {
789
- [key: string]: string | undefined
790
- }
791
-
792
- interface ImportMeta {
793
- readonly env: ImportMetaEnv
794
- readonly webpackHot?: {
795
- accept: (module?: string | string[], callback?: () => void) => void
796
- dispose: (callback: () => void) => void
797
- }
798
- url: string
799
- }
800
-
801
- interface Window {
802
- /**
803
- * @deprecated
804
- * @description
805
- * This is how Extension.js used to inject the shadow root into the window object.
806
- * Use the shadowRoot reference from the content script instead.
807
- */
808
- __EXTENSION_SHADOW_ROOT__: ShadowRoot
809
- }
810
- }
811
-
812
- type CSSContentData = Readonly<Record<string, string>>
813
- type CSSModuleData = Readonly<Record<string, string>>
814
-
815
- declare module '*.css' {
816
- const content: CSSContentData
817
- export default content
818
- }
819
-
820
- declare module '*.module.css' {
821
- const content: CSSModuleData
822
- export default content
823
- }
824
- declare module '*.module.scss' {
825
- const content: CSSModuleData
826
- export default content
827
- }
828
- declare module '*.module.sass' {
829
- const content: CSSModuleData
830
- export default content
831
- }
764
+ // If you need additional types, consider creating a new *.d.ts file and
765
+ // referencing it in the "include" array of your tsconfig.json file.
766
+ // See https://www.typescriptlang.org/tsconfig#include for more information.
767
+ /// <reference types="${typePath}/types" />
832
768
 
833
- declare module '*.png' {
834
- const content: string
835
- export default content
836
- }
837
- declare module '*.jpg' {
838
- const content: string
839
- export default content
840
- }
841
- declare module '*.jpeg' {
842
- const content: string
843
- export default content
844
- }
845
- declare module '*.gif' {
846
- const content: string
847
- export default content
848
- }
849
- declare module '*.webp' {
850
- const content: string
851
- export default content
852
- }
853
- declare module '*.avif' {
854
- const content: string
855
- export default content
856
- }
857
- declare module '*.ico' {
858
- const content: string
859
- export default content
860
- }
861
- declare module '*.bmp' {
862
- const content: string
863
- export default content
864
- }
865
- declare module '*.svg' {
866
- const content: any
867
- export default content
868
- }
869
-
870
- export {}
769
+ // Polyfill types for browser.* APIs
770
+ /// <reference types="${typePath}/types/polyfill" />
871
771
  `;
872
772
  try {
873
773
  await promises_namespaceObject.mkdir(projectPath, {
@@ -880,26 +780,6 @@ export {}
880
780
  throw error;
881
781
  }
882
782
  }
883
- async function readPackageJson(projectPath) {
884
- const packageJsonPath = external_path_namespaceObject.join(projectPath, 'package.json');
885
- try {
886
- const content = await promises_namespaceObject.readFile(packageJsonPath, 'utf8');
887
- const parsed = JSON.parse(content) || {};
888
- return {
889
- dependencies: parsed.dependencies || {},
890
- devDependencies: parsed.devDependencies || {},
891
- peerDependencies: parsed.peerDependencies || {},
892
- optionalDependencies: parsed.optionalDependencies || {}
893
- };
894
- } catch {
895
- return {
896
- dependencies: {},
897
- devDependencies: {},
898
- peerDependencies: {},
899
- optionalDependencies: {}
900
- };
901
- }
902
- }
903
783
  const globalDependencies = [
904
784
  '',
905
785
  '# dependencies',
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "name": "extension-create",
26
- "version": "3.4.0",
26
+ "version": "3.4.1",
27
27
  "description": "The standalone extension creation engine for Extension.js",
28
28
  "author": {
29
29
  "name": "Cezar Augusto",