marko 6.0.53 → 6.0.55

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.
@@ -1997,7 +1997,9 @@ function writeBranchEnd(scopeId, accessor, resumeMarker, parentEndTag, mark) {
1997
1997
  }
1998
1998
  }
1999
1999
  var writeScope = (scopeId, partialScope) => {
2000
- const { state } = $chunk.boundary;
2000
+ return writeScopeToState($chunk.boundary.state, scopeId, partialScope);
2001
+ };
2002
+ function writeScopeToState(state, scopeId, partialScope) {
2001
2003
  const { scopes } = state;
2002
2004
  let scope = scopes.get(scopeId);
2003
2005
  state.needsMainRuntime = true;
@@ -2014,7 +2016,7 @@ var writeScope = (scopeId, partialScope) => {
2014
2016
  state.writeScopes = { [scopeId]: scope };
2015
2017
  }
2016
2018
  return scope;
2017
- };
2019
+ }
2018
2020
  if (true) {
2019
2021
  writeScope = /* @__PURE__ */ ((writeScope2) => (scopeId, partialScope, file, loc, vars) => {
2020
2022
  const scope = writeScope2(scopeId, partialScope);
@@ -3286,22 +3288,33 @@ var compat = {
3286
3288
  writeScope(branchId, { m5c });
3287
3289
  writeEffect(branchId, SET_SCOPE_REGISTER_ID);
3288
3290
  },
3289
- toJSON() {
3290
- let compatRegistered = COMPAT_REGISTRY.get(this);
3291
- if (!compatRegistered) {
3292
- const registered = getRegistered(this);
3293
- if (registered) {
3294
- const scopeId = getScopeId(registered.scope);
3295
- if (scopeId !== void 0) {
3296
- writeScope(scopeId, {});
3291
+ toJSON(state) {
3292
+ return function toJSON() {
3293
+ let compatRegistered = COMPAT_REGISTRY.get(this);
3294
+ if (!compatRegistered) {
3295
+ const registered = getRegistered(this);
3296
+ if (registered) {
3297
+ const scopeId = getScopeId(registered.scope);
3298
+ if (scopeId !== void 0) {
3299
+ writeScopeToState(state, scopeId, {});
3300
+ }
3301
+ COMPAT_REGISTRY.set(
3302
+ this,
3303
+ compatRegistered = [registered.id, scopeId]
3304
+ );
3297
3305
  }
3298
- COMPAT_REGISTRY.set(
3299
- this,
3300
- compatRegistered = [registered.id, scopeId]
3301
- );
3302
3306
  }
3307
+ return compatRegistered;
3308
+ };
3309
+ },
3310
+ flushScript($global2) {
3311
+ const boundary = new Boundary(this.ensureState($global2));
3312
+ if (!boundary.done) {
3313
+ throw new Error(
3314
+ "Cannot serialize promise across tags/class compat layer."
3315
+ );
3303
3316
  }
3304
- return compatRegistered;
3317
+ return new Chunk(boundary, null, null).flushScript().scripts;
3305
3318
  },
3306
3319
  render(renderer, willRerender, classAPIOut, component, input, completeChunks) {
3307
3320
  const boundary = new Boundary(this.ensureState(classAPIOut.global));
@@ -1913,7 +1913,9 @@ function writeBranchEnd(scopeId, accessor, resumeMarker, parentEndTag, mark) {
1913
1913
  }
1914
1914
  }
1915
1915
  var writeScope = (scopeId, partialScope) => {
1916
- const { state } = $chunk.boundary;
1916
+ return writeScopeToState($chunk.boundary.state, scopeId, partialScope);
1917
+ };
1918
+ function writeScopeToState(state, scopeId, partialScope) {
1917
1919
  const { scopes } = state;
1918
1920
  let scope = scopes.get(scopeId);
1919
1921
  state.needsMainRuntime = true;
@@ -1930,7 +1932,7 @@ var writeScope = (scopeId, partialScope) => {
1930
1932
  state.writeScopes = { [scopeId]: scope };
1931
1933
  }
1932
1934
  return scope;
1933
- };
1935
+ }
1934
1936
  if (true) {
1935
1937
  writeScope = /* @__PURE__ */ ((writeScope2) => (scopeId, partialScope, file, loc, vars) => {
1936
1938
  const scope = writeScope2(scopeId, partialScope);
@@ -3202,22 +3204,33 @@ var compat = {
3202
3204
  writeScope(branchId, { m5c });
3203
3205
  writeEffect(branchId, SET_SCOPE_REGISTER_ID);
3204
3206
  },
3205
- toJSON() {
3206
- let compatRegistered = COMPAT_REGISTRY.get(this);
3207
- if (!compatRegistered) {
3208
- const registered = getRegistered(this);
3209
- if (registered) {
3210
- const scopeId = getScopeId(registered.scope);
3211
- if (scopeId !== void 0) {
3212
- writeScope(scopeId, {});
3207
+ toJSON(state) {
3208
+ return function toJSON() {
3209
+ let compatRegistered = COMPAT_REGISTRY.get(this);
3210
+ if (!compatRegistered) {
3211
+ const registered = getRegistered(this);
3212
+ if (registered) {
3213
+ const scopeId = getScopeId(registered.scope);
3214
+ if (scopeId !== void 0) {
3215
+ writeScopeToState(state, scopeId, {});
3216
+ }
3217
+ COMPAT_REGISTRY.set(
3218
+ this,
3219
+ compatRegistered = [registered.id, scopeId]
3220
+ );
3213
3221
  }
3214
- COMPAT_REGISTRY.set(
3215
- this,
3216
- compatRegistered = [registered.id, scopeId]
3217
- );
3218
3222
  }
3223
+ return compatRegistered;
3224
+ };
3225
+ },
3226
+ flushScript($global2) {
3227
+ const boundary = new Boundary(this.ensureState($global2));
3228
+ if (!boundary.done) {
3229
+ throw new Error(
3230
+ "Cannot serialize promise across tags/class compat layer."
3231
+ );
3219
3232
  }
3220
- return compatRegistered;
3233
+ return new Chunk(boundary, null, null).flushScript().scripts;
3221
3234
  },
3222
3235
  render(renderer, willRerender, classAPIOut, component, input, completeChunks) {
3223
3236
  const boundary = new Boundary(this.ensureState(classAPIOut.global));
@@ -14,7 +14,8 @@ export declare const compat: {
14
14
  onFlush(fn: (chunk: Chunk) => void): void;
15
15
  patchDynamicTag: typeof patchDynamicTag;
16
16
  writeSetScopeForComponent(branchId: number, m5c: string): void;
17
- toJSON(this: WeakKey): [registryId: string, scopeId: unknown] | undefined;
17
+ toJSON(state: State): (this: WeakKey) => [registryId: string, scopeId: unknown] | undefined;
18
+ flushScript($global: any): string;
18
19
  render(renderer: ServerRenderer, willRerender: boolean, classAPIOut: any, component: any, input: any, completeChunks: Chunk[]): void;
19
20
  registerRenderer(renderer: any, id: string): any;
20
21
  registerRenderBody(fn: any): void;
@@ -44,6 +44,7 @@ export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: un
44
44
  export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
45
45
  export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
46
46
  declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
47
+ export declare function writeScopeToState(state: State, scopeId: number, partialScope: PartialScope): ScopeInternals;
47
48
  export { writeScope };
48
49
  export declare function writeExistingScope(scopeId: number): ScopeInternals;
49
50
  export declare function ensureScopeWithId(scopeId: number): PartialScope;
package/dist/html.js CHANGED
@@ -1291,10 +1291,11 @@ function writeBranchEnd(scopeId, accessor, resumeMarker, parentEndTag, mark) {
1291
1291
  let endTag = parentEndTag || "";
1292
1292
  resumeMarker ? mark ? $chunk.writeHTML(mark + endTag) : $chunk.writeHTML(endTag + markResumeNode(scopeId, accessor)) : $chunk.writeHTML(endTag);
1293
1293
  }
1294
- var writeScope = (scopeId, partialScope) => {
1295
- let { state } = $chunk.boundary, { scopes } = state, scope = scopes.get(scopeId);
1294
+ var writeScope = (scopeId, partialScope) => writeScopeToState($chunk.boundary.state, scopeId, partialScope);
1295
+ function writeScopeToState(state, scopeId, partialScope) {
1296
+ let { scopes } = state, scope = scopes.get(scopeId);
1296
1297
  return state.needsMainRuntime = !0, scope ? Object.assign(scope, partialScope) : (scope = partialScope, scope[K_SCOPE_ID] = scopeId, state.scopes.set(scopeId, scope)), state.writeScopes ? state.writeScopes[scopeId] = scope : state.writeScopes = { [scopeId]: scope }, scope;
1297
- };
1298
+ }
1298
1299
  function writeExistingScope(scopeId) {
1299
1300
  return writeScope(scopeId, ensureScopeWithId(scopeId));
1300
1301
  }
@@ -2114,19 +2115,29 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
2114
2115
  writeSetScopeForComponent(branchId, m5c) {
2115
2116
  writeScope(branchId, { m5c }), writeEffect(branchId, SET_SCOPE_REGISTER_ID);
2116
2117
  },
2117
- toJSON() {
2118
- let compatRegistered = COMPAT_REGISTRY.get(this);
2119
- if (!compatRegistered) {
2120
- let registered = getRegistered(this);
2121
- if (registered) {
2122
- let scopeId = getScopeId(registered.scope);
2123
- scopeId !== void 0 && writeScope(scopeId, {}), COMPAT_REGISTRY.set(
2124
- this,
2125
- compatRegistered = [registered.id, scopeId]
2126
- );
2118
+ toJSON(state) {
2119
+ return function() {
2120
+ let compatRegistered = COMPAT_REGISTRY.get(this);
2121
+ if (!compatRegistered) {
2122
+ let registered = getRegistered(this);
2123
+ if (registered) {
2124
+ let scopeId = getScopeId(registered.scope);
2125
+ scopeId !== void 0 && writeScopeToState(state, scopeId, {}), COMPAT_REGISTRY.set(
2126
+ this,
2127
+ compatRegistered = [registered.id, scopeId]
2128
+ );
2129
+ }
2127
2130
  }
2128
- }
2129
- return compatRegistered;
2131
+ return compatRegistered;
2132
+ };
2133
+ },
2134
+ flushScript($global2) {
2135
+ let boundary = new Boundary(this.ensureState($global2));
2136
+ if (!boundary.done)
2137
+ throw new Error(
2138
+ "Cannot serialize promise across tags/class compat layer."
2139
+ );
2140
+ return new Chunk(boundary, null, null).flushScript().scripts;
2130
2141
  },
2131
2142
  render(renderer, willRerender, classAPIOut, component, input, completeChunks) {
2132
2143
  let boundary = new Boundary(this.ensureState(classAPIOut.global)), head = new Chunk(
package/dist/html.mjs CHANGED
@@ -1210,10 +1210,11 @@ function writeBranchEnd(scopeId, accessor, resumeMarker, parentEndTag, mark) {
1210
1210
  let endTag = parentEndTag || "";
1211
1211
  resumeMarker ? mark ? $chunk.writeHTML(mark + endTag) : $chunk.writeHTML(endTag + markResumeNode(scopeId, accessor)) : $chunk.writeHTML(endTag);
1212
1212
  }
1213
- var writeScope = (scopeId, partialScope) => {
1214
- let { state } = $chunk.boundary, { scopes } = state, scope = scopes.get(scopeId);
1213
+ var writeScope = (scopeId, partialScope) => writeScopeToState($chunk.boundary.state, scopeId, partialScope);
1214
+ function writeScopeToState(state, scopeId, partialScope) {
1215
+ let { scopes } = state, scope = scopes.get(scopeId);
1215
1216
  return state.needsMainRuntime = !0, scope ? Object.assign(scope, partialScope) : (scope = partialScope, scope[K_SCOPE_ID] = scopeId, state.scopes.set(scopeId, scope)), state.writeScopes ? state.writeScopes[scopeId] = scope : state.writeScopes = { [scopeId]: scope }, scope;
1216
- };
1217
+ }
1217
1218
  function writeExistingScope(scopeId) {
1218
1219
  return writeScope(scopeId, ensureScopeWithId(scopeId));
1219
1220
  }
@@ -2033,19 +2034,29 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
2033
2034
  writeSetScopeForComponent(branchId, m5c) {
2034
2035
  writeScope(branchId, { m5c }), writeEffect(branchId, SET_SCOPE_REGISTER_ID);
2035
2036
  },
2036
- toJSON() {
2037
- let compatRegistered = COMPAT_REGISTRY.get(this);
2038
- if (!compatRegistered) {
2039
- let registered = getRegistered(this);
2040
- if (registered) {
2041
- let scopeId = getScopeId(registered.scope);
2042
- scopeId !== void 0 && writeScope(scopeId, {}), COMPAT_REGISTRY.set(
2043
- this,
2044
- compatRegistered = [registered.id, scopeId]
2045
- );
2037
+ toJSON(state) {
2038
+ return function() {
2039
+ let compatRegistered = COMPAT_REGISTRY.get(this);
2040
+ if (!compatRegistered) {
2041
+ let registered = getRegistered(this);
2042
+ if (registered) {
2043
+ let scopeId = getScopeId(registered.scope);
2044
+ scopeId !== void 0 && writeScopeToState(state, scopeId, {}), COMPAT_REGISTRY.set(
2045
+ this,
2046
+ compatRegistered = [registered.id, scopeId]
2047
+ );
2048
+ }
2046
2049
  }
2047
- }
2048
- return compatRegistered;
2050
+ return compatRegistered;
2051
+ };
2052
+ },
2053
+ flushScript($global2) {
2054
+ let boundary = new Boundary(this.ensureState($global2));
2055
+ if (!boundary.done)
2056
+ throw new Error(
2057
+ "Cannot serialize promise across tags/class compat layer."
2058
+ );
2059
+ return new Chunk(boundary, null, null).flushScript().scripts;
2049
2060
  },
2050
2061
  render(renderer, willRerender, classAPIOut, component, input, completeChunks) {
2051
2062
  let boundary = new Boundary(this.ensureState(classAPIOut.global)), head = new Chunk(
@@ -1194,7 +1194,7 @@ var import_compiler5 = require("@marko/compiler");
1194
1194
  var import_babel_utils6 = require("@marko/compiler/babel-utils");
1195
1195
  var kState = Symbol();
1196
1196
  var entry_builder_default = {
1197
- build(entryFile) {
1197
+ build(entryFile, exportInit) {
1198
1198
  const state = entryFile[kState];
1199
1199
  if (!state) {
1200
1200
  throw entryFile.path.buildCodeFrameError(
@@ -1214,12 +1214,19 @@ var entry_builder_default = {
1214
1214
  )
1215
1215
  );
1216
1216
  const { runtimeId } = entryFile.markoOpts;
1217
+ const initExpression = import_compiler5.types.callExpression(
1218
+ import_compiler5.types.identifier("init"),
1219
+ runtimeId ? [import_compiler5.types.stringLiteral(runtimeId)] : []
1220
+ );
1217
1221
  body.push(
1218
- import_compiler5.types.expressionStatement(
1219
- import_compiler5.types.callExpression(
1220
- import_compiler5.types.identifier("init"),
1221
- runtimeId ? [import_compiler5.types.stringLiteral(runtimeId)] : []
1222
- )
1222
+ exportInit ? import_compiler5.types.exportDefaultDeclaration(
1223
+ import_compiler5.types.arrowFunctionExpression([], initExpression)
1224
+ ) : import_compiler5.types.expressionStatement(initExpression)
1225
+ );
1226
+ } else if (exportInit) {
1227
+ body.push(
1228
+ import_compiler5.types.exportDefaultDeclaration(
1229
+ import_compiler5.types.arrowFunctionExpression([], import_compiler5.types.blockStatement([]))
1223
1230
  )
1224
1231
  );
1225
1232
  }
@@ -14,7 +14,7 @@ type EntryFile = t.BabelFile & {
14
14
  };
15
15
  declare const kState: unique symbol;
16
16
  declare const _default: {
17
- build(entryFile: EntryFile): t.Statement[];
17
+ build(entryFile: EntryFile, exportInit?: boolean): t.Statement[];
18
18
  visit(file: t.BabelFile, entryFile: EntryFile, visitChild: (id: string) => void): void;
19
19
  };
20
20
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.53",
3
+ "version": "6.0.55",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",