@buoy-gg/angular 7.0.73 → 7.0.75

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/README.md CHANGED
@@ -17,7 +17,7 @@ Run these from your app folder:
17
17
 
18
18
  ```sh
19
19
  ng add @buoy-gg/angular
20
- npx buoy login
20
+ npx --package=@buoy-gg/core buoy login
21
21
  ng serve
22
22
  ```
23
23
 
@@ -41,7 +41,7 @@ For more than one app, choose it by name:
41
41
 
42
42
  ```sh
43
43
  ng add @buoy-gg/angular --project my-app
44
- npx buoy login --project my-app
44
+ npx --package=@buoy-gg/core buoy login --project my-app
45
45
  ```
46
46
 
47
47
  Login writes `src/environments/buoy.ts` under the app's source root.
@@ -1,8 +1,8 @@
1
1
  const{createRequire}=require("node:module");const appRequire=createRequire(require("node:path").join(process.cwd(),"package.json"));const ts=appRequire("typescript");const path=require("node:path").posix;const catalog=require("./tools.json");const read=(r,e)=>{const o=ts.parseConfigFileTextToJson(e,r.readText(e));if(o.error)throw new Error(`Cannot read ${e}. Fix its JSON, then run ng add again.`);return o.config};const write=(r,e,o)=>{const a=JSON.stringify(o,null,2)+"\n";if(!r.exists(e))r.create(e,a);else if(r.readText(e)!==a)r.overwrite(e,a)};function select(r,e){const o=read(r,"/angular.json");const a=Object.keys(o.projects).filter(s=>o.projects[s].projectType==="application");const t=e.project||o.defaultProject||(a.length===1?a[0]:void 0);if(!t||!a.includes(t))throw new Error("Choose an app with --project <name>.");return{workspace:o,name:t,project:o.projects[t]}}function defaults(r){const e={...r.dependencies,...r.devDependencies};const o=["network","console","storage","events","env"];if(e["@angular/router"])o.push("route-events");if(Object.keys(e).some(a=>a.startsWith("@tanstack/angular-query-")))o.push("react-query");if(e["@ngrx/store"]||e["@ngxs/store"])o.push("redux");if(Number((e["@angular/core"]||"").match(/\d+/)?.[0])>=20)o.push("highlight-updates");return o.filter(a=>catalog.some(t=>t.id===a))}function ngAdd(r){return(e,o)=>{const{name:a}=select(e,r);const t=read(e,"/package.json");if(t.buoy?.angular?.[a])return e;r={...r};if(!r.tools?.length)delete r.tools;const s=o.schematic.collection.createSchematic("setup",true);s.description.schemaJson=structuredClone(s.description.schemaJson);s.description.schemaJson.properties.tools.default=defaults(t);return s.call({...r,project:a},appRequire("rxjs").of(e),o)}}function source(r,e){return ts.createSourceFile(e,r.readText(e),ts.ScriptTarget.Latest,true)}function nodes(r,e){const o=[];const a=t=>{if(e(t))o.push(t);ts.forEachChild(t,a)};a(r);return o}function importName(r,e,o,a){const t=source(r,e);for(const l of t.statements)if(ts.isImportDeclaration(l)&&l.moduleSpecifier.text===o){const i=l.importClause?.namedBindings;if(i&&ts.isNamedImports(i)){for(const u of i.elements)if((u.propertyName||u.name).text===a)return u.name.text}}const s=new Set(nodes(t,ts.isIdentifier).map(l=>l.text));let n=a;while(s.has(n))n+="Buoy";r.overwrite(e,`import { ${a}${n!==a?" as "+n:""} } from '${o}';
2
2
  `+r.readText(e));return n}function providerFile(r,e){const o=new Set;const a=t=>{if(o.has(t)||!r.exists(t))return;o.add(t);const s=source(r,t);if(nodes(s,n=>ts.isCallExpression(n)&&n.expression.getText(s)==="NgModule").length||nodes(s,n=>ts.isVariableDeclaration(n)&&n.name.getText(s)==="appConfig").length||nodes(s,n=>ts.isCallExpression(n)&&n.expression.getText(s)==="bootstrapApplication"&&n.arguments[1]&&ts.isObjectLiteralExpression(n.arguments[1])).length)return t;for(const n of s.statements)if(ts.isImportDeclaration(n)&&n.moduleSpecifier.text.startsWith(".")){const l=path.join(path.dirname(t),n.moduleSpecifier.text);for(const i of[l+".ts",path.join(l,"index.ts")]){const u=a(i);if(u)return u}}};return a(e)}function providers(r,e,o,a){const t=source(r,e);let s;const n=nodes(t,c=>ts.isCallExpression(c)&&c.expression.getText(t)==="NgModule")[0];if(n)s=n.arguments[0];else s=nodes(t,c=>ts.isVariableDeclaration(c)&&c.name.getText(t)==="appConfig")[0]?.initializer;if(!s)s=nodes(t,c=>ts.isCallExpression(c)&&c.expression.getText(t)==="bootstrapApplication")[0]?.arguments[1];if(!s||!ts.isObjectLiteralExpression(s))throw new Error(`Cannot find a provider list in ${e}. Add provideBuoy() last in your app's providers.`);const l=s.properties.find(c=>c.name?.getText(t)==="providers");const i=r.readText(e);if(!l){const c=s.getEnd()-1;r.overwrite(e,i.slice(0,c)+`${s.properties.length&&!s.properties.hasTrailingComma?",":""}
3
3
  providers: [${o}]
4
- `+i.slice(c));return}if(!ts.isArrayLiteralExpression(l.initializer))throw new Error(`The providers in ${e} use a shared value. Add provideBuoy() last in that list.`);const u=l.initializer;const d=u.elements.map(c=>c.getFullText(t).trim());const y=u.elements.findIndex(c=>nodes(c,v=>ts.isCallExpression(v)&&v.expression.getText(t)===a).length>0);const g=y<0?o:d.splice(y,1)[0];d.push(g);const x=i.includes("\r\n")?"\r\n":"\n";const p=c=>(i.slice(i.lastIndexOf("\n",c-1)+1,c).match(/^[ \t]*/)||[""])[0];const m=p(l.getStart(t));const b=u.elements[0];const h=b&&i.slice(u.getStart(t),b.getStart(t)).includes("\n")?p(b.getStart(t)):"";const $=(i.match(/^[ \t]+(?=\S)/m)||[" "])[0];const j=h||m+$;const T=u.elements.hasTrailingComma||/,\s*\n\s*[}\]]/.test(i);const k="["+x+d.map(c=>j+c).join(","+x)+(T?",":"")+x+m+"]";if(i.slice(u.getStart(t),u.getEnd())!==k)r.overwrite(e,i.slice(0,u.getStart(t))+k+i.slice(u.getEnd()))}function setup(r){return(e,o)=>{const{workspace:a,name:t,project:s}=select(e,r);const n=read(e,"/package.json");const l=[...new Set(r.tools??defaults(n))];for(const p of l)if(!catalog.some(m=>m.id===p))throw new Error(`Unknown Buoy tool: ${p}.`);const i=s.architect||s.targets;if(!i?.build)throw new Error("This app has no build target. Add Buoy by hand.");const u=["@angular/build:application","@buoy-gg/angular:application"].includes(i.build.builder)&&(!i.serve||["@angular/build:dev-server","@buoy-gg/angular:dev-server"].includes(i.serve.builder));const d=s.sourceRoot||path.join(s.root||"","src");const y=i.build.options?.browser||i.build.options?.main||path.join(d,"main.ts");const g=providerFile(e,y)||[path.join(d,"app/app.config.ts"),path.join(d,"app/app.module.ts"),path.join(d,"app/app-module.ts")].find(p=>e.exists(p));if(!g)throw new Error("Cannot find the app entry. Add provideBuoy() last in its providers.");const x=importName(e,g,"@buoy-gg/angular","provideBuoy");if(u){i.build.builder="@buoy-gg/angular:application";if(i.serve)i.serve.builder="@buoy-gg/angular:dev-server";providers(e,g,`${x}()`,x)}else{o.logger.warn(`[Buoy] Kept ${i.build.builder}. It is not an @angular/build builder. Added the manual setup instead.`);const p=path.join(d,"buoy.ts");const m=l.map((f,E)=>`'${f==="notifications"?"push-notifications":f}': await import('@buoy-gg/${f}/web')`).join(",\n ");const b=path.join(d,"environments/buoy.ts");if(!e.exists(b))e.create(b,"export const BUOY_KEY = '';\n");if(!e.exists(p))e.create(p,`import { BUOY_KEY } from './environments/buoy';
4
+ `+i.slice(c));return}if(!ts.isArrayLiteralExpression(l.initializer))throw new Error(`The providers in ${e} use a shared value. Add provideBuoy() last in that list.`);const u=l.initializer;const d=u.elements.map(c=>c.getFullText(t).trim());const h=u.elements.findIndex(c=>nodes(c,v=>ts.isCallExpression(v)&&v.expression.getText(t)===a).length>0);const g=h<0?o:d.splice(h,1)[0];d.push(g);const x=i.includes("\r\n")?"\r\n":"\n";const p=c=>(i.slice(i.lastIndexOf("\n",c-1)+1,c).match(/^[ \t]*/)||[""])[0];const m=p(l.getStart(t));const b=u.elements[0];const y=b&&i.slice(u.getStart(t),b.getStart(t)).includes("\n")?p(b.getStart(t)):"";const $=(i.match(/^[ \t]+(?=\S)/m)||[" "])[0];const j=y||m+$;const T=u.elements.hasTrailingComma||/,\s*\n\s*[}\]]/.test(i);const k="["+x+d.map(c=>j+c).join(","+x)+(T?",":"")+x+m+"]";if(i.slice(u.getStart(t),u.getEnd())!==k)r.overwrite(e,i.slice(0,u.getStart(t))+k+i.slice(u.getEnd()))}function setup(r){return(e,o)=>{const{workspace:a,name:t,project:s}=select(e,r);const n=read(e,"/package.json");const l=[...new Set(r.tools??defaults(n))];for(const p of l)if(!catalog.some(m=>m.id===p))throw new Error(`Unknown Buoy tool: ${p}.`);const i=s.architect||s.targets;if(!i?.build)throw new Error("This app has no build target. Add Buoy by hand.");const u=["@angular/build:application","@buoy-gg/angular:application"].includes(i.build.builder)&&(!i.serve||["@angular/build:dev-server","@buoy-gg/angular:dev-server"].includes(i.serve.builder));const d=s.sourceRoot||path.join(s.root||"","src");const h=i.build.options?.browser||i.build.options?.main||path.join(d,"main.ts");const g=providerFile(e,h)||[path.join(d,"app/app.config.ts"),path.join(d,"app/app.module.ts"),path.join(d,"app/app-module.ts")].find(p=>e.exists(p));if(!g)throw new Error("Cannot find the app entry. Add provideBuoy() last in its providers.");const x=importName(e,g,"@buoy-gg/angular","provideBuoy");if(u){i.build.builder="@buoy-gg/angular:application";if(i.serve)i.serve.builder="@buoy-gg/angular:dev-server";providers(e,g,`${x}()`,x)}else{o.logger.warn(`[Buoy] Kept ${i.build.builder}. It is not an @angular/build builder. Added the manual setup instead.`);const p=path.join(d,"buoy.ts");const m=l.map((f,E)=>`'${f==="notifications"?"push-notifications":f}': await import('@buoy-gg/${f}/web')`).join(",\n ");const b=path.join(d,"environments/buoy.ts");if(!e.exists(b))e.create(b,"export const BUOY_KEY = '';\n");if(!e.exists(p))e.create(p,`import { BUOY_KEY } from './environments/buoy';
5
5
  export const buoyOptions = { licenseKey: BUOY_KEY, modules: async () => ({
6
6
  ${m}
7
7
  }) };
8
- `);let h=path.relative(path.dirname(g),p).replace(/\.ts$/,"");if(!h.startsWith("."))h="./"+h;const $=importName(e,g,h,"buoyOptions");let j=e.readText(g);if(!/declare\s+const\s+ngDevMode/.test(j))e.overwrite(g,"declare const ngDevMode: boolean | undefined;\n"+j);providers(e,g,`(typeof ngDevMode === 'undefined' || ngDevMode) ? ${x}(${$}) : []`,x);const T=e.readText(y);if(!T.includes("'@buoy-gg/angular/register'"))e.overwrite(y,"import '@buoy-gg/angular/register';\n"+T);const k=Number(({...n.dependencies,...n.devDependencies}["@angular/core"]||"").match(/\d+/)?.[0]);const c=(i.build.configurations??={}).production??={};const v=path.join(d,"buoy.prod.ts");if(!e.exists(v))e.create(v,"export const buoyOptions = {};\n");c.fileReplacements=[...(c.fileReplacements||[]).filter(f=>f.replace!==p),{replace:p,with:v}];if(k>=20&&!i.build.builder.endsWith(":browser"))c.conditions=[...new Set(["buoy-disabled",...c.conditions||["module","production"]])];else{const f=path.join(d,"buoy-entry.ts"),E=path.join(d,"buoy-entry.prod.ts");if(!e.exists(f))e.create(f,"import '@buoy-gg/angular/register';\nexport { provideBuoy } from '@buoy-gg/angular';\nexport { buoyOptions } from './buoy';\n");if(!e.exists(E))e.create(E,"import { makeEnvironmentProviders } from '@angular/core';\nexport const provideBuoy = (_options?: unknown) => makeEnvironmentProviders([]);\nexport const buoyOptions = {};\n");let w=path.relative(path.dirname(g),f).replace(/\.ts$/,"");if(!w.startsWith("."))w="./"+w;e.overwrite(g,e.readText(g).replace(/from '@buoy-gg\/angular'/,`from '${w}'`).replace(`from '${h}'`,`from '${w}'`));e.overwrite(y,e.readText(y).replace("import '@buoy-gg/angular/register';\n",""));c.fileReplacements=[...(c.fileReplacements||[]).filter(S=>S.replace!==f),{replace:f,with:E}]}}n.devDependencies??={};for(const p of["core",...l]){const m=catalog.find(h=>h.id===p);const b="@buoy-gg/"+p;if(!n.dependencies?.[b]&&!n.devDependencies[b])n.devDependencies[b]="^"+m.version}if(l.includes("react-query")&&!n.dependencies?.["@tanstack/react-query"]&&!n.devDependencies["@tanstack/react-query"]){const p=Object.entries({...n.dependencies,...n.devDependencies}).find(([m])=>m.startsWith("@tanstack/angular-query-"));n.devDependencies["@tanstack/react-query"]=p?.[1]||"^5.0.0"}n.buoy??={};n.buoy.angular??={};n.buoy.angular[t]={tools:l};write(e,"/angular.json",a);write(e,"/package.json",n);if(!r.skipInstall)o.addTask(new(createRequire(appRequire.resolve("@angular/cli/package.json"))("@angular-devkit/schematics/tasks")).NodePackageInstallTask);o.logger.info("[Buoy] Run npx buoy login to sign in.");return e}}module.exports={ngAdd,setup,defaults};
8
+ `);let y=path.relative(path.dirname(g),p).replace(/\.ts$/,"");if(!y.startsWith("."))y="./"+y;const $=importName(e,g,y,"buoyOptions");let j=e.readText(g);if(!/declare\s+const\s+ngDevMode/.test(j))e.overwrite(g,"declare const ngDevMode: boolean | undefined;\n"+j);providers(e,g,`(typeof ngDevMode === 'undefined' || ngDevMode) ? ${x}(${$}) : []`,x);const T=e.readText(h);if(!T.includes("'@buoy-gg/angular/register'"))e.overwrite(h,"import '@buoy-gg/angular/register';\n"+T);const k=Number(({...n.dependencies,...n.devDependencies}["@angular/core"]||"").match(/\d+/)?.[0]);const c=(i.build.configurations??={}).production??={};const v=path.join(d,"buoy.prod.ts");if(!e.exists(v))e.create(v,"export const buoyOptions = {};\n");c.fileReplacements=[...(c.fileReplacements||[]).filter(f=>f.replace!==p),{replace:p,with:v}];if(k>=20&&!i.build.builder.endsWith(":browser"))c.conditions=[...new Set(["buoy-disabled",...c.conditions||["module","production"]])];else{const f=path.join(d,"buoy-entry.ts"),E=path.join(d,"buoy-entry.prod.ts");if(!e.exists(f))e.create(f,"import '@buoy-gg/angular/register';\nexport { provideBuoy } from '@buoy-gg/angular';\nexport { buoyOptions } from './buoy';\n");if(!e.exists(E))e.create(E,"import { makeEnvironmentProviders } from '@angular/core';\nexport const provideBuoy = (_options?: unknown) => makeEnvironmentProviders([]);\nexport const buoyOptions = {};\n");let w=path.relative(path.dirname(g),f).replace(/\.ts$/,"");if(!w.startsWith("."))w="./"+w;e.overwrite(g,e.readText(g).replace(/from '@buoy-gg\/angular'/,`from '${w}'`).replace(`from '${y}'`,`from '${w}'`));e.overwrite(h,e.readText(h).replace("import '@buoy-gg/angular/register';\n",""));c.fileReplacements=[...(c.fileReplacements||[]).filter(S=>S.replace!==f),{replace:f,with:E}]}}n.devDependencies??={};for(const p of["core",...l]){const m=catalog.find(y=>y.id===p);const b="@buoy-gg/"+p;if(!n.dependencies?.[b]&&!n.devDependencies[b])n.devDependencies[b]="^"+m.version}if(l.includes("react-query")&&!n.dependencies?.["@tanstack/react-query"]&&!n.devDependencies["@tanstack/react-query"]){const p=Object.entries({...n.dependencies,...n.devDependencies}).find(([m])=>m.startsWith("@tanstack/angular-query-"));n.devDependencies["@tanstack/react-query"]=p?.[1]||"^5.0.0"}n.buoy??={};n.buoy.angular??={};n.buoy.angular[t]={tools:l};write(e,"/angular.json",a);write(e,"/package.json",n);if(!r.skipInstall)o.addTask(new(createRequire(appRequire.resolve("@angular/cli/package.json"))("@angular-devkit/schematics/tasks")).NodePackageInstallTask);o.logger.info("[Buoy] Run npx --package=@buoy-gg/core buoy login to sign in.");return e}}module.exports={ngAdd,setup,defaults};
@@ -1,106 +1,106 @@
1
1
  [
2
2
  {
3
3
  "id": "core",
4
- "version": "7.0.73"
4
+ "version": "7.0.75"
5
5
  },
6
6
  {
7
7
  "id": "env",
8
- "version": "7.0.73"
8
+ "version": "7.0.75"
9
9
  },
10
10
  {
11
11
  "id": "events",
12
- "version": "7.0.73"
12
+ "version": "7.0.75"
13
13
  },
14
14
  {
15
15
  "id": "console",
16
- "version": "7.0.73"
16
+ "version": "7.0.75"
17
17
  },
18
18
  {
19
19
  "id": "time-machine",
20
- "version": "7.0.73"
20
+ "version": "7.0.75"
21
21
  },
22
22
  {
23
23
  "id": "clock",
24
- "version": "7.0.73"
24
+ "version": "7.0.75"
25
25
  },
26
26
  {
27
27
  "id": "permissions",
28
- "version": "7.0.73"
28
+ "version": "7.0.75"
29
29
  },
30
30
  {
31
31
  "id": "lifecycle",
32
- "version": "7.0.73"
32
+ "version": "7.0.75"
33
33
  },
34
34
  {
35
35
  "id": "location",
36
- "version": "7.0.73"
36
+ "version": "7.0.75"
37
37
  },
38
38
  {
39
39
  "id": "ask-buoy",
40
- "version": "7.0.73"
40
+ "version": "7.0.75"
41
41
  },
42
42
  {
43
43
  "id": "network",
44
- "version": "7.0.73"
44
+ "version": "7.0.75"
45
45
  },
46
46
  {
47
47
  "id": "storage",
48
- "version": "7.0.73"
48
+ "version": "7.0.75"
49
49
  },
50
50
  {
51
51
  "id": "route-events",
52
- "version": "7.0.73"
52
+ "version": "7.0.75"
53
53
  },
54
54
  {
55
55
  "id": "react-query",
56
- "version": "7.0.73"
56
+ "version": "7.0.75"
57
57
  },
58
58
  {
59
59
  "id": "redux",
60
- "version": "7.0.73"
60
+ "version": "7.0.75"
61
61
  },
62
62
  {
63
63
  "id": "zustand",
64
- "version": "7.0.73"
64
+ "version": "7.0.75"
65
65
  },
66
66
  {
67
67
  "id": "jotai",
68
- "version": "7.0.73"
68
+ "version": "7.0.75"
69
69
  },
70
70
  {
71
71
  "id": "highlight-updates",
72
- "version": "7.0.73"
72
+ "version": "7.0.75"
73
73
  },
74
74
  {
75
75
  "id": "image-overlay",
76
- "version": "7.0.73"
76
+ "version": "7.0.75"
77
77
  },
78
78
  {
79
79
  "id": "impersonate",
80
- "version": "7.0.73"
80
+ "version": "7.0.75"
81
81
  },
82
82
  {
83
83
  "id": "perf-monitor",
84
- "version": "7.0.73"
84
+ "version": "7.0.75"
85
85
  },
86
86
  {
87
87
  "id": "js-top",
88
- "version": "7.0.73"
88
+ "version": "7.0.75"
89
89
  },
90
90
  {
91
91
  "id": "images",
92
- "version": "7.0.73"
92
+ "version": "7.0.75"
93
93
  },
94
94
  {
95
95
  "id": "assets",
96
- "version": "7.0.73"
96
+ "version": "7.0.75"
97
97
  },
98
98
  {
99
99
  "id": "tv-remote",
100
- "version": "7.0.73"
100
+ "version": "7.0.75"
101
101
  },
102
102
  {
103
103
  "id": "focus-inspector",
104
- "version": "7.0.73"
104
+ "version": "7.0.75"
105
105
  }
106
106
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/angular",
3
- "version": "7.0.73",
3
+ "version": "7.0.75",
4
4
  "description": "Run Buoy in an Angular app.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -48,8 +48,8 @@
48
48
  "react": "^19.2.0",
49
49
  "react-dom": "^19.2.0",
50
50
  "react-native-web": "^0.21.2",
51
- "@buoy-gg/core": "^7.0.73",
52
- "@buoy-gg/shared-ui": "^7.0.73"
51
+ "@buoy-gg/core": "^7.0.75",
52
+ "@buoy-gg/shared-ui": "^7.0.75"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@angular/core": ">=19 <23",