@buoy-gg/angular 7.0.74 → 7.0.76
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
|
|
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
|
|
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};
|
|
@@ -15,11 +15,13 @@
|
|
|
15
15
|
"env",
|
|
16
16
|
"events",
|
|
17
17
|
"console",
|
|
18
|
+
"sentry",
|
|
18
19
|
"time-machine",
|
|
19
20
|
"clock",
|
|
20
21
|
"permissions",
|
|
21
22
|
"lifecycle",
|
|
22
23
|
"location",
|
|
24
|
+
"scenarios",
|
|
23
25
|
"ask-buoy",
|
|
24
26
|
"network",
|
|
25
27
|
"storage",
|
|
@@ -57,6 +59,10 @@
|
|
|
57
59
|
"value": "console",
|
|
58
60
|
"label": "Console"
|
|
59
61
|
},
|
|
62
|
+
{
|
|
63
|
+
"value": "sentry",
|
|
64
|
+
"label": "Sentry"
|
|
65
|
+
},
|
|
60
66
|
{
|
|
61
67
|
"value": "time-machine",
|
|
62
68
|
"label": "Time Machine"
|
|
@@ -77,6 +83,10 @@
|
|
|
77
83
|
"value": "location",
|
|
78
84
|
"label": "Location"
|
|
79
85
|
},
|
|
86
|
+
{
|
|
87
|
+
"value": "scenarios",
|
|
88
|
+
"label": "Scenarios"
|
|
89
|
+
},
|
|
80
90
|
{
|
|
81
91
|
"value": "ask-buoy",
|
|
82
92
|
"label": "Ask Buoy"
|
|
@@ -1,106 +1,114 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"id": "core",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.76"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
7
|
"id": "env",
|
|
8
|
-
"version": "7.0.
|
|
8
|
+
"version": "7.0.76"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"id": "events",
|
|
12
|
-
"version": "7.0.
|
|
12
|
+
"version": "7.0.76"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"id": "console",
|
|
16
|
-
"version": "7.0.
|
|
16
|
+
"version": "7.0.76"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "sentry",
|
|
20
|
+
"version": "7.0.76"
|
|
17
21
|
},
|
|
18
22
|
{
|
|
19
23
|
"id": "time-machine",
|
|
20
|
-
"version": "7.0.
|
|
24
|
+
"version": "7.0.76"
|
|
21
25
|
},
|
|
22
26
|
{
|
|
23
27
|
"id": "clock",
|
|
24
|
-
"version": "7.0.
|
|
28
|
+
"version": "7.0.76"
|
|
25
29
|
},
|
|
26
30
|
{
|
|
27
31
|
"id": "permissions",
|
|
28
|
-
"version": "7.0.
|
|
32
|
+
"version": "7.0.76"
|
|
29
33
|
},
|
|
30
34
|
{
|
|
31
35
|
"id": "lifecycle",
|
|
32
|
-
"version": "7.0.
|
|
36
|
+
"version": "7.0.76"
|
|
33
37
|
},
|
|
34
38
|
{
|
|
35
39
|
"id": "location",
|
|
36
|
-
"version": "7.0.
|
|
40
|
+
"version": "7.0.76"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "scenarios",
|
|
44
|
+
"version": "7.0.76"
|
|
37
45
|
},
|
|
38
46
|
{
|
|
39
47
|
"id": "ask-buoy",
|
|
40
|
-
"version": "7.0.
|
|
48
|
+
"version": "7.0.76"
|
|
41
49
|
},
|
|
42
50
|
{
|
|
43
51
|
"id": "network",
|
|
44
|
-
"version": "7.0.
|
|
52
|
+
"version": "7.0.76"
|
|
45
53
|
},
|
|
46
54
|
{
|
|
47
55
|
"id": "storage",
|
|
48
|
-
"version": "7.0.
|
|
56
|
+
"version": "7.0.76"
|
|
49
57
|
},
|
|
50
58
|
{
|
|
51
59
|
"id": "route-events",
|
|
52
|
-
"version": "7.0.
|
|
60
|
+
"version": "7.0.76"
|
|
53
61
|
},
|
|
54
62
|
{
|
|
55
63
|
"id": "react-query",
|
|
56
|
-
"version": "7.0.
|
|
64
|
+
"version": "7.0.76"
|
|
57
65
|
},
|
|
58
66
|
{
|
|
59
67
|
"id": "redux",
|
|
60
|
-
"version": "7.0.
|
|
68
|
+
"version": "7.0.76"
|
|
61
69
|
},
|
|
62
70
|
{
|
|
63
71
|
"id": "zustand",
|
|
64
|
-
"version": "7.0.
|
|
72
|
+
"version": "7.0.76"
|
|
65
73
|
},
|
|
66
74
|
{
|
|
67
75
|
"id": "jotai",
|
|
68
|
-
"version": "7.0.
|
|
76
|
+
"version": "7.0.76"
|
|
69
77
|
},
|
|
70
78
|
{
|
|
71
79
|
"id": "highlight-updates",
|
|
72
|
-
"version": "7.0.
|
|
80
|
+
"version": "7.0.76"
|
|
73
81
|
},
|
|
74
82
|
{
|
|
75
83
|
"id": "image-overlay",
|
|
76
|
-
"version": "7.0.
|
|
84
|
+
"version": "7.0.76"
|
|
77
85
|
},
|
|
78
86
|
{
|
|
79
87
|
"id": "impersonate",
|
|
80
|
-
"version": "7.0.
|
|
88
|
+
"version": "7.0.76"
|
|
81
89
|
},
|
|
82
90
|
{
|
|
83
91
|
"id": "perf-monitor",
|
|
84
|
-
"version": "7.0.
|
|
92
|
+
"version": "7.0.76"
|
|
85
93
|
},
|
|
86
94
|
{
|
|
87
95
|
"id": "js-top",
|
|
88
|
-
"version": "7.0.
|
|
96
|
+
"version": "7.0.76"
|
|
89
97
|
},
|
|
90
98
|
{
|
|
91
99
|
"id": "images",
|
|
92
|
-
"version": "7.0.
|
|
100
|
+
"version": "7.0.76"
|
|
93
101
|
},
|
|
94
102
|
{
|
|
95
103
|
"id": "assets",
|
|
96
|
-
"version": "7.0.
|
|
104
|
+
"version": "7.0.76"
|
|
97
105
|
},
|
|
98
106
|
{
|
|
99
107
|
"id": "tv-remote",
|
|
100
|
-
"version": "7.0.
|
|
108
|
+
"version": "7.0.76"
|
|
101
109
|
},
|
|
102
110
|
{
|
|
103
111
|
"id": "focus-inspector",
|
|
104
|
-
"version": "7.0.
|
|
112
|
+
"version": "7.0.76"
|
|
105
113
|
}
|
|
106
114
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/angular",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.76",
|
|
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/shared-ui": "^7.0.
|
|
52
|
-
"@buoy-gg/core": "^7.0.
|
|
51
|
+
"@buoy-gg/shared-ui": "^7.0.76",
|
|
52
|
+
"@buoy-gg/core": "^7.0.76"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@angular/core": ">=19 <23",
|