@plasmicapp/loader-fetcher 1.0.41 → 1.0.43

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
@@ -1,4 +1,205 @@
1
- export type { AssetModule, CodeModule, ComponentMeta, ExperimentSlice, FontMeta, GlobalGroupMeta, LoaderBundleOutput, LoaderHtmlOutput, PageMeta, PageMetadata, ProjectMeta, SegmentSlice, Split, } from "./api";
2
- export { Api } from "./api";
3
- export type { FetcherOptions, LoaderBundleCache } from "./fetcher";
4
- export { internal_getCachedBundleInNodeServer, PlasmicModulesFetcher, } from "./fetcher";
1
+ export declare class Api {
2
+ private opts;
3
+ private host;
4
+ private fetch;
5
+ constructor(opts: {
6
+ projects: {
7
+ id: string;
8
+ token: string;
9
+ }[];
10
+ host?: string;
11
+ nativeFetch?: boolean;
12
+ });
13
+ fetchLoaderData(projectIds: string[], opts: {
14
+ platform?: "react" | "nextjs" | "gatsby";
15
+ platformOptions?: {
16
+ nextjs?: {
17
+ appDir: boolean;
18
+ };
19
+ };
20
+ preview?: boolean;
21
+ browserOnly?: boolean;
22
+ i18nKeyScheme?: "content" | "hash" | "path";
23
+ i18nTagPrefix?: string;
24
+ skipHead?: boolean;
25
+ }): Promise<LoaderBundleOutput>;
26
+ private parseJsonResponse;
27
+ fetchHtmlData(opts: {
28
+ projectId: string;
29
+ component: string;
30
+ hydrate?: boolean;
31
+ embedHydrate?: boolean;
32
+ }): Promise<LoaderHtmlOutput>;
33
+ private makeGetHeaders;
34
+ private makeAuthHeaders;
35
+ }
36
+
37
+ export declare interface AssetModule {
38
+ fileName: string;
39
+ source: string;
40
+ type: "asset";
41
+ }
42
+
43
+ export declare interface CodeModule {
44
+ fileName: string;
45
+ code: string;
46
+ imports: string[];
47
+ type: "code";
48
+ }
49
+
50
+ export declare interface ComponentMeta {
51
+ id: string;
52
+ usedComponents: string[];
53
+ projectId: string;
54
+ name: string;
55
+ displayName: string;
56
+ cssFile: string;
57
+ path: string | undefined;
58
+ isPage: boolean;
59
+ plumeType?: string;
60
+ entry: string;
61
+ isCode: boolean;
62
+ isGlobalContextProvider: boolean;
63
+ pageMetadata?: PageMetadata;
64
+ metadata?: Record<string, string>;
65
+ }
66
+
67
+ export declare interface ExperimentSlice extends Slice {
68
+ prob: number;
69
+ }
70
+
71
+ declare interface ExperimentSplit {
72
+ id: string;
73
+ projectId: string;
74
+ externalId?: string;
75
+ type: "experiment";
76
+ slices: ExperimentSlice[];
77
+ }
78
+
79
+ export declare interface FetcherOptions {
80
+ projects: {
81
+ id: string;
82
+ version?: string;
83
+ token: string;
84
+ }[];
85
+ cache?: LoaderBundleCache;
86
+ platform?: "react" | "nextjs" | "gatsby";
87
+ platformOptions?: {
88
+ nextjs?: {
89
+ appDir: boolean;
90
+ };
91
+ };
92
+ preview?: boolean;
93
+ host?: string;
94
+ /**
95
+ * @deprecated use i18n.keyScheme instead
96
+ */
97
+ i18nKeyScheme?: "content" | "hash" | "path";
98
+ i18n?: {
99
+ keyScheme: "content" | "hash" | "path";
100
+ tagPrefix?: string;
101
+ };
102
+ skipHead?: boolean;
103
+ nativeFetch?: boolean;
104
+ }
105
+
106
+ export declare interface FontMeta {
107
+ url: string;
108
+ }
109
+
110
+ export declare interface GlobalGroupMeta {
111
+ id: string;
112
+ projectId: string;
113
+ name: string;
114
+ type: string;
115
+ contextFile: string;
116
+ useName: string;
117
+ }
118
+
119
+ declare interface GlobalVariantSplitContent {
120
+ type: "global-variant";
121
+ projectId: string;
122
+ group: string;
123
+ variant: string;
124
+ }
125
+
126
+ export declare function internal_getCachedBundleInNodeServer(opts: FetcherOptions): LoaderBundleOutput | undefined;
127
+
128
+ export declare interface LoaderBundleCache {
129
+ set: (data: LoaderBundleOutput) => Promise<void>;
130
+ get: () => Promise<LoaderBundleOutput>;
131
+ }
132
+
133
+ export declare interface LoaderBundleOutput {
134
+ modules: {
135
+ browser: (CodeModule | AssetModule)[];
136
+ server: (CodeModule | AssetModule)[];
137
+ };
138
+ external: string[];
139
+ components: ComponentMeta[];
140
+ globalGroups: GlobalGroupMeta[];
141
+ projects: ProjectMeta[];
142
+ activeSplits: Split[];
143
+ }
144
+
145
+ export declare interface LoaderHtmlOutput {
146
+ html: string;
147
+ }
148
+
149
+ export declare interface PageMeta extends ComponentMeta {
150
+ isPage: true;
151
+ path: string;
152
+ plumeType: never;
153
+ pageMetadata: PageMetadata;
154
+ }
155
+
156
+ export declare interface PageMetadata {
157
+ path: string;
158
+ title?: string | null;
159
+ description?: string | null;
160
+ openGraphImageUrl?: string | null;
161
+ canonical?: string | null;
162
+ }
163
+
164
+ export declare class PlasmicModulesFetcher {
165
+ private opts;
166
+ private api;
167
+ private curFetch;
168
+ constructor(opts: FetcherOptions);
169
+ fetchAllData(): Promise<LoaderBundleOutput>;
170
+ private getCachedOrFetch;
171
+ private doFetch;
172
+ private cacheBundleInNodeServer;
173
+ }
174
+
175
+ export declare interface ProjectMeta {
176
+ id: string;
177
+ teamId?: string;
178
+ indirect?: boolean;
179
+ name: string;
180
+ version: string;
181
+ remoteFonts: FontMeta[];
182
+ globalContextsProviderFileName: string;
183
+ }
184
+
185
+ export declare interface SegmentSlice extends Slice {
186
+ cond: any;
187
+ }
188
+
189
+ declare interface SegmentSplit {
190
+ id: string;
191
+ projectId: string;
192
+ externalId?: string;
193
+ type: "segment";
194
+ slices: SegmentSlice[];
195
+ }
196
+
197
+ declare interface Slice {
198
+ id: string;
199
+ contents: GlobalVariantSplitContent[];
200
+ externalId?: string;
201
+ }
202
+
203
+ export declare type Split = ExperimentSplit | SegmentSplit;
204
+
205
+ export { }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.41",
2
+ "version": "1.0.43",
3
3
  "license": "MIT",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
