@puzzmo/sdk 1.0.7 → 1.0.9
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 +72 -34
- package/dist/{createSimulator-Ctg-fdCI.cjs → createSimulator-BmeD2jIP.cjs} +31 -31
- package/dist/createSimulator-BmeD2jIP.cjs.map +1 -0
- package/dist/{createSimulator-BZYymqOG.js → createSimulator-D-ln1AMv.js} +237 -240
- package/dist/createSimulator-D-ln1AMv.js.map +1 -0
- package/dist/{workshop.d.ts → editor.d.ts} +16 -3
- package/dist/editor.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -11
- package/dist/index.js.map +1 -1
- package/dist/objectSpread2-C4RR_HMd.cjs +1 -0
- package/dist/objectSpread2-CJo2CZQ6.js +76 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/simulator/createSimulator.d.ts +11 -7
- package/dist/simulator/createSimulator.d.ts.map +1 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.js +1 -1
- package/dist/simulator/standalone.cjs +1 -1
- package/dist/simulator/standalone.cjs.map +1 -1
- package/dist/simulator/standalone.js +4 -4
- package/dist/simulator/standalone.js.map +1 -1
- package/dist/simulator/types.d.ts +0 -2
- package/dist/simulator/types.d.ts.map +1 -1
- package/dist/types.d.ts +49 -29
- package/dist/types.d.ts.map +1 -1
- package/dist/vite.cjs +3 -3
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +18 -2
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +79 -23
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/dist/asyncToGenerator-BlxRHn40.cjs +0 -1
- package/dist/asyncToGenerator-CPSNHDFw.js +0 -25
- package/dist/createSimulator-BZYymqOG.js.map +0 -1
- package/dist/createSimulator-Ctg-fdCI.cjs.map +0 -1
- package/dist/objectSpread2-B6tAAMuy.cjs +0 -1
- package/dist/objectSpread2-vLYiAtaU.js +0 -52
- package/dist/workshop.d.ts.map +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,73 +1,101 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Theme info provided by Puzzmo. We have scoped prefixes for domain specific areas.
|
|
3
|
+
* The comments in JSDoc are based on Puzzmo's light theme colour scheme.
|
|
4
|
+
*/
|
|
2
5
|
export type Theme = {
|
|
6
|
+
/** Themes display name */
|
|
3
7
|
name: string;
|
|
8
|
+
/** How should it be bucketed? */
|
|
4
9
|
type: "light" | "dark";
|
|
10
|
+
/** The bright Pink */
|
|
5
11
|
key: string;
|
|
12
|
+
/** The color to draw on a key */
|
|
6
13
|
keyFG: string;
|
|
14
|
+
/** A bolder version of the bright pink */
|
|
7
15
|
keyStrong: string;
|
|
16
|
+
/** A lighter version of the bright pink */
|
|
8
17
|
keyLight: string;
|
|
18
|
+
/** A variant of the key which is always above a certain level of brightness so that you
|
|
19
|
+
* can show dark text on it for games */
|
|
9
20
|
g_key: string;
|
|
21
|
+
/** A secondary color for the brand, in Puzzmo's case this is the puzzmo yellow */
|
|
10
22
|
subBrand: string;
|
|
23
|
+
/** Foreground color for the secondary */
|
|
11
24
|
subBrandFG: string;
|
|
25
|
+
/** The blue you traditionally see around a user avatar and selection */
|
|
12
26
|
player: string;
|
|
27
|
+
/** A lighter variant on the user's blue */
|
|
13
28
|
playerLight: string;
|
|
29
|
+
/** Text for on a background of player */
|
|
14
30
|
playerFG: string;
|
|
31
|
+
/** Alt color, this one is an earthy green in the main theme */
|
|
15
32
|
alt1: string;
|
|
33
|
+
/** Alt color 2, this one is a faded yellow which looks quite like the puzmo yellow */
|
|
16
34
|
alt2: string;
|
|
35
|
+
/** Alt color 3, this one is a cute purple */
|
|
17
36
|
alt3: string;
|
|
37
|
+
/** The foreground body text color */
|
|
18
38
|
fg: string;
|
|
39
|
+
/** The red for showing errors */
|
|
19
40
|
error: string;
|
|
41
|
+
/** Stays dark regardless of being in light/dark mode */
|
|
20
42
|
alwaysDark: string;
|
|
43
|
+
/** Stays light regardless of being in light/dark mode */
|
|
21
44
|
alwaysLight: string;
|
|
45
|
+
/** The 'tile' usually */
|
|
22
46
|
g_bg: string;
|
|
47
|
+
/** The 'tile' alternative in checkered patterns */
|
|
23
48
|
g_bgAlt: string;
|
|
49
|
+
/** Sorta useful for content layers on the existing bg, a darker version */
|
|
24
50
|
g_bgDark: string;
|
|
51
|
+
/** When _the text_ is on a light background, this is basically black */
|
|
25
52
|
g_textDark: string;
|
|
53
|
+
/** When _the text_ is dark background, this is white */
|
|
26
54
|
g_textLight: string;
|
|
55
|
+
/** For voids in a game, this is black */
|
|
27
56
|
g_blank: string;
|
|
57
|
+
/** For when a tile is not yet solved, this is a lighter grey */
|
|
28
58
|
g_unsolved: string;
|
|
59
|
+
/** Border for a game frame, for example the crossword edge */
|
|
29
60
|
g_outline: string;
|
|
61
|
+
/** The light grey you see as the background for most pages */
|
|
30
62
|
a_bg: string;
|
|
63
|
+
/** The darker grey which usually is seen as borders in the background */
|
|
31
64
|
a_bgAlt: string;
|
|
65
|
+
/** Used in the info bar BG */
|
|
32
66
|
a_infoBG: string;
|
|
67
|
+
/** The yellow shade of the puzmonaut */
|
|
33
68
|
a_puzmo: string;
|
|
69
|
+
/** Header colors */
|
|
34
70
|
a_headerText: string;
|
|
71
|
+
/** When tabulating results, the background color for an even table row */
|
|
35
72
|
a_table: string;
|
|
73
|
+
/** When tabulating results, the background color for an odd table row */
|
|
36
74
|
a_tableAlt: string;
|
|
75
|
+
/** Inline tag bg - used in the tagged friends */
|
|
37
76
|
a_inlineTag: string;
|
|
77
|
+
/** Used to indicate a link */
|
|
38
78
|
a_anchor: string;
|
|
39
79
|
};
|
|
40
80
|
/** Gameplay metrics sent to the host */
|
|
41
81
|
export type GamePlay = {
|
|
42
82
|
elapsedTimeSecs: number;
|
|
43
83
|
additionalTimeAddedSecs: number;
|
|
44
|
-
hintsUsed: number;
|
|
45
|
-
resetsUsed: number;
|
|
46
|
-
metric1: number;
|
|
47
|
-
metric2: number;
|
|
48
|
-
metric3: number;
|
|
49
|
-
metric4: number;
|
|
50
|
-
metricStrings: string[];
|
|
51
84
|
pointsAwarded: number;
|
|
52
85
|
completed?: boolean;
|
|
53
|
-
pipelineStats?: any;
|
|
54
|
-
cheatsUsed: number;
|
|
55
86
|
};
|
|
56
87
|
/** Things the server uses for meta-game augmentations */
|
|
57
88
|
export type AugmentationConfig = {
|
|
58
|
-
augmentations?: any;
|
|
59
89
|
deeds?: Deed[] | Readonly<Deed[]>;
|
|
60
90
|
};
|
|
61
91
|
export type CheckpointConfig = {
|
|
62
92
|
interruptible: boolean;
|
|
63
93
|
complete: boolean;
|
|
64
|
-
process: "leaderboards"[];
|
|
65
94
|
};
|
|
66
95
|
export type Deed = {
|
|
67
96
|
id: string;
|
|
68
97
|
value: any;
|
|
69
98
|
textRepresentation?: string | null;
|
|
70
|
-
puzzmoPoints?: number | null;
|
|
71
99
|
};
|
|
72
100
|
export type GameOverMessageUIComponent = {
|
|
73
101
|
type: "md";
|
|
@@ -99,11 +127,6 @@ export type BootstrapGameData = {
|
|
|
99
127
|
elapsedTimeSecs: number;
|
|
100
128
|
hintsUsed: number;
|
|
101
129
|
id: string;
|
|
102
|
-
metric1: number;
|
|
103
|
-
metric2: number;
|
|
104
|
-
metric3: number;
|
|
105
|
-
metric4: number;
|
|
106
|
-
metricStrings: ReadonlyArray<string>;
|
|
107
130
|
ownerID: string;
|
|
108
131
|
pointsAwarded: number;
|
|
109
132
|
resetsUsed: number;
|
|
@@ -130,17 +153,20 @@ export type BootstrapGameData = {
|
|
|
130
153
|
hostContext: any[];
|
|
131
154
|
appRuntimeContract: string;
|
|
132
155
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
(puzzleStr: string, inputStr?: string, config?: ThumbnailConfig): string;
|
|
136
|
-
|
|
156
|
+
export type AppBundle = {
|
|
157
|
+
/** Renders a puzzle and optional state string into an SVG */
|
|
158
|
+
renderThumbnail(puzzleStr: string, inputStr?: string, config?: ThumbnailConfig): string;
|
|
159
|
+
/** Takes an input string, and backtracks to a version somewhere between 0-1 for its completion */
|
|
160
|
+
interpolateInputString?: (inputStr: string, puzzleStr: string, value: number) => {
|
|
137
161
|
inputStr: string;
|
|
138
162
|
display: string;
|
|
139
163
|
time?: number;
|
|
140
164
|
};
|
|
141
|
-
|
|
165
|
+
/** Gives you an indication of how many possible steps are available for interpolation */
|
|
166
|
+
getInterpolatedStepCount?: (inputStr: string) => {
|
|
142
167
|
count: number;
|
|
143
168
|
};
|
|
169
|
+
/** Gets a share-able string representation of the puzzle */
|
|
144
170
|
getShareString?: (inputStr: string, title: string, extraData?: {
|
|
145
171
|
puzzleString: string;
|
|
146
172
|
dateKey: string;
|
|
@@ -181,11 +207,6 @@ export type MessagesSentFromEmbed = {
|
|
|
181
207
|
resetsUsed?: number | null;
|
|
182
208
|
cheatsUsed?: number | null;
|
|
183
209
|
boardState?: string | null;
|
|
184
|
-
metric1?: number | null;
|
|
185
|
-
metric2?: number | null;
|
|
186
|
-
metric3?: number | null;
|
|
187
|
-
metric4?: number | null;
|
|
188
|
-
metricStrings?: string[] | null;
|
|
189
210
|
collabUserReferences: string[];
|
|
190
211
|
};
|
|
191
212
|
};
|
|
@@ -195,7 +216,6 @@ export type MessagesSentFromEmbed = {
|
|
|
195
216
|
pipelineStats?: any[];
|
|
196
217
|
config?: {
|
|
197
218
|
deeds?: Deed[] | readonly Deed[];
|
|
198
|
-
augmentations?: any;
|
|
199
219
|
};
|
|
200
220
|
};
|
|
201
221
|
SHOW_GAME_COMPLETE_SCREEN: {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"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AAQ,EAAE,QAAQ,CAAA;KACnB,CAAA;IACD,UAAU,EAAE;QAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;IACzC,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE;QACd,cAAc,EAAE,MAAM,CAAA;QACtB,QAAQ,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;SAAE,CAAA;QACvD,gBAAgB,EAAE,gBAAgB,CAAA;QAClC,SAAS,EAAE,kBAAkB,CAAA;KAC9B,CAAA;CACF,CAAA;AAED,wCAAwC;AACxC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,UAAU,EAAE;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,SAAS,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,GAAG,CAAA;CACrB,CAAA"}
|
package/dist/vite.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
2
|
-
`)}return{name:`puzzmo-simulator`,apply:`serve`,resolveId(e){if(e===
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const l=require(`./objectSpread2-C4RR_HMd.cjs`);let u=require(`vite`);var d=c(o(((e,t)=>{t.exports={}}))(),1);function f(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function p(e,t){if(e==null)return{};var n,r,i=f(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var m=[`fixturesGlob`],h=`/@puzzmo-simulator-init.js`,g=`virtual:puzzmo-simulator`,_=`\0`+g;function v(e={}){function t(){let{fixturesGlob:t}=e,n=p(e,m),r=[`import { createSimulator } from "@puzzmo/sdk/simulator"`];t&&r.push(`const fixtures = import.meta.glob(${JSON.stringify(t)}, { eager: true })`);let i=Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>`${e}: ${JSON.stringify(t)}`);return t&&i.push(`fixtures`),r.push(`createSimulator({ ${i.join(`, `)} })`),r.join(`
|
|
2
|
+
`)}return{name:`puzzmo-simulator`,apply:`serve`,resolveId(e){if(e===g)return _},load(e){if(e===_)return t()},configureServer(e){e.middlewares.use(`/oauth/callback`,(e,t)=>{t.setHeader(`Content-Type`,`text/html`),t.end(`<!DOCTYPE html>
|
|
3
3
|
<html><head><title>Puzzmo OAuth</title></head>
|
|
4
4
|
<body><script>
|
|
5
5
|
var params = new URLSearchParams(window.location.search);
|
|
@@ -7,5 +7,5 @@ var returnUrl = sessionStorage.getItem("oauth_return_url") || "/";
|
|
|
7
7
|
var url = new URL(returnUrl);
|
|
8
8
|
params.forEach(function(v, k) { url.searchParams.set(k, v); });
|
|
9
9
|
window.location.href = url.toString();
|
|
10
|
-
<\/script></body></html>`)}),
|
|
10
|
+
<\/script></body></html>`)}),e.middlewares.use(function(){var t=l.n(function*(t,n,r){var i;if(((i=t.url)==null?void 0:i.split(`?`)[0])!==h)return r();let a=yield e.transformRequest(g);if(!a)return r();n.setHeader(`Content-Type`,`application/javascript`),n.end(a.code)});return function(e,n,r){return t.apply(this,arguments)}}())},transformIndexHtml(){return[{tag:`script`,attrs:{type:`module`,src:h},injectTo:`head`}]}}}function y(e,t){return(n={})=>{let{entry:r,outputFile:i}=l.t(l.t({},t),n);return{name:e,apply:`build`,closeBundle(){return l.n(function*(){try{yield(0,u.build)({configFile:!1,logLevel:`warn`,build:{lib:{entry:d.default.isAbsolute(r)?r:d.default.resolve(process.cwd(),r),formats:[`es`],fileName:()=>i},outDir:`dist`,emptyOutDir:!1}})}catch(t){throw console.error(`[${e}] build failed:`,t),t}})()}}}}const b=y(`app-bundle`,{entry:`src/appBundle.js`,outputFile:`app-bundle.js`}),x=y(`editor-bundle`,{entry:`src/editorBundle.js`,outputFile:`editor-bundle.js`});exports.appBundlePlugin=b,exports.editorBundlePlugin=x,exports.puzzmoSimulator=v;
|
|
11
11
|
//# sourceMappingURL=vite.cjs.map
|
package/dist/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.cjs","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import type { Plugin } from \"vite\"\
|
|
1
|
+
{"version":3,"file":"vite.cjs","names":[],"sources":["../__vite-browser-external","../src/vite.ts"],"sourcesContent":["module.exports = {}","import type { Plugin } from \"vite\"\nimport { build } from \"vite\"\nimport path from \"path\"\n\nexport type PuzzmoSimulatorPluginOptions = {\n /** Whether to auto-start the game after READY (default: true) */\n autoStart?: boolean\n /** Initial collapsed state (default: true) */\n collapsed?: boolean\n /** Game slug for API features (e.g. \"crossword\", \"my-game\") */\n slug?: string\n /** Glob pattern for fixture files, passed to import.meta.glob (e.g. \"./fixtures/puzzles/**\\/*.json\") */\n fixturesGlob?: string\n}\n\nconst SIMULATOR_URL = \"/@puzzmo-simulator-init.js\"\nconst VIRTUAL_ID = \"virtual:puzzmo-simulator\"\nconst RESOLVED_VIRTUAL_ID = \"\\0\" + VIRTUAL_ID\n\n/** Vite plugin that injects the Puzzmo simulator in dev mode and handles OAuth callbacks. */\nexport function puzzmoSimulator(options: PuzzmoSimulatorPluginOptions = {}): Plugin {\n function generateCode(): string {\n const { fixturesGlob, ...config } = options\n\n const lines = [`import { createSimulator } from \"@puzzmo/sdk/simulator\"`]\n\n if (fixturesGlob) {\n lines.push(`const fixtures = import.meta.glob(${JSON.stringify(fixturesGlob)}, { eager: true })`)\n }\n\n const configEntries = Object.entries(config).filter(([, v]) => v !== undefined)\n const configParts = configEntries.map(([k, v]) => `${k}: ${JSON.stringify(v)}`)\n if (fixturesGlob) configParts.push(\"fixtures\")\n\n lines.push(`createSimulator({ ${configParts.join(\", \")} })`)\n\n return lines.join(\"\\n\")\n }\n\n return {\n name: \"puzzmo-simulator\",\n apply: \"serve\",\n\n // Virtual module used internally for code generation and transformation.\n // Uses \\0 prefix so Vite's HTML processor won't try to inline it.\n resolveId(id) {\n if (id === VIRTUAL_ID) return RESOLVED_VIRTUAL_ID\n },\n\n load(id) {\n if (id === RESOLVED_VIRTUAL_ID) return generateCode()\n },\n\n configureServer(server) {\n server.middlewares.use(\"/oauth/callback\", (_req, res) => {\n res.setHeader(\"Content-Type\", \"text/html\")\n res.end(`<!DOCTYPE html>\n<html><head><title>Puzzmo OAuth</title></head>\n<body><script>\nvar params = new URLSearchParams(window.location.search);\nvar returnUrl = sessionStorage.getItem(\"oauth_return_url\") || \"/\";\nvar url = new URL(returnUrl);\nparams.forEach(function(v, k) { url.searchParams.set(k, v); });\nwindow.location.href = url.toString();\n</script></body></html>`)\n })\n\n // Serve the simulator init module. Registered before Vite's internal\n // middleware so the SPA fallback doesn't intercept it.\n server.middlewares.use(async (req, res, next) => {\n if (req.url?.split(\"?\")[0] !== SIMULATOR_URL) return next()\n\n const result = await server.transformRequest(VIRTUAL_ID)\n if (!result) return next()\n res.setHeader(\"Content-Type\", \"application/javascript\")\n res.end(result.code)\n })\n },\n\n // Inject a script tag whose src the browser will fetch.\n // The URL is NOT resolvable via resolveId (intentionally), so Vite's\n // HTML processor won't inline it. The middleware above serves it instead.\n transformIndexHtml() {\n return [\n {\n tag: \"script\",\n attrs: { type: \"module\", src: SIMULATOR_URL },\n injectTo: \"head\",\n },\n ]\n },\n }\n}\n\ntype BundlePluginOptions = {\n /** Entry file for the bundle */\n entry: string\n /** Output file name */\n outputFile: string\n}\n\nfunction createBundlePlugin(pluginName: string, defaults: BundlePluginOptions) {\n return (options: Partial<BundlePluginOptions> = {}): Plugin => {\n const { entry, outputFile } = { ...defaults, ...options }\n return {\n name: pluginName,\n apply: \"build\",\n async closeBundle() {\n try {\n await build({\n configFile: false,\n logLevel: \"warn\",\n build: {\n lib: {\n entry: path.isAbsolute(entry) ? entry : path.resolve(process.cwd(), entry),\n formats: [\"es\"],\n fileName: () => outputFile,\n },\n outDir: \"dist\",\n emptyOutDir: false,\n },\n })\n } catch (error) {\n console.error(`[${pluginName}] build failed:`, error)\n throw error\n }\n },\n }\n }\n}\n\nexport type AppBundlePluginOptions = Partial<BundlePluginOptions>\n\n/**\n * Vite plugin that produces dist/app-bundle.js after the main build for app-level integrations.\n *\n * The bundle exports `renderThumbnail(puzzleStr, inputStr?, config?)` — a pure\n * SVG-string renderer used by the Puzzmo platform for puzzle previews.\n */\nexport const appBundlePlugin = createBundlePlugin(\"app-bundle\", { entry: \"src/appBundle.js\", outputFile: \"app-bundle.js\" })\n\nexport type EditorBundlePluginOptions = Partial<BundlePluginOptions>\n\n/** Vite plugin that produces dist/editor-bundle.js after the main build for editor-level integrations. */\nexport const editorBundlePlugin = createBundlePlugin(\"editor-bundle\", { entry: \"src/editorBundle.js\", outputFile: \"editor-bundle.js\" })\n"],"mappings":"orBAAA,EAAO,QAAU,EAAA,0XCsBL,eAAA,CAPN,EAAgB,6BAChB,EAAa,2BACb,EAAsB,KAAO,EAGnC,SAAgB,EAAgB,EAAwC,EAAE,CAAU,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,GAAa,CAC7D,GAAM,CAAE,QAAO,cAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAoB,EAAA,CAAa,EAAS,CACzD,MAAO,CACL,KAAM,EACN,MAAO,QACP,aAAM,uBAAc,CAClB,GAAI,CACF,MAAA,EAAA,EAAA,OAAY,CACV,WAAY,GACZ,SAAU,OACV,MAAO,CACL,IAAK,CACH,MAAO,EAAA,QAAK,WAAW,EAAM,CAAG,EAAQ,EAAA,QAAK,QAAQ,QAAQ,KAAK,CAAE,EAAM,CAC1E,QAAS,CAAC,KAAK,CACf,aAAgB,EACjB,CACD,OAAQ,OACR,YAAa,GACd,CACF,CAAC,OACK,EAAO,CAEd,MADA,QAAQ,MAAM,IAAI,EAAW,iBAAkB,EAAM,CAC/C,QAGX,EAYL,MAAa,EAAkB,EAAmB,aAAc,CAAE,MAAO,mBAAoB,WAAY,gBAAiB,CAAC,CAK9G,EAAqB,EAAmB,gBAAiB,CAAE,MAAO,sBAAuB,WAAY,mBAAoB,CAAC"}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
export type PuzzmoSimulatorPluginOptions = {
|
|
3
|
-
/** Path to the puzzle JSON file (default: "./sample-puzzle.json") */
|
|
4
|
-
puzzlePath?: string;
|
|
5
3
|
/** Whether to auto-start the game after READY (default: true) */
|
|
6
4
|
autoStart?: boolean;
|
|
7
5
|
/** Initial collapsed state (default: true) */
|
|
@@ -13,4 +11,22 @@ export type PuzzmoSimulatorPluginOptions = {
|
|
|
13
11
|
};
|
|
14
12
|
/** Vite plugin that injects the Puzzmo simulator in dev mode and handles OAuth callbacks. */
|
|
15
13
|
export declare function puzzmoSimulator(options?: PuzzmoSimulatorPluginOptions): Plugin;
|
|
14
|
+
type BundlePluginOptions = {
|
|
15
|
+
/** Entry file for the bundle */
|
|
16
|
+
entry: string;
|
|
17
|
+
/** Output file name */
|
|
18
|
+
outputFile: string;
|
|
19
|
+
};
|
|
20
|
+
export type AppBundlePluginOptions = Partial<BundlePluginOptions>;
|
|
21
|
+
/**
|
|
22
|
+
* Vite plugin that produces dist/app-bundle.js after the main build for app-level integrations.
|
|
23
|
+
*
|
|
24
|
+
* The bundle exports `renderThumbnail(puzzleStr, inputStr?, config?)` — a pure
|
|
25
|
+
* SVG-string renderer used by the Puzzmo platform for puzzle previews.
|
|
26
|
+
*/
|
|
27
|
+
export declare const appBundlePlugin: (options?: Partial<BundlePluginOptions>) => Plugin;
|
|
28
|
+
export type EditorBundlePluginOptions = Partial<BundlePluginOptions>;
|
|
29
|
+
/** Vite plugin that produces dist/editor-bundle.js after the main build for editor-level integrations. */
|
|
30
|
+
export declare const editorBundlePlugin: (options?: Partial<BundlePluginOptions>) => Plugin;
|
|
31
|
+
export {};
|
|
16
32
|
//# sourceMappingURL=vite.d.ts.map
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC,MAAM,MAAM,4BAA4B,GAAG;IACzC,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,wGAAwG;IACxG,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAMD,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,OAAO,GAAE,4BAAiC,GAAG,MAAM,CAwElF;AAED,KAAK,mBAAmB,GAAG;IACzB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAgCD,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,aArCT,OAAO,CAAC,mBAAmB,CAAC,KAAQ,MAqCoE,CAAA;AAE3H,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEpE,0GAA0G;AAC1G,eAAO,MAAM,kBAAkB,aA1CZ,OAAO,CAAC,mBAAmB,CAAC,KAAQ,MA0CgF,CAAA"}
|
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { n as e, t } from "./objectSpread2-CJo2CZQ6.js";
|
|
2
|
+
import { build as n } from "vite";
|
|
3
|
+
var r = Object.create, i = Object.defineProperty, a = Object.getOwnPropertyDescriptor, o = Object.getOwnPropertyNames, s = Object.getPrototypeOf, c = Object.prototype.hasOwnProperty, l = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), u = (e, t, n, r) => {
|
|
4
|
+
if (t && typeof t == "object" || typeof t == "function") for (var s = o(t), l = 0, u = s.length, d; l < u; l++) d = s[l], !c.call(e, d) && d !== n && i(e, d, {
|
|
5
|
+
get: ((e) => t[e]).bind(null, d),
|
|
6
|
+
enumerable: !(r = a(t, d)) || r.enumerable
|
|
7
|
+
});
|
|
8
|
+
return e;
|
|
9
|
+
}, d = /* @__PURE__ */ ((e, t, n) => (n = e == null ? {} : r(s(e)), u(t || !e || !e.__esModule ? i(n, "default", {
|
|
10
|
+
value: e,
|
|
11
|
+
enumerable: !0
|
|
12
|
+
}) : n, e)))((/* @__PURE__ */ l(((e, t) => {
|
|
13
|
+
t.exports = {};
|
|
14
|
+
})))(), 1);
|
|
15
|
+
function f(e, t) {
|
|
3
16
|
if (e == null) return {};
|
|
4
17
|
var n = {};
|
|
5
18
|
for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
|
|
@@ -8,43 +21,43 @@ function t(e, t) {
|
|
|
8
21
|
}
|
|
9
22
|
return n;
|
|
10
23
|
}
|
|
11
|
-
function
|
|
24
|
+
function p(e, t) {
|
|
12
25
|
if (e == null) return {};
|
|
13
|
-
var r, i
|
|
26
|
+
var n, r, i = f(e, t);
|
|
14
27
|
if (Object.getOwnPropertySymbols) {
|
|
15
|
-
var
|
|
16
|
-
for (
|
|
28
|
+
var a = Object.getOwnPropertySymbols(e);
|
|
29
|
+
for (r = 0; r < a.length; r++) n = a[r], t.includes(n) || {}.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
|
|
17
30
|
}
|
|
18
|
-
return
|
|
31
|
+
return i;
|
|
19
32
|
}
|
|
20
|
-
var
|
|
33
|
+
var m = ["fixturesGlob"], h = "/@puzzmo-simulator-init.js", g = "virtual:puzzmo-simulator", _ = "\0" + g;
|
|
21
34
|
/** Vite plugin that injects the Puzzmo simulator in dev mode and handles OAuth callbacks. */
|
|
22
|
-
function
|
|
23
|
-
function
|
|
24
|
-
let { fixturesGlob: e } = t,
|
|
25
|
-
e &&
|
|
26
|
-
let
|
|
27
|
-
return e &&
|
|
35
|
+
function v(t = {}) {
|
|
36
|
+
function n() {
|
|
37
|
+
let { fixturesGlob: e } = t, n = p(t, m), r = ["import { createSimulator } from \"@puzzmo/sdk/simulator\""];
|
|
38
|
+
e && r.push(`const fixtures = import.meta.glob(${JSON.stringify(e)}, { eager: true })`);
|
|
39
|
+
let i = Object.entries(n).filter(([, e]) => e !== void 0).map(([e, t]) => `${e}: ${JSON.stringify(t)}`);
|
|
40
|
+
return e && i.push("fixtures"), r.push(`createSimulator({ ${i.join(", ")} })`), r.join("\n");
|
|
28
41
|
}
|
|
29
42
|
return {
|
|
30
43
|
name: "puzzmo-simulator",
|
|
31
44
|
apply: "serve",
|
|
32
45
|
resolveId(e) {
|
|
33
|
-
if (e ===
|
|
46
|
+
if (e === g) return _;
|
|
34
47
|
},
|
|
35
48
|
load(e) {
|
|
36
|
-
if (e ===
|
|
49
|
+
if (e === _) return n();
|
|
37
50
|
},
|
|
38
51
|
configureServer(t) {
|
|
39
52
|
t.middlewares.use("/oauth/callback", (e, t) => {
|
|
40
53
|
t.setHeader("Content-Type", "text/html"), t.end("<!DOCTYPE html>\n<html><head><title>Puzzmo OAuth</title></head>\n<body><script>\nvar params = new URLSearchParams(window.location.search);\nvar returnUrl = sessionStorage.getItem(\"oauth_return_url\") || \"/\";\nvar url = new URL(returnUrl);\nparams.forEach(function(v, k) { url.searchParams.set(k, v); });\nwindow.location.href = url.toString();\n<\/script></body></html>");
|
|
41
54
|
}), t.middlewares.use(function() {
|
|
42
55
|
var n = e(function* (e, n, r) {
|
|
43
|
-
var
|
|
44
|
-
if (((
|
|
45
|
-
let
|
|
46
|
-
if (!
|
|
47
|
-
n.setHeader("Content-Type", "application/javascript"), n.end(
|
|
56
|
+
var i;
|
|
57
|
+
if (((i = e.url) == null ? void 0 : i.split("?")[0]) !== h) return r();
|
|
58
|
+
let a = yield t.transformRequest(g);
|
|
59
|
+
if (!a) return r();
|
|
60
|
+
n.setHeader("Content-Type", "application/javascript"), n.end(a.code);
|
|
48
61
|
});
|
|
49
62
|
return function(e, t, r) {
|
|
50
63
|
return n.apply(this, arguments);
|
|
@@ -56,13 +69,56 @@ function s(t = {}) {
|
|
|
56
69
|
tag: "script",
|
|
57
70
|
attrs: {
|
|
58
71
|
type: "module",
|
|
59
|
-
src:
|
|
72
|
+
src: h
|
|
60
73
|
},
|
|
61
74
|
injectTo: "head"
|
|
62
75
|
}];
|
|
63
76
|
}
|
|
64
77
|
};
|
|
65
78
|
}
|
|
66
|
-
|
|
79
|
+
function y(r, i) {
|
|
80
|
+
return (a = {}) => {
|
|
81
|
+
let { entry: o, outputFile: s } = t(t({}, i), a);
|
|
82
|
+
return {
|
|
83
|
+
name: r,
|
|
84
|
+
apply: "build",
|
|
85
|
+
closeBundle() {
|
|
86
|
+
return e(function* () {
|
|
87
|
+
try {
|
|
88
|
+
yield n({
|
|
89
|
+
configFile: !1,
|
|
90
|
+
logLevel: "warn",
|
|
91
|
+
build: {
|
|
92
|
+
lib: {
|
|
93
|
+
entry: d.default.isAbsolute(o) ? o : d.default.resolve(process.cwd(), o),
|
|
94
|
+
formats: ["es"],
|
|
95
|
+
fileName: () => s
|
|
96
|
+
},
|
|
97
|
+
outDir: "dist",
|
|
98
|
+
emptyOutDir: !1
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
} catch (e) {
|
|
102
|
+
throw console.error(`[${r}] build failed:`, e), e;
|
|
103
|
+
}
|
|
104
|
+
})();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Vite plugin that produces dist/app-bundle.js after the main build for app-level integrations.
|
|
111
|
+
*
|
|
112
|
+
* The bundle exports `renderThumbnail(puzzleStr, inputStr?, config?)` — a pure
|
|
113
|
+
* SVG-string renderer used by the Puzzmo platform for puzzle previews.
|
|
114
|
+
*/
|
|
115
|
+
const b = y("app-bundle", {
|
|
116
|
+
entry: "src/appBundle.js",
|
|
117
|
+
outputFile: "app-bundle.js"
|
|
118
|
+
}), x = y("editor-bundle", {
|
|
119
|
+
entry: "src/editorBundle.js",
|
|
120
|
+
outputFile: "editor-bundle.js"
|
|
121
|
+
});
|
|
122
|
+
export { b as appBundlePlugin, x as editorBundlePlugin, v as puzzmoSimulator };
|
|
67
123
|
|
|
68
124
|
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import type { Plugin } from \"vite\"\
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../__vite-browser-external","../src/vite.ts"],"sourcesContent":["module.exports = {}","import type { Plugin } from \"vite\"\nimport { build } from \"vite\"\nimport path from \"path\"\n\nexport type PuzzmoSimulatorPluginOptions = {\n /** Whether to auto-start the game after READY (default: true) */\n autoStart?: boolean\n /** Initial collapsed state (default: true) */\n collapsed?: boolean\n /** Game slug for API features (e.g. \"crossword\", \"my-game\") */\n slug?: string\n /** Glob pattern for fixture files, passed to import.meta.glob (e.g. \"./fixtures/puzzles/**\\/*.json\") */\n fixturesGlob?: string\n}\n\nconst SIMULATOR_URL = \"/@puzzmo-simulator-init.js\"\nconst VIRTUAL_ID = \"virtual:puzzmo-simulator\"\nconst RESOLVED_VIRTUAL_ID = \"\\0\" + VIRTUAL_ID\n\n/** Vite plugin that injects the Puzzmo simulator in dev mode and handles OAuth callbacks. */\nexport function puzzmoSimulator(options: PuzzmoSimulatorPluginOptions = {}): Plugin {\n function generateCode(): string {\n const { fixturesGlob, ...config } = options\n\n const lines = [`import { createSimulator } from \"@puzzmo/sdk/simulator\"`]\n\n if (fixturesGlob) {\n lines.push(`const fixtures = import.meta.glob(${JSON.stringify(fixturesGlob)}, { eager: true })`)\n }\n\n const configEntries = Object.entries(config).filter(([, v]) => v !== undefined)\n const configParts = configEntries.map(([k, v]) => `${k}: ${JSON.stringify(v)}`)\n if (fixturesGlob) configParts.push(\"fixtures\")\n\n lines.push(`createSimulator({ ${configParts.join(\", \")} })`)\n\n return lines.join(\"\\n\")\n }\n\n return {\n name: \"puzzmo-simulator\",\n apply: \"serve\",\n\n // Virtual module used internally for code generation and transformation.\n // Uses \\0 prefix so Vite's HTML processor won't try to inline it.\n resolveId(id) {\n if (id === VIRTUAL_ID) return RESOLVED_VIRTUAL_ID\n },\n\n load(id) {\n if (id === RESOLVED_VIRTUAL_ID) return generateCode()\n },\n\n configureServer(server) {\n server.middlewares.use(\"/oauth/callback\", (_req, res) => {\n res.setHeader(\"Content-Type\", \"text/html\")\n res.end(`<!DOCTYPE html>\n<html><head><title>Puzzmo OAuth</title></head>\n<body><script>\nvar params = new URLSearchParams(window.location.search);\nvar returnUrl = sessionStorage.getItem(\"oauth_return_url\") || \"/\";\nvar url = new URL(returnUrl);\nparams.forEach(function(v, k) { url.searchParams.set(k, v); });\nwindow.location.href = url.toString();\n</script></body></html>`)\n })\n\n // Serve the simulator init module. Registered before Vite's internal\n // middleware so the SPA fallback doesn't intercept it.\n server.middlewares.use(async (req, res, next) => {\n if (req.url?.split(\"?\")[0] !== SIMULATOR_URL) return next()\n\n const result = await server.transformRequest(VIRTUAL_ID)\n if (!result) return next()\n res.setHeader(\"Content-Type\", \"application/javascript\")\n res.end(result.code)\n })\n },\n\n // Inject a script tag whose src the browser will fetch.\n // The URL is NOT resolvable via resolveId (intentionally), so Vite's\n // HTML processor won't inline it. The middleware above serves it instead.\n transformIndexHtml() {\n return [\n {\n tag: \"script\",\n attrs: { type: \"module\", src: SIMULATOR_URL },\n injectTo: \"head\",\n },\n ]\n },\n }\n}\n\ntype BundlePluginOptions = {\n /** Entry file for the bundle */\n entry: string\n /** Output file name */\n outputFile: string\n}\n\nfunction createBundlePlugin(pluginName: string, defaults: BundlePluginOptions) {\n return (options: Partial<BundlePluginOptions> = {}): Plugin => {\n const { entry, outputFile } = { ...defaults, ...options }\n return {\n name: pluginName,\n apply: \"build\",\n async closeBundle() {\n try {\n await build({\n configFile: false,\n logLevel: \"warn\",\n build: {\n lib: {\n entry: path.isAbsolute(entry) ? entry : path.resolve(process.cwd(), entry),\n formats: [\"es\"],\n fileName: () => outputFile,\n },\n outDir: \"dist\",\n emptyOutDir: false,\n },\n })\n } catch (error) {\n console.error(`[${pluginName}] build failed:`, error)\n throw error\n }\n },\n }\n }\n}\n\nexport type AppBundlePluginOptions = Partial<BundlePluginOptions>\n\n/**\n * Vite plugin that produces dist/app-bundle.js after the main build for app-level integrations.\n *\n * The bundle exports `renderThumbnail(puzzleStr, inputStr?, config?)` — a pure\n * SVG-string renderer used by the Puzzmo platform for puzzle previews.\n */\nexport const appBundlePlugin = createBundlePlugin(\"app-bundle\", { entry: \"src/appBundle.js\", outputFile: \"app-bundle.js\" })\n\nexport type EditorBundlePluginOptions = Partial<BundlePluginOptions>\n\n/** Vite plugin that produces dist/editor-bundle.js after the main build for editor-level integrations. */\nexport const editorBundlePlugin = createBundlePlugin(\"editor-bundle\", { entry: \"src/editorBundle.js\", outputFile: \"editor-bundle.js\" })\n"],"mappings":";;;;;;;;;;;;AAAA,GAAO,UAAU,EAAA;;;;;;;;;;;;;;;;;;;;SCsBL,eAAA,EAPN,IAAgB,8BAChB,IAAa,4BACb,IAAsB,OAAO;;AAGnC,SAAgB,EAAgB,IAAwC,EAAE,EAAU;CAClF,SAAS,IAAuB;EAC9B,IAAM,EAAE,oBAAA,GAAiB,IAAA,EAAW,GAAA,EAAA,EAE9B,IAAQ,CAAC,4DAA0D;AAEzE,EAAI,KACF,EAAM,KAAK,qCAAqC,KAAK,UAAU,EAAa,CAAC,oBAAoB;EAInG,IAAM,IADgB,OAAO,QAAQ,EAAO,CAAC,QAAQ,GAAG,OAAO,MAAM,KAAA,EAAU,CAC7C,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,IAAI,KAAK,UAAU,EAAE,GAAG;AAK/E,SAJI,KAAc,EAAY,KAAK,WAAW,EAE9C,EAAM,KAAK,qBAAqB,EAAY,KAAK,KAAK,CAAC,KAAK,EAErD,EAAM,KAAK,KAAK;;AAGzB,QAAO;EACL,MAAM;EACN,OAAO;EAIP,UAAU,GAAI;AACZ,OAAI,MAAO,EAAY,QAAO;;EAGhC,KAAK,GAAI;AACP,OAAI,MAAO,EAAqB,QAAO,GAAc;;EAGvD,gBAAgB,GAAQ;AAgBtB,GAfA,EAAO,YAAY,IAAI,oBAAoB,GAAM,MAAQ;AAEvD,IADA,EAAI,UAAU,gBAAgB,YAAY,EAC1C,EAAI,IAAI,uXAQS;KACjB,EAIF,EAAO,YAAY,IAAA,WAAA;yBAAW,GAAK,GAAK,GAAS;;AAC/C,WAAA,IAAI,EAAI,QAAA,OAAA,KAAA,IAAA,EAAK,MAAM,IAAI,CAAC,QAAO,EAAe,QAAO,GAAM;KAE3D,IAAM,IAAS,MAAM,EAAO,iBAAiB,EAAW;AACxD,SAAI,CAAC,EAAQ,QAAO,GAAM;AAE1B,KADA,EAAI,UAAU,gBAAgB,yBAAyB,EACvD,EAAI,IAAI,EAAO,KAAK;;oBANQ,GAAK,GAAK,GAAA;;;OAOtC;;EAMJ,qBAAqB;AACnB,UAAO,CACL;IACE,KAAK;IACL,OAAO;KAAE,MAAM;KAAU,KAAK;KAAe;IAC7C,UAAU;IACX,CACF;;EAEJ;;AAUH,SAAS,EAAmB,GAAoB,GAA+B;AAC7E,SAAQ,IAAwC,EAAE,KAAa;EAC7D,IAAM,EAAE,UAAO,kBAAA,EAAA,EAAA,EAAA,EAAoB,EAAA,EAAa,EAAS;AACzD,SAAO;GACL,MAAM;GACN,OAAO;GACP,cAAM;0BAAc;AAClB,SAAI;AACF,YAAM,EAAM;OACV,YAAY;OACZ,UAAU;OACV,OAAO;QACL,KAAK;SACH,OAAO,EAAA,QAAK,WAAW,EAAM,GAAG,IAAQ,EAAA,QAAK,QAAQ,QAAQ,KAAK,EAAE,EAAM;SAC1E,SAAS,CAAC,KAAK;SACf,gBAAgB;SACjB;QACD,QAAQ;QACR,aAAa;QACd;OACF,CAAC;cACK,GAAO;AAEd,YADA,QAAQ,MAAM,IAAI,EAAW,kBAAkB,EAAM,EAC/C;;;;GAGX;;;;;;;;;AAYL,MAAa,IAAkB,EAAmB,cAAc;CAAE,OAAO;CAAoB,YAAY;CAAiB,CAAC,EAK9G,IAAqB,EAAmB,iBAAiB;CAAE,OAAO;CAAuB,YAAY;CAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function t(t){return function(){var n=this,r=arguments;return new Promise(function(i,a){var o=t.apply(n,r);function s(t){e(o,i,a,s,c,`next`,t)}function c(t){e(o,i,a,s,c,`throw`,t)}s(void 0)})}}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
function e(e, t, n, r, i, a, o) {
|
|
2
|
-
try {
|
|
3
|
-
var s = e[a](o), c = s.value;
|
|
4
|
-
} catch (e) {
|
|
5
|
-
n(e);
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
s.done ? t(c) : Promise.resolve(c).then(r, i);
|
|
9
|
-
}
|
|
10
|
-
function t(t) {
|
|
11
|
-
return function() {
|
|
12
|
-
var n = this, r = arguments;
|
|
13
|
-
return new Promise(function(i, a) {
|
|
14
|
-
var o = t.apply(n, r);
|
|
15
|
-
function s(t) {
|
|
16
|
-
e(o, i, a, s, c, "next", t);
|
|
17
|
-
}
|
|
18
|
-
function c(t) {
|
|
19
|
-
e(o, i, a, s, c, "throw", t);
|
|
20
|
-
}
|
|
21
|
-
s(void 0);
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export { t };
|