@@ -21,11 +21,11 @@
21
21
  "build": "yarn build:types && yarn build:index",
22
22
  "build:types": "yarn tsc",
23
23
  "build:index": "node ../../build.mjs ./src/index.ts",
24
- "postbuild": "node ../../print-module-api.js ./packages/loader-fetcher/dist/index.js > index-api.txt",
25
24
  "yalcp": "yalc publish --push",
26
25
  "test": "yarn --cwd=../.. test",
27
26
  "lint": "eslint",
28
27
  "prepublishOnly": "npm run build",
28
+ "postpublish": "bash ../../scripts/publish-api-doc-model.sh",
29
29
  "size": "size-limit",
30
30
  "analyze": "size-limit --why"
31
31
  },
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "6f034859cd2316dfed75d01006abbc002149374c"
50
+ "gitHead": "9216f61b95565cb9ff8639fa7f2d2640a320e731"
51
51
  }
package/dist/api.d.ts DELETED
@@ -1,143 +0,0 @@
1
- export interface ComponentMeta {
2
- id: string;
3
- usedComponents: string[];
4
- projectId: string;
5
- name: string;
6
- displayName: string;
7
- cssFile: string;
8
- path: string | undefined;
9
- isPage: boolean;
10
- plumeType?: string;
11
- entry: string;
12
- isCode: boolean;
13
- isGlobalContextProvider: boolean;
14
- pageMetadata?: PageMetadata;
15
- metadata?: Record<string, string>;
16
- }
17
- export interface PageMeta extends ComponentMeta {
18
- isPage: true;
19
- path: string;
20
- plumeType: never;
21
- pageMetadata: PageMetadata;
22
- }
23
- export interface PageMetadata {
24
- path: string;
25
- title?: string | null;
26
- description?: string | null;
27
- openGraphImageUrl?: string | null;
28
- canonical?: string | null;
29
- }
30
- export interface GlobalGroupMeta {
31
- id: string;
32
- projectId: string;
33
- name: string;
34
- type: string;
35
- contextFile: string;
36
- useName: string;
37
- }
38
- export interface ProjectMeta {
39
- id: string;
40
- teamId?: string;
41
- indirect?: boolean;
42
- name: string;
43
- version: string;
44
- remoteFonts: FontMeta[];
45
- globalContextsProviderFileName: string;
46
- }
47
- export interface FontMeta {
48
- url: string;
49
- }
50
- interface GlobalVariantSplitContent {
51
- type: "global-variant";
52
- projectId: string;
53
- group: string;
54
- variant: string;
55
- }
56
- interface Slice {
57
- id: string;
58
- contents: GlobalVariantSplitContent[];
59
- externalId?: string;
60
- }
61
- export interface ExperimentSlice extends Slice {
62
- prob: number;
63
- }
64
- export interface SegmentSlice extends Slice {
65
- cond: any;
66
- }
67
- export interface ExperimentSplit {
68
- id: string;
69
- projectId: string;
70
- externalId?: string;
71
- type: "experiment";
72
- slices: ExperimentSlice[];
73
- }
74
- export interface SegmentSplit {
75
- id: string;
76
- projectId: string;
77
- externalId?: string;
78
- type: "segment";
79
- slices: SegmentSlice[];
80
- }
81
- export type Split = ExperimentSplit | SegmentSplit;
82
- export interface LoaderBundleOutput {
83
- modules: {
84
- browser: (CodeModule | AssetModule)[];
85
- server: (CodeModule | AssetModule)[];
86
- };
87
- external: string[];
88
- components: ComponentMeta[];
89
- globalGroups: GlobalGroupMeta[];
90
- projects: ProjectMeta[];
91
- activeSplits: Split[];
92
- }
93
- export interface LoaderHtmlOutput {
94
- html: string;
95
- }
96
- export interface CodeModule {
97
- fileName: string;
98
- code: string;
99
- imports: string[];
100
- type: "code";
101
- }
102
- export interface AssetModule {
103
- fileName: string;
104
- source: string;
105
- type: "asset";
106
- }
107
- export declare const isBrowser: boolean;
108
- export declare class Api {
109
- private opts;
110
- private host;
111
- private fetch;
112
- constructor(opts: {
113
- projects: {
114
- id: string;
115
- token: string;
116
- }[];
117
- host?: string;
118
- nativeFetch?: boolean;
119
- });
120
- fetchLoaderData(projectIds: string[], opts: {
121
- platform?: "react" | "nextjs" | "gatsby";
122
- platformOptions?: {
123
- nextjs?: {
124
- appDir: boolean;
125
- };
126
- };
127
- preview?: boolean;
128
- browserOnly?: boolean;
129
- i18nKeyScheme?: "content" | "hash" | "path";
130
- i18nTagPrefix?: string;
131
- skipHead?: boolean;
132
- }): Promise<LoaderBundleOutput>;
133
- private parseJsonResponse;
134
- fetchHtmlData(opts: {
135
- projectId: string;
136
- component: string;
137
- hydrate?: boolean;
138
- embedHydrate?: boolean;
139
- }): Promise<LoaderHtmlOutput>;
140
- private makeGetHeaders;
141
- private makeAuthHeaders;
142
- }
143
- export {};
package/dist/fetcher.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import { LoaderBundleOutput } from "./api";
2
- export interface FetcherOptions {
3
- projects: {
4
- id: string;
5
- version?: string;
6
- token: string;
7
- }[];
8
- cache?: LoaderBundleCache;
9
- platform?: "react" | "nextjs" | "gatsby";
10
- platformOptions?: {
11
- nextjs?: {
12
- appDir: boolean;
13
- };
14
- };
15
- preview?: boolean;
16
- host?: string;
17
- /**
18
- * @deprecated use i18n.keyScheme instead
19
- */
20
- i18nKeyScheme?: "content" | "hash" | "path";
21
- i18n?: {
22
- keyScheme: "content" | "hash" | "path";
23
- tagPrefix?: string;
24
- };
25
- skipHead?: boolean;
26
- nativeFetch?: boolean;
27
- }
28
- export interface LoaderBundleCache {
29
- set: (data: LoaderBundleOutput) => Promise<void>;
30
- get: () => Promise<LoaderBundleOutput>;
31
- }
32
- export declare class PlasmicModulesFetcher {
33
- private opts;
34
- private api;
35
- private curFetch;
36
- constructor(opts: FetcherOptions);
37
- fetchAllData(): Promise<LoaderBundleOutput>;
38
- private getCachedOrFetch;
39
- private doFetch;
40
- private cacheBundleInNodeServer;
41
- }
42
- export declare function internal_getCachedBundleInNodeServer(opts: FetcherOptions): LoaderBundleOutput | undefined